1.0.8 • Published 7 years ago

restify-x-request-id v1.0.8

Weekly downloads
11
License
ISC
Repository
github
Last release
7 years ago

Restify X-Request-Id

alt Build

A middleware for restify to add request id in response object.

The default behaviour is very simple, the middleware checks if there's an UUID in X-Request-Id in request header, if so just set the same header to response object.

If there's no X-Request-Id in request object then a new UUID is generated and added to the response object, so this way every micro service that is called will keep passing the same ID to keep tracking of the request from the beginning to the end.

Install

npm install --save restify-x-request-id

Usage ES6/Typescript

import RestfiyXRequestId from "restify-x-request-id";
...
server.use(RestfiyXRequestId.middleware);
...

Usage ES5

var restfiyXRequestId = require("restify-x-request-id").default;
...
server.use(restfiyXRequestId.middleware);
...

Obtaining the generated request id

Since the X-Request-Id is linked to the request object (req.reqId), to access you must write:

server.use((req, res, next) => {
    console.log(req.reqId);
    //The output will be something like: f2bf0a3b-5d34-43ad-879b-6eceaa0b089e
    return next();
);
1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago