@esmilo/yamato
v1.0.2
Published
Express middleware to trim request body
Downloads
3
Readme
Yamato is an express
middleware to remove extra whitespace(s) inside your
request body
. For example, if you send a json like this:
{
"name": " Dimitri Wahyudiputra",
"hobbies": [" Music ", " Playing Tekken"],
"personalInfo": {
"phoneNumber": " +6281234567890 ",
"address": " Somewhere on earth"
},
"isPrivate": true
}
Yamato will trim all the extra whitespaces so you'll get:
{
"name": "Dimitri Wahyudiputra",
"hobbies": ["Music", "Playing Tekken"],
"personalInfo": {
"phoneNumber": "+6281234567890",
"address": "Somewhere on earth"
},
"isPrivate": true
}
Usage
Install Yamato
npm install @esmilo/yamato
Invoke Yamato as a middleware after body-parser
// ...
const yamato = require('@esmilo/yamato');
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(yamato());
// ...