Socket
Socket
Sign inDemoInstall

@patrtorg/libero-doloribus-omnis

Package Overview
Dependencies
Maintainers
0
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@patrtorg/libero-doloribus-omnis

[![Tests](https://github.com/patrtorg/libero-doloribus-omnis/workflows/CI/badge.svg)](https://github.com/patrtorg/libero-doloribus-omnis/actions) [![npm version](https://img.shields.io/npm/v/@patrtorg/libero-doloribus-omnis.svg)](https://npmjs.org/package


Version published
Maintainers
0
Created
Source

@patrtorg/libero-doloribus-omnis

Tests npm version npm downloads

Generates UUID for ExpressJS requests. Add an id property to the Request object.

Install

npm install --save @patrtorg/libero-doloribus-omnis

Basic Usage

import express from 'express';
import expressRequestId from '@patrtorg/libero-doloribus-omnis';
const PORT = 3000;
app.use(expressRequestId());

app.get('/', function (req, res, next) {
  console.log('Res id: %s', res.get('X-Request-Id'));
  return res.send(req.id);
});

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

// curl localhost:3000
// Res id: e462be8c-5641-4b37-99c1-b0f16b859d2a
// e462be8c-5641-4b37-99c1-b0f16b859d2a

Custom Options Usage

import express from 'express';
import expressRequestId, { Options } from '@patrtorg/libero-doloribus-omnis';
const PORT = 3000;
const options: Options = {
  headerName: 'pizza-id',
  setHeader: false,
  generator: () => `pizza_${Math.random()}`;
};
app.use(expressRequestId(options));

app.get('/', function (req, res, next) {
  console.log('Res id: %s', res.get('pizza-id'));
  return res.send(req.id);
});

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

// curl localhost:3000
// Response id: undefined
// pizza_0.36206992526026704

Options

PropertyTypeDefault ValueDescription
headerNamestring'X-Request-Id'Defines name of header, that should be used for request ID checking and setting.
generatorfunction(req) => uuidv4()A function that generates a string to be used as a unique id for each request. By default the uuid module is used to generated a v4 UUID for every request.
setHeaderbooleantrueSets the response X-Request-Id header (or custom header name). If false response header will not be set.

Keywords

FAQs

Package last updated on 27 Sep 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc