Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

koa-better-request-id

3imed-jaberi371MIT2.0.0


request-id, request-uuid, x-request-id, uuid, middleware, koa

readme

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'.

Support Node.js 18+.

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

changelog

CHANGE LOG

v2.0.0 (06 Dec 2024)

  • fix vulnerability by update deps.
  • drop support for all node.js versions less than 18.
  • replace mocha with native node.js test runner.
  • use async/await syntax for the test cases over 'done'.

v1.2.0 (24 Apr 2022)

  • fix vulnerability by update deps.
  • drop ci for node 10 and support only 12 - 16.

v1.1.0 (3 Aout 2020)

  • fix vulnerability.

v1.0.0 (11 July 2020)