Skip to content

koa-modules/x-request-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 NPM Downloads Build status Test coverage Dependency status License

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

About

Generates a unique Request ID for every incoming HTTP request.

Resources

License

Stars

Watchers

Forks

Packages

No packages published