GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ruiquelhas/coutts: File type validation for hapi raw temporary file request payloads.

BranchesTags
Open more actions menu

Latest commit

 

History

34 Commits
34 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

coutts

File type validation for hapi raw temporary file multipart/form-data request payloads.

Like most modern magicians, builds on the work, knowledge and influence of others before it, in this case, fischbacher.

NPM Version Build Status Coverage Status Dependencies Dev Dependencies

Table of Contents

  • Installation
  • Usage
    • Example
  • Supported File Types

Installation

Install via NPM.

$ npm install coutts

Usage

Register the package as a server plugin to enable validation for each route that does not parse — parse: false — into a temporary file, the request payload — output: 'file'. For every other route with a different configuration, the validation is skipped.

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.

Also, if the Content-Type request header is not multipart/form-data, a 415 Unsupported Media Type error is returned, but in this case, without any additional response header.

Example

const Hapi = require('hapi');
const Coutts = require('coutts');

try {
    const server = new Hapi.Server();

    server.route({
        options: {
            payload: {
                output: 'file',
                parse: false
            }
            // go nuts
        }
    });

    await server.register({
        plugin: Coutts,
        options: {
            // Allow png files only
            whitelist: ['image/png']
        }
    });

    await server.start();
}
catch (err) {
    throw err;
}

Supported File Types

The same as file-type.

About

File type validation for hapi raw temporary file request payloads.

www.npmjs.com/package/coutts

Resources

Readme
BSD-3-Clause license

Contributing

Contributing
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.