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


Version published
Maintainers
1
Weekly downloads
96,979
increased by2.01%

Weekly downloads

Readme

Source

express-request-id

Tests npm version npm downloads

Generates UUID for request and add it to header.

Install

npm install express-request-id

Usage

import express from 'express';
import requestID from 'express-request-id';

app.use(requestID());

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

requestID(options?)

options

Type: object

generator

Type: function Default: func(req) { return uuidv4(); }

Defines function, that generated ID from request. By default used uuid module, that generated UUID V4 for every request.

headerName

Type: string Default: X-Request-Id

Defines name of header, that should be used for request ID checking and setting.

setHeader

Type: bool Default: true

If false – header will not be set.

Keywords

FAQs

Last updated on 05 Oct 2022

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