@natlibfi/express-validate-content-type
v2.0.3
Published
Express.js middleware for validating content type
Downloads
129
Readme
Express.js middleware for validating content type
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, 2024 University Of Helsinki (The National Library Of Finland)
This project's source code is licensed under the terms of MIT license