req-parser
v1.0.3
Published
A middleware function for parsing request bodies in Express.js. It automatically detects the content type and parses the body accordingly.
Downloads
17
Maintainers
Readme
req-parser
A lightweight and flexible middleware for parsing the request body in Express.
Installation
Install with npm:
npm install req-parser
Usage
const express = require("express");
const bodyParser = require("req-parser");
const app = express();
// Use bodyParser middleware
app.use(bodyParser);
// Handle POST requests
app.post("/", (req, res) => {
console.log(req.body);
res.send("Got it!");
});
app.listen(3000, () => {
console.log("Server listening on port 3000");
});
Options The middleware automatically detects the content type of the request body and parses it accordingly. Supported content types are:
- application/json
- application/x-www-form-urlencoded
- any other content type (treated as plain text)
License ISC