koa-x-request-id

2.0.0 • Public • Published

koa-x-request-id

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.

NPM version Build status Test coverage License Dependency status

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))

Package Sidebar

Install

npm i koa-x-request-id

Weekly Downloads

135

Version

2.0.0

License

MIT

Last publish

Collaborators

  • fundon