Socket
Socket
Sign inDemoInstall

express-request-id

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    express-request-id

Generate UUID for request and add it to headers


Version published
Maintainers
1
Created

Readme

Source

express-request-id NPM version Build Status

Generate UUID for request and add it to headers


var app = require('express')();
var addRequestId = require('express-request-id')();

app.use(addRequestId);

app.get('/', function (req, res, next) {
    res.send(req.id);
    next();
});

app.listen(3000, function() {
    console.log('Listening on port %d', server.address().port);
});

// curl localhost:3000
// d7c32387-3feb-452b-8df1-2d8338b3ea22

API

express-request-id([options])

Returns middleware function, that appends request id to req object.

options
  • uuidVersion - version of uuid to use (defaults to v4). Can be one of methods from node-uuid.
  • setHeader - boolean, indicates that header should be added to response (defaults to true).

This options fields are passed to node-uuid functions directly:

  • Whole options object, that can contain fields like: node, clockseq, msecs, nsecs.
  • options.buffer and options.offset to uuid function as second and third parameters.

License

MIT (c) 2013 Vsevolod Strukchinsky (floatdrop@gmail.com)

Keywords

FAQs

Last updated on 02 Jul 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc