New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

supervizor

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supervizor

Server-level request payload validation for hapi

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-54.55%
Maintainers
1
Weekly downloads
 
Created
Source

supervizor

Server-level request payload validation for hapi.

NPM Version Build Status Coverage Status Dependencies

Table of Contents

Installation

Install via NPM.

$ npm install supervizor

Usage

Register the package as a server plugin and provide a validation function via the options that will be attached to each route.

If the validation fails, a joi-like 400 Bad Request error is returned alongside an additional content-validation: failure response header. If everything is ok, the response will ultimately contain a content-validation: success header.

Example

const Hapi = require('hapi');
const Supervizor = require('supervizor');

server = new Hapi.Server();
server.connection({
    // go nuts
});

const plugin = {
    register: Supervizor,
    options: {
        validator: (payload, options, next) => {
            // In this example, the payload must contain `valid: true`.
            if (!payload.valid) {
                // Be nice to everyone and provide details about the issue.
                const error = new Error('invalid payload');
                error.details = [{ path: 'valid' }];

                return next(error);
            }

            // Be nice to yourself and allow further validation.
            next(null, payload);
        });
    }
};

server.register(plugin, (err) => {

    if (err) {
        throw err;
    }

    server.start(() => {
        // go nuts
    });
});

Keywords

FAQs

Package last updated on 10 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc