A middleware for Express that determines the size of each request in bytes.
This package is available on npm as express-request-size. Therefore, it can be installed using the following command:
npm install express-request-size
or, if you're using yarn or pnpm:
yarn add express-request-size
pnpm install express-request-size
This middleware adds the size
property to the request object.
Example usage:
const express = require('express');
const requestSize = require('express-request-size');
const app = express();
app.use(requestSize());
app.get('/', function(req, res) {
// The request size will be available as req.size
});
// ...
This middleware also comes in with built-in types for use in Typescript:
import express from 'express';
import requestSize from 'express-request-size');
const app = express();
app.use(requestSize());
app.get('/', function(req, res) {
// The request size will be available as req.size
});
// ...