hapi-ending

An endpoint documentation plugin for HapiJS

Showing:

Popularity

Downloads/wk

62

GitHub Stars

30

Maintenance

Last Commit

2yrs ago

Contributors

5

Package

Dependencies

13

Size (min+gzip)

95.1KB

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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)

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial