
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
This Repo is a Hapi plugin, that adds the possibility to define demo handlers.
The demo handler will be called instead of the original handler, if certain conditions are met.
A possible use-case is to setup routes with demo data, but without adding additional code into the existing code-base.
npm i --save hapi-demo
Set up a hapi server and register the plugin.
import Hapi from 'hapi';
import HapiDemo from 'hapi-demo'
const server = new Hapi.Server();
server.register(HapiDemo)
.then(() => {
console.log('plugin has been registered successfully');
});
When setting up routes, configure the demo handler if necessary:
import Joi from 'joi';
server.route({
method: 'GET',
path: '/test',
handler(request, reply) {
return reply('test handler called');
},
config: {
plugins: {
'hapi-demo': {
shouldApplyHandler(request) {
return request.query.demo;
},
handler(request, reply) {
return reply('demo handler called');
}
}
},
validate: {
query: Joi.object().keys({
demo: Joi.boolean()
})
}
}
});
Now when calling the /test
route without any query parameters the normal hander will be called, but when
calling it with query parameters like /test?demo=true
, then the demo handler will be called.
test
: {function(request: Hapi.Request) : Boolean} - test function that returns if the demo-handler should be calledhandler
: {function(reqest: Hapi.Request, reply: Hapi.Reply)} - demo handlerFAQs
hapi plugin to configure demo handlers
The npm package hapi-demo receives a total of 1 weekly downloads. As such, hapi-demo popularity was classified as not popular.
We found that hapi-demo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.