express-camelcase-middleware
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

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.

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.

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

Package Sidebar

Install

npm i express-camelcase-middleware

Weekly Downloads

10

Version

0.3.0

License

ISC

Unpacked Size

9.19 kB

Total Files

11

Last publish

Collaborators

  • tjrexer