restify-correlation-id

1.0.1 • Public • Published

Build Status npm version

restify-correlation-id

A restify plugin to track correlation IDs across API requests

Correlation IDs (sometimes called "trace IDs") are unique identifiers that track a request through a series of API calls.

This middleware parses incoming headers for a set correlation ID and stores it away on the req object. If no appropriate headers are sent with the request, a new ID is created instead.

Usage

const restify = require('restify'),
  { cid } = require('restify-correlation-id');

let server = restify.createServer();
server.use(correlationId());

server.get('/', (req, res, next) => {
  res.send(req.cid);
  next();
});

server.listen(8080, () => {
  console.log('I echo correlation IDs!');
});

Option

{
  header: 'CorrelationID'
}

header

The name of the header to parse a correlation ID from. Parsing is case-insensitive. The default header field is "CorrelationID".

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i restify-correlation-id

Weekly Downloads

8

Version

1.0.1

License

MIT

Last publish

Collaborators

  • delta62