New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@newstudios/express-middleware-requestid

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@newstudios/express-middleware-requestid - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

package.json
{
"name": "@newstudios/express-middleware-requestid",
"version": "0.0.2",
"version": "0.0.3",
"description": "A middleware that generates a unique Request ID for every incoming HTTP request in express.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -44,3 +44,3 @@ <div align="center">

Use `@newstudios/express-middleware-requestid` as a middleware for a [koa](https://github.com/koajs/koa) app. By default, it generates a unique uuid (v4) and exposes it on the response via the `X-Request-ID` header. The id is also saved as part of the *ctx.req.id*、*ctx.request.id*、*ctx.id*.
Use `@newstudios/express-middleware-requestid` as a middleware for a [express](https://github.com/expressjs/express) app. By default, it generates a unique uuid (v4) and exposes it on the response via the `X-Request-ID` header. The id is also saved as part of the *req.id*、*req.request.id*、*req.id*.

@@ -50,9 +50,16 @@ In the following example, the generated uuid is manually exposed on the body for debugging purposes:

```js
const Koa = require('koa');
const express = require('express');
const requestId = require('@newstudios/express-middleware-requestid');
const app = new Koa();
const app = express();
app.use(requestId());
app.use(async ctx => {
ctx.body = ctx.id;
app.use(requestId({
type: 'object-id' // uuid
}));
app.get('/', function (req, res, next) {
console.log('new v4 id', requestId.generateID())
console.log('new bson id', requestId.generateID('object-id'))
console.log('req.id', req.id)
res.send('req id is' + req.id)
next();
});

@@ -59,0 +66,0 @@

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