https://github.com/softonic/hapi-blister-dependency
Hapi plugin to use a Blister container dependency as the handler of a route
https://github.com/softonic/hapi-blister-dependency
Last synced: about 1 year ago
JSON representation
Hapi plugin to use a Blister container dependency as the handler of a route
- Host: GitHub
- URL: https://github.com/softonic/hapi-blister-dependency
- Owner: softonic
- License: other
- Created: 2016-11-13T12:01:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T03:32:46.000Z (over 3 years ago)
- Last Synced: 2025-03-14T19:53:00.508Z (about 1 year ago)
- Language: JavaScript
- Size: 936 KB
- Stars: 0
- Watchers: 19
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
```bash
npm install @softonic/hapi-blister-dependency
```
## Usage
```javascript
// CommonJS
// const HapiBlisterDependency = require('@softonic/hapi-blister-dependency');
// ES6
import HapiBlisterDependency from '@softonic/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:
```bash
npm test
```
## Contribute
1. Fork it: `git clone https://github.com/softonic/hapi-blister-dependency.git`
2. Create your feature branch: `git checkout -b feature/my-new-feature`
3. Commit your changes: `git commit -am 'Added some feature'`
4. Check the build: `npm run build`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D