Registry / database / hapi-postgres-pool

hapi-postgres-pool

JSON →
library2.2.5jsnpmunverified

Hapi plugin (v2.x) for connecting to multiple PostgreSQL databases using connection pools. Provides access via server and request objects, supports native pg bindings, and allows attaching queries based on URL params. Uses pg-pool under the hood. Last updated 2017, appears unmaintained (no recent releases).

npm install hapi-postgres-pool
INSTALL
IMPORT
SIG · HAPI-POSTGRES-POOL
H
hapi-postgres-pool
databasejavascriptv2.2.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const plugin = require('hapi-postgres-pool')
import plugin from 'hapi-postgres-pool'
CommonJS only; no ES module export.

Registers the plugin with a single PostgreSQL connection and runs a simple query.

const Hapi = require('@hapi/hapi'); const plugin = require('hapi-postgres-pool'); const server = Hapi.server({ port: 3000 }); await server.register({ plugin: plugin, options: { default: 'primary', connections: [ { key: 'primary', connectionString: 'postgres://user:pass@localhost:5432/mydb' } ] } }); // Access pool via server const pool = server.pg.primary; const { rows } = await pool.query('SELECT NOW()'); console.log(rows); await server.start();
Debug
Known issues
deprecatedPlugin is unmaintained; no updates since 2017. May not work with modern Hapi v19+.
fix
Consider migrating to '@hapi/postgresql-connection' or 'knex' with Hapi plugins.
affects: >=2.0.0
breakingRequires Hapi v17+ (uses async/await). Older Hapi v16 not supported.
fix
Ensure Hapi version is 17 or newer. For v16, use version 1.x of this plugin.
affects: >=2.0.0
gotchaThe connection pools are attached to server.pg and request.pg with the 'key' value. If no default is set and the key is not matched, pooled connections may be undefined.
fix
Always set a 'default' key or ensure the requested key exists in connections.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'hapi-postgres-pool'
Package was not installed or name is misspelled.
fix
npm install hapi-postgres-pool
TypeError: Cannot read property 'query' of undefined
Attempted to access a connection key that does not exist in options.connections.
fix
Ensure the key used (e.g., server.pg.mykey) matches one defined in options.connections.
Upgrade
Version history
2.2.5latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client library
@hapi/joirequiredValidation library used internally
Agent activity
6 hits · last 30 days
node
6
Resources
hapi-postgres-pool — npm install hapi-postgres-pool · libregistry