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.
import validateContentType from '@natlibfi/express-validate-content-type';
app.post('/', validateContentType({type: 'application/json'}), (req, res) => {...});
const {default: validateContentType} = require('@natlibfi/express-validate-content-type');
app.post('/', validateContentType({type: 'application/json'}), (req, res) => {...});
Copyright (c) 2019, 2024-2025 University Of Helsinki (The National Library Of Finland)
This project's source code is licensed under the terms of MIT license