hapi plugin conventions
// index.js - the main entry point
import Joi from 'joi';
import pkg from '../package.json';
import routes from './routes';
import pluginOptionsSchema from './schemas/pluginOptions';
export const register = (server, options, next) => {
const { error, value } = Joi.validate(options, pluginOptionsSchema);
if (error) {
return next(error);
}
server.route(routes);
return next();
};
register.attributes = {
pkg,
dependencies: ['someOtherPlugin'],
};
- src
- - lib
- - handlers
- - - handler1.js
- - - handler2.js # could be a pre as well
- - server-methods
- - routes
- - - index.js
- - - products.js
- - schemas
- - - pluginOptions.js
- - - product.js
- - index.js
- test
- .eslintignore
- .eslintrc
- .gitignore
- README.md
- package.json
Examples - https://github.com/viczam/hb-user
request.log(tags, data)
in your handlers