Skip to content

3imed-jaberi/koa-better-request-id

Repository files navigation

koa-better-request-id


Build Status Coverage Status NPM version License Code Size

If express-request-id and x-request-id have a baby ❤️.

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.

Installation

# npm ..
$ npm install koa-better-request-id
# yarn ..
$ yarn add koa-better-request-id

Usage

This is a practical example of how to use.

const Koa = require('koa');
const xRequestId = require ('koa-better-request-id');
const app = new Koa();

// You can pass options object to xRequestId
app.use(xRequestId());

OPTIONS

You can pass an object that contains these keys to the xRequestId middleware:

  • uuidVersion — (String) Pick which version of UUID that should used. default to 'v4'
  • uuidOpts — (Object) Optional UUID state to apply. default to {}
  • uuidBuffer — (Array|buffer) Where UUID bytes are to be written. defaultto undefined
  • uuidOffset — (Number) Starting index in buffer at which to begin writing. default to 0
  • noHyphen — (Boolean) Abandon the hyphen or not. default to false
  • setHeader — (Boolean) Should be added to response or not. default to true
  • headerName — (String) Header name to use. default to 'X-Request-Id'
  • attributeName — (String) Attribute name used for the identifier on the ctx/request object default to 'id'

License


MIT © Imed Jaberi

About

If `express-request-id` and `x-request-id` have a baby ❤️.

Resources

License

Stars

Watchers

Forks

Packages

No packages published