express-parameter-rewriter
v1.1.0
Published
[![Build Status](https://travis-ci.org/Sly321/express-parameter-rewriter.svg?branch=master)](https://travis-ci.org/Sly321/express-parameter-rewriter) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079
Downloads
3
Readme
express-parameter-rewriter
Middleware that allows you to reconfigure the request parameter.
Usage
With yarn:
yarn add express-parameter-rewriter
or npm:
npm i express-parameter-rewriter --save
Example
import * as express from 'express'
// import
import parameterRewriter from 'express-parameter-rewriter'
const app = express()
app.use(parameterRewriter({ hello: 'bye' })) // usage
app.use((req, res, next) => {
console.log(req.url)
console.log(req.originalUrl)
console.log(req.query)
next()
})
app.listen(3000, '0.0.0.0', () => {
console.log('Listening on localhost:3000')
})
If you call http://localhost:3000/?hello=world
(Tools like Insomnia, VSCode Extension Rest Client or any other restclient will do the job), the app will log:
/?bye=world
/?bye=world
{ bye: "world" }