Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

houdin

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

houdin

Route-level file type validation for hapi parsed in-memory request payloads

  • 2.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by40%
Maintainers
1
Weekly downloads
 
Created
Source

houdin

Route-level file type validation for hapi parsed in-memory multipart/form-data request payloads. Also works as a standalone module.

NPM Version Build Status Coverage Status Dependencies

Table of Contents

Installation

Install via NPM.

$ npm install houdin

Usage

validate(payload, options, fn)

Validates all Buffer values in a payload given a whitelist of file types provided in the options. Results in a joi-like ValidationError if some file type is not allowed or unknown otherwise it returns the original parsed payload to account for additional custom validation.

Hapi
const Hapi = require('hapi');
const Houdin = require('houdin');

const server = new Hapi.Server();

server.connection({
    routes: {
        validate: {
            options: {
                whitelist: ['image/png']
            }
        }
    }
});

server.route({
    config: {
        validate: {
            payload: Houdin.validate
        },
        payload: {
            output: 'data',
            parse: true
        }
    }
});

Standalone

const Houdin = require('houdin');

const options = { whitelist: ['image/png'] };
const png = Buffer.from('89504e47', 'hex');

Houdin.validate({ file: png }, options, (err, value) => {

    console.log(err); // null
    console.log(value); // { file: <Buffer 89 50 4e 47> }
});
const Houdin = require('houdin');

const options = { whitelist: ['image/png'] };
const gif = Buffer.from('47494638', 'hex');

Houdin.validate({ file: gif }, options, (err, value) => {

    console.log(err); // [ValidationError: child "file" fails because ["file" type is not allowed]]
    console.log(value); // undefined
});

Supported File Types

The same as file-type.

Keywords

FAQs

Package last updated on 03 Jun 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