The sword is said to be able to cut through anything, even the very fabric of space itself.
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());
// ...