hapi-decorating
v1.0.1-rc15
Published
Typescript decorators for Hapi
Downloads
54
Readme
hapi-decorating
Typescript decorators for HapiJS
Advantages over the original https://github.com/Boulangerie/hapiour-decorators[hapiour-decorators]:
New decorators added:
@param_number
@request_attr
@require_request_attr
@request
@reply
@param
Controller (
@Module
) Interceptor supportReply Exception if error happen
Support https://github.com/pleerock/typedi[TypeDI]
Inject arguments to Route Handler just like Java Spring
Sample
@Service()
export class SomeInterceptor extends Interceptor {
@Inject()
private service: SomeService;
async intercept(@request request, @param_number user_id?: number) {
...
}
}
@Module({basePath: '/path', interceptors: [SomeInterceptor]})
export class YourController {
@Inject()
private service: SomeService;
@Route({method: 'POST', path: '/{user_id}/clients'})
async getToken(@request_attr googleAuth, @request_attr payload: any, @param_number user_id): Promise<any> {
return "something";
}
...
}
- Npm package: https://www.npmjs.com/package/hapi-decorating
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Write your code and tests
- Ensure all tests still pass
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new pull request