# trim-request

> Express middleware to trim all incoming request object

Latest version **1.0.6** (published 2017-10-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install trim-request
pnpm add trim-request
yarn add trim-request
bun add trim-request
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2017-10-07 |
| First published | 2017-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Younes Elfe |
| Maintainers | younell |
| Keywords | express, trim, sanitize, body, params, query, string |

## Links

- npm: https://www.npmjs.com/package/trim-request
- Repository: https://github.com/Younell/trim-request
- Homepage: https://github.com/Younell/trim-request#readme
- Issues: https://github.com/Younell/trim-request/issues
- npm.io page: https://npm.io/package/trim-request

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2017-10-07
- 1.0.5 — 2017-10-07
- 1.0.4 — 2017-10-07
- 1.0.3 — 2017-10-07
- 1.0.2 — 2017-10-07
- 1.0.1 — 2017-10-07
- 1.0.0 — 2017-10-06

## README

# 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 

```javascript
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

---
_Source: https://npm.io/package/trim-request · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
