hapi-joi-common-schema

1.0.1 • Public • Published

common-headers

Description

Node.js hapi.js common Joi validation schema plugin

Common Joi validation schema: Allows to set common Joi validation schema for routes that doesn't have skipTag or doesn't have skipPath

Usage example:

In manifest.js

 
const Joi = require('joi');
 
module.exports = {
    server: {
        app: {
            slogan: 'New shiny service'
        }
    },
    plugins: {
        'hapi-joi-common-schema': {
            skipTags: ['hapi-swagger'],
            skipPath: [/^\/swaggerui/, /^\/documentation/, /^\/swagger\.json/],
            schema: {
                headers: Joi.object()
                    .label('x-request and x-correlation-id headers')
                    .keys({
                        'x-request-id': Joi.string().required(),
                        'x-correlation-id': Joi.string().required()
                    })
            }
        }
    }

Package Sidebar

Install

npm i hapi-joi-common-schema

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • yehor.manzhula