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 install --save koa-x-request-id
Adding this into your koa server file:
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 `-`.
// in inject = true, `this[key] = uuid;
app.use(xRequestId(key, noHyphen, inject));