hapi-knex-plugin
Wrap requests with a Knex connection.
Install
NPM
$ npm install hapi-knex-plugin --save
Yarn
$ yarn add hapi-knex-plugin
Usage
In request handlers
In your request handlers you'll have access to request.knex
.
server.route({
method: 'GET',
path: '/user/{id}',
handler: function (request, reply) {
const { id } = request.params;
request.knex('user')
.where({ id: id })
.then(users => reply(users[0]))
.catch(reply)
}
});
License
MIT