# express-camelcase-middleware

> Convert requests to and from snake_case to camelCase

Latest version **0.3.0** (published 2023-10-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install express-camelcase-middleware
pnpm add express-camelcase-middleware
yarn add express-camelcase-middleware
bun add express-camelcase-middleware
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2023-10-10 |
| First published | 2020-09-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tim Rexer |
| Maintainers | tjrexer |
| Keywords | express, camelcase, snakecase |

## Links

- npm: https://www.npmjs.com/package/express-camelcase-middleware
- npm.io page: https://npm.io/package/express-camelcase-middleware

## Dependencies (2)

- [camelcase-keys](https://npm.io/package/camelcase-keys.md) 6.2.x
- [snakecase-keys](https://npm.io/package/snakecase-keys.md) 3.2.x

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 0.3.0 (latest) — 2023-10-10
- 0.2.1 — 2020-09-17
- 0.1.0 — 2020-09-12

## README

# Express Camelcase Middleware

Used to convert api requests to/from camelcase/snakecase depending on your requirements.

There are 2 middlewares with this package.  

### snakeCaseHandler
snakeCaseHandler will handle conversions to and from snake_case where camelCase is used internally in an app, with snake_case being supported by the API.  The handler accepts all options from [snakecase-keys](https://www.npmjs.com/package/snakecase-keys).

### camelCaseHandler
camelCaseHandler will handle conversions to and from camelCase where snake_case is used internally in an app, with camelCase being supported by the API. The handler accepts all options from [camelcase-keys](https://www.npmjs.com/package/camelcase-keys).

## Installing
```
npm i express-camelcase-middleware
```

## Usage
You must import the middleware, and then add it to your express app as shown below.  It is required to also include `express.json()` as well as `express.urlencode({extended:true})` since these are used by express to handle conversions of the requests.

### camelCaseHandler
Recommended options used are `{deep: true}`

```
import { camelCaseHandler } from express-camelcase-middleware

const app = express()
app.use(express.json())
app.use(express.urlencoded({extended: true}))
app.use(camelCaseHandler(options))
```

### snakeCaseHandler
Recommended options used are `{deep: true}`

```
import { snakeCaseHandler } from express-camelcase-middleware

const app = express()
app.use(express.json())
app.use(express.urlencoded({extended: true}))
app.use(snakeCaseHandler(options))
```

## Built With
- [Express](http://expressjs.com) - Web Framework
- [Jest](https://jestjs.io/) - Testing Framework
- [snakecase-keys](https://www.npmjs.com/package/snakecase-keys) - Snake Case conversion
- [camelcase-keys](https://www.npmjs.com/package/camelcase-keys) - Camel Case conversion

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