Home

Awesome

lout

API documentation generator for hapi

Build Status

Description

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.

Live demo

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.

Usage

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)
);

Parameters

The following options are available when registering the plugin:

Ignoring a route in documentation

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);
    });
});