/hapi-pg-promise

Primary LanguageJavaScriptMIT LicenseMIT

hapi-pg-promise

Wrap requests with a Postgres connection using promises.

Build Status Dependency Status devDependency Status peerDependency Status

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