
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@moxy/express-ensure-content-type
Advanced tools
Express middleware that ensures requests match the specified content-type
Express middleware that ensures requests match the specified content-type.
$ npm install @moxy/express-ensure-content-type
const express = require('express');
const bodyParser = require('body-parser');
const ensureContentType = require('@moxy/express-ensure-content-type');
const app = express();
app.post(
'/',
bodyParser(),
ensureContentType('application/json'),
(req, res, next) => {
console.log(req.body);
},
);
Creates a middleware that validates a request content-type against contentType
.
If the validation fails, next
will be called with an Error created with http-errors
.
Type: string | array
One or more content-types to match against. It can be:
Please check type-is
for more information.
Type: object
Type: string
Default: always
When to validate. Can be set to:
always
- Always validate.body-present
- Validate if body is present, that is, when the request has Transfer-Encoding
or Content-Length
headers.body-not-empty
- Same as body-present
but skips if Content-Length
is explicitly set to 0, as set by some HTTP clients unnecessarily.Any parameter passed to the test
command is passed down to Jest.
$ npm t
$ npm t -- --watch # To run watch mode
Released under the MIT License.
FAQs
Express middleware that ensures requests match the specified content-type
The npm package @moxy/express-ensure-content-type receives a total of 0 weekly downloads. As such, @moxy/express-ensure-content-type popularity was classified as not popular.
We found that @moxy/express-ensure-content-type demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 22 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.