# express-body-formatter

> A package that allows you format request body easily in other to keep your data at a consistent style

Latest version **1.0.1** (published 2019-05-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-body-formatter
pnpm add express-body-formatter
yarn add express-body-formatter
bun add express-body-formatter
```

## 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.1 |
| Published | 2019-05-19 |
| First published | 2019-05-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kelechi Nwosu |
| Maintainers | klexzi |
| Keywords | express, node, middleware, format, body |

## Links

- npm: https://www.npmjs.com/package/express-body-formatter
- npm.io page: https://npm.io/package/express-body-formatter

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-05-19
- 1.0.0 — 2019-05-19

## README

# express-body-formatter

An express middleware that formats the request body to a particular unified style

## Installation
Using npm

    npm install --save express-body-formatter
Using yarn

    yarn add express-body-formatter

## Usage

    const express = require("express");
    const bodyParser = require("body-parser");
    const bodyFormatter = require("express-body-formatter");
    const app = express();

    app.use(bodyParser.json());
    const options = { exclude: ["name"], trim: true, transform: "lowerCase" }
    app.use(bodyFormatter(options));
    app.use("/", function(req, res) {
      res.json(req.body);
    });

    app.listen(3000);

if a json object is sent to the server, for example:

    {"name": "John Doe ", "status": " I love programmING "}
    
your object will become:

    {name: "John Doe ", "status": "i love programming"}

name will remain the same because it was inluded in the `exclude` array option but status will be formatted accordingly

### Options

all options are optional, to use the default options, you can either send an empty object as an argument or not send an arguement at all


|   options | type    | description                                                                                                                                                                                                              |
| --------: | ------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   exclude | array   | an array of object keys to exclude from formatting, useful when exempting data that needs to remain it was sent                                                                                                          |
|      trim | boolean | if set to true, it removes any whitespace before and after a given value, default value is true                                                                                                                          |
| transform | string  | value of "lowerCase" converts all string to lowercase characters,"upperCase" converts all string to upperCase characters, "capitalize" makes the first letter of each word a capital letter.  default value is lowerCase |

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