hapi-blister-dependency
v2.0.1
Published
Hapi plugin to use a Blister container dependency as the handler of a route
Downloads
44
Readme
hapi-blister-dependency
Hapi plugin to add the "dependencyId" handler to the server. That handler uses the dependency with the given ID as the handler for the route.
Installation
npm install hapi-blister-dependency
Usage
// CommonJS
// const HapiBlisterDependency = require('hapi-blister-dependency');
// ES6
import HapiBlisterDependency from 'hapi-blister-dependency';
import Blister from 'blister';
const container = new Blister();
container.service('my-handler', () => {
return (request, h) => {
h.response('It works!');
};
});
// Registration
await server.register({
plugin: HapiBlisterDependency,
options: { container }
});
server.route({
path: '/test',
handler: {
dependencyId: 'my-handler'
}
});
// GET /test => It works!
Testing
Clone the repository and execute:
npm test
Contribute
- Fork it:
git clone https://github.com/softonic/hapi-blister-dependency.git
- Create your feature branch:
git checkout -b feature/my-new-feature
- Commit your changes:
git commit -am 'Added some feature'
- Check the build:
npm run build
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D