npm.io
1.0.4 • Published 6 years ago

hapi-pg-promise-multi

Licence
MIT
Version
1.0.4
Deps
2
Size
12 kB
Vulns
2
Weekly
0

hapi-pg-promise-multi

Wrap requests with a Postgres connection using promises.

Build Status dependencies Status devDependencies Status peerDependencies Status

We use the pg-promise (pg-promise)

Install

$ npm install hapi-pg-promise-multi

Usage

In your request handlers you'll have access to request.BASE_NAME which you can use to make DB requests.

server.plugins['hapi-pg-promise'].BASE_NAME is available outside of request handlers.

Hapi 18

Current version works with Hapi 18.x.x. For older versions use 1.0.0 of hapi-pg-promise.

Register the plugin
const hapiPgPromise = require('hapi-pg-promise-multi');
const plugin = {
    plugin: hapiPgPromise,
    options: [{
        cn: 'postgres://username:password@host:port/database',
        name: 'BASE_NAME',
        settings: {
            // pg-promise options
        }
    },{
        cn: 'postgres://username:password@host:port/database_next',
        name: 'BASE_NAME_NEXT',
        settings: {
            // pg-promise options
        }
    }]
};

server.register(plugin);

Original

dszczyt/hapi-pg-promise

License

MIT

Keywords