hapi-ending

1.0.1 • Public • Published

Hapi Ending

Lists routes, parameters, and validation constraints for HAPI version 17.x.

CircleCI JavaScript Style Guide

Thanks

Original plugin by Antony Jones, updated for Hapi v17+ by Yulia Tenincheva

  • For HapiJS < v17, use branch hapi-pre-v17 or npm tag 0.9.2
  • For HapiJS > v17, use master, or npm tag > ^1.0.0

What it looks like

Hapi Ending

Configuration

Currently you can configure the baseUrl which is useful if you want to copy and paste urls, and whether the plugin is enabled or not. Disabling the plugin is highly advised for production environments.

var options = {
    baseUrl: 'http://your.domain:1234' // defaults to protocol-less server host+port,
    enabled: true // defaults to false,
    assetsPath: '/mount-point-for-plugin-assets' // defaults to 'assets' - change if this conflicts with your own routes,
    logoUrl: 'http://example.net/logo.webp'
}

Live Demo

To run a quick local demo, use the npm target 'demo':

npm run demo

Usage

Install the plugin in the standard way:

server.register([
    {
        plugin: require('hapi-ending'),
        options: options
    }
], (err) => {
    ...
}

Describing endpoints

You can add a description to routes using the parameters 'description', 'tags', and 'notes' as follows:

    {
        method: 'GET',
        path: '/you/{foo}/name/{baz}',
        options: {
            description: "Describe your endpoint here",
            tags: ['foo', 'authenticated', 'any tag']
            validate: {
                query: {
                    a: Joi.number().describe('This is where you put the number of As'),
                    now: Joi.boolean().describe('Whether I should do it now or later')
                },
                params: {
                    foo: Joi.number().describe('It should more than likely be a number'),
                    baz: Joi.string().describe('Some string thing goes here')
                }
            },
            notes: [
                'This is just a note'
            ]
        },
        handler: function(request, h) {
            ...
        }
    }

Private endpoints

Adding 'private' to any endpoint's tags will make the endpoint private (i.e. unlisted by the plugin)

Package Sidebar

Install

npm i hapi-ending

Weekly Downloads

82

Version

1.0.1

License

none

Unpacked Size

414 kB

Total Files

35

Last publish

Collaborators

  • antony