Plugins
- The plugin directory is located in
src/plugins
, how to implement a simple plugin
exports.plugin = {
name: 'testExample',
register: async (server) =>{
server.route({
method: 'GET',
path: '/testExample',
handler: function (request, h) {
return 'hello, world';
}
});
// server.ext('onRequest', async function (request, h) {
// //...code
// console.log(request.path)
// return h.continue;
// });
}
}
- For plugin development you should know about server properties and plugin configuration
- See plugin sample documentation here
hapi
community plugin https://hapi.dev/plugins/