hapi-request-id

A Hapi.js plugin for setting request ID from request ID headers

Usage no npm install needed!

<script type="module">
  import hapiRequestId from 'https://cdn.skypack.dev/hapi-request-id';
</script>

README

Hapi Request ID

This module is a plugin for Hapi.js that sets the id property of each Hapi.js request object on a server to the value of that request's X-Request-ID header. This makes it easier to corrolate requests across multiple Hapi applications and things like the Heroku routing stack.

Usage

const Hapi      = require('hapi');
const RequestID = require('hapi-request-id');
const server    = new Hapi.Server();

server.register([
  RequestID
], function(err) {
  /* etc. */
});

// You can also specify any arbitrary header to set as the request ID
server.register({
  register: RequestID,
  options: { header: 'x-my-custom-id-header' }
}, function(err) {
  /* etc. */
});