Socket
Book a DemoInstallSign in
Socket

express-camelcase-middleware

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-camelcase-middleware

Convert requests to and from snake_case to camelCase

latest
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

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

Keywords

express

FAQs

Package last updated on 10 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts