1.0.1 • Published 5 years ago

@natlibfi/express-validate-content-type v1.0.1

Weekly downloads
207
License
MIT
Repository
github
Last release
5 years ago

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