Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/svenliebig/express-parameter-rewriter
✍️Middleware that allows you to reconfigure the request parameter.
https://github.com/svenliebig/express-parameter-rewriter
express-middleware url-parameters
Last synced: 8 days ago
JSON representation
✍️Middleware that allows you to reconfigure the request parameter.
- Host: GitHub
- URL: https://github.com/svenliebig/express-parameter-rewriter
- Owner: svenliebig
- License: mit
- Created: 2019-08-03T15:33:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-11T00:35:54.000Z (over 3 years ago)
- Last Synced: 2024-09-05T22:52:30.796Z (2 months ago)
- Topics: express-middleware, url-parameters
- Language: TypeScript
- Homepage: https://sly321.github.io/express-parameter-rewriter/
- Size: 747 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-parameter-rewriter
Middleware that allows you to reconfigure the request parameter.
[![Build Status](https://travis-ci.org/Sly321/express-parameter-rewriter.svg?branch=master)](https://travis-ci.org/Sly321/express-parameter-rewriter)
[![Coverage Status](https://coveralls.io/repos/github/Sly321/express-parameter-rewriter/badge.svg?branch=master)](https://coveralls.io/github/Sly321/express-parameter-rewriter?branch=master)
[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/Sly321/express-parameter-rewriter/master)](https://stryker-mutator.github.io)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)## Usage
With yarn:
```bash
yarn add express-parameter-rewriter
```or npm:
```bash
npm i express-parameter-rewriter --save
```### Example
```typescript
import * as express from 'express'// import
import parameterRewriter from 'express-parameter-rewriter'const app = express()
app.use(parameterRewriter({ hello: 'bye' })) // usageapp.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](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) or any other restclient will do the job), the app will log:
```bash
/?bye=world
/?bye=world
{ bye: "world" }
```