API documentation generator for hapi
lout is a documentation generator for hapi servers, providing a human-readable guide for every endpoint using the route configuration. The module allows full customization of the output.
You can find a live demo of lout using the unit tests routes. The routes are of course fake but you can get a grasp of what lout looks like given various inputs.
Lout depends on vision and inert, make sure you register them with hapi.
const Hapi = require('hapi');
const server = Hapi.server({ port: 80 });
await server.register([require('vision'), require('inert'), require('lout')]);
server.start().then(
console.log('Server running at:', server.info.uri)
);
The following options are available when registering the plugin:
method
and path
and returns a boolean value to exclude routes.If you want a specific route not to appear in lout's documentation, you have to set lout settings for this specific route to false.
Here is an example snippet of a route configuration :
{
method: 'GET',
path: '/myroute',
options: {
handler: [...],
[...]
plugins: {
lout: false
}
}
}
If you want to exclude multiple routes using conditions, you can use filterRoutes
when registering lout :
server.register([require('vision'), require('inert'), {
plugin: require('lout'),
options: {
filterRoutes: (route) => {
return route.method !== '*' && !/^\/private\//.test(route.path);
}
}
}]).then(() => {
server.start(() => {
console.log('Server running at:', server.info.uri);
});
});