Generates a unique Request ID for every incoming HTTP request. This unique ID is then passed to your application as an HTTP header called
X-Request-Id.
Install
$ npm install --save koa-x-request-id
Usage
=2.x, working with koa-v2
app.use(xRequestId({ key, noHyphen, inject }, [app]))
const Koa = require('koa') const xRequestId = require('koa-x-request-id') const app = new Koa() // key defaults to `X-Request-Id` // if `noHyphen = true`, generates 32 uuid, no hyphen `-`. // if `inject = true`, `ctx.id = uuid` app.use(xRequestId({key, noHyphen, inject}, app))
=1.x
app.use(xRequestId(app, { key, noHyphen, inject }))
var koa = require('koa') var xRequestId = require('koa-x-request-id') var app = koa() // key defaults to `X-Request-Id` // if `noHyphen = true`, generates 32 uuid, no hyphen `-`. // if `inject = true`, `ctx.id = uuid` app.use(xRequestId({key, noHyphen, inject}, app))