1.0.2 • Published 3 years ago

@esmilo/yamato v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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());

// ...