Skip to content

Express middleware to trim all incoming request object

License

Notifications You must be signed in to change notification settings

YouneLL/trim-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

trim-request

Express middleware to trim all incoming request object

Installation

npm install trim-request

Usage

trim-request is very simple to use, just import the package and use one of its methods:

trimRequest.all trim body, params and query objects

trimRequest.body trim only the body object

trimRequest.param trim the params object

trimRequest.query trim the query string object

const trimRequest = require('trim-request');

app.post('/person', trimRequest.all, (req, res, next) => { 

    res.json(req.body);

});

if the client post:

{
    name: '  foo   ',
    age: 20,
}

the code above will return this object:

{
    name: 'foo',
    age: 20,
}

License

MIT License

About

Express middleware to trim all incoming request object

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published