hapi-pg-promise
v2.0.0
Published
Wrap requests with a pg connection.
Downloads
30
Readme
hapi-pg-promise
Wrap requests with a Postgres connection using promises.
We use the pg-promise
(pg-promise
)
Install
$ npm install hapi-pg-promise
Usage
In your request handlers you'll have access to request.db
which you
can use to make DB requests.
server.plugins['hapi-pg-promise'].db
is available outside of request
handlers.
Hapi 17
Current version works with Hapi 17.x.x. For older versions use 1.0.0 of hapi-pg-promise.
Register the plugin
const hapiPgPromise = require('hapi-pg-promise');
const plugin = {
plugin: hapiPgPromise,
options: {
cn: 'postgres://username:password@host:port/database',
settings: {
// pg-promise options
}
}
};
server.register(plugin);
License
MIT