Koa Request Trimmer
A dependency-free koa middleware to trim incoming requests - complete with Typescript Typings!
The middleware is able to trim the request body, URL parameters and query string parameters.
Installation
npm i --save koa-request-trimmer
Usage
const Koa = ;// a body parser of your choiceconst trimmer = ; const app = ; const options = body: true query: true params: true; // apply bodyparser middleware of your choice app;
Passing options to the middleware is optional. You can even use it like this:
app;
If you do not provide any options then by default, the middleware will only trim the request body.
To trim other things like query string parameters and URL parameters, the options object needs to be passed to the middleware:
const options = body: true query: true params: true;
setting any of the property to true or false will dictate the middleware as to what to trim and what not.
Using with Typescript
You can import the module in this way:
;
and then pass it on to the Koa App with optional parameters:
app.usetrimmer
Contributors
License
MIT © Hussain Ali Akbar