1.0.1 • Published 8 years ago

hapi-joi-common-schema v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

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