Route dependency checking PoC
const Hapi = require('@hapi/hapi');
const server = Hapi.server();
await server.register({
name: 'app',
register(srv) {
srv.events.on('route', ({ realm, settings }) => {
// If this route originates from this plugin and has dependencies
// then add a dependency to this plugin on behalf of the route.
if (realm === srv.realm && settings.app.dependencies) {
srv.dependency(settings.app.dependencies);
}
});
srv.route({
method: 'get',
path: '/',
options: {
app: { dependencies: ['inert'] }
},
handler: (request, h) => h.file('./my-file')
});
}
});
await server.initialize();
no comments