Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jehy/express-pass-id
Simple expresse middleware module for passing request id
https://github.com/jehy/express-pass-id
Last synced: 10 days ago
JSON representation
Simple expresse middleware module for passing request id
- Host: GitHub
- URL: https://github.com/jehy/express-pass-id
- Owner: jehy
- Created: 2016-12-28T11:40:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-12T14:03:38.000Z (almost 8 years ago)
- Last Synced: 2024-11-02T07:04:52.582Z (18 days ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#Express-Pass-Id
[![Build Status](https://travis-ci.org/jehy/express-pass-id.svg?branch=master)](https://travis-ci.org/jehy/express-pass-id)
Simple express middleware module, inspired by [express-request-id](https://www.npmjs.com/package/express-request-id).
It allows passing prefixes for unique request IDs and using custom headers (because x-request-id is often already used).
##Installation
`npm install express-pass-id`##Usage
**config.json**
```json
{
"prefix": "myService1",
"header": "x-my-id"
}
```**express app file**
```javascript
var
express = require('express'),
app = express(),
config = require('./config.json'),
expressPassId = require('express-pass-id.js')(config),
rp = require('request-promise');app.use(expressPassId);
app.post('/login', function (req, res) {
console.log('Processing route /login, id '+req.id); //print custom ID
var options = {
uri: 'https://google.com',
headers: req.passHeaders //Here we pass our custom header
};
rp(options)
//....
});
```