Skip to content

Commit 7270d3b

Browse files
authored
Update index.js
Added check for duplicate connection names
1 parent 0f6e090 commit 7270d3b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ function fastifyPostgres (fastify, options, next) {
2828
if (!fastify.pg) {
2929
fastify.decorate('pg', {})
3030
}
31-
31+
32+
if (fastify.pg[name]) {
33+
next(new Error('Connection name has already been registered: ' + name))
34+
}
35+
3236
fastify.pg[name] = db
3337
} else {
3438
if (fastify.pg) {

0 commit comments

Comments
 (0)