connect-trim-body
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/connect-trim-body package

0.0.3 • Public • Published

connect-trim-body

Connect/Express middleware to trim parameters in request body. Works recursively.

Dependencies

Requires body-parser middleware.

Usage

var express = require('express')
  , bodyParser = require('body-parser')
  , trimBody = require('connect-trim-body')
  ;
 
var app = express();
 
app.use(bodyParser()); // body-parser first
app.use(trimBody());
 
app.post('/products', function (req, res) {
  res.json(req.body);
});
 
app.listen(3000);
{
  "brand": "HP",
  "model": "EliteBook",
  "description": "   some stuff    "
}
 
// becomes
 
{
  "brand": "HP",
  "model": "EliteBook",
  "description": "some stuff"
}

License

MIT

Package Sidebar

Install

npm i connect-trim-body

Weekly Downloads

40

Version

0.0.3

License

MIT

Last publish

Collaborators

  • samora