@natlibfi/express-validate-content-type

1.0.1 • Public • Published

Express.js middleware for validating content type NPM Version Build Status

Express.js middleware for validating content type. Very simple but often sorely needed. Sends response with status code 415 (Unsupported Media Type) if content type doesn't match. Use Express's req.is behind the scenes.

Usage

ES modules

import validateContentType from '@natlibfi/express-validate-content-type';
app.post('/', validateContentType({type: 'application/json'}), (req, res) => {...});

Node.js require

const {default: validateContentType} = require('@natlibfi/express-validate-content-type');
app.post('/', validateContentType({type: 'application/json'}), (req, res) => {...});

License and copyright

Copyright (c) 2019 University Of Helsinki (The National Library Of Finland)

This project's source code is licensed under the terms of MIT license

Readme

Keywords

none

Package Sidebar

Install

npm i @natlibfi/express-validate-content-type

Weekly Downloads

82

Version

1.0.1

License

MIT

Unpacked Size

19.3 kB

Total Files

9

Last publish

Collaborators