Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@eropple/nestjs-correlation-id
Advanced tools
Middleware for managing X-Correlation-Id headers in NestJS (or any other Express app).
@eropple/nestjs-correlation-id
This package contains a single global middleware that operates on the
X-Correlation-Id
header. If it doesn't exist on the incoming request, it
generates a random UUID and attaches it to the X-Correlation-Id
header on the
request (http.IncomingMessage
) and the response (http.ServerResponse
)
objects within the NestJS request pipeline. If it already exists, the existing
value is copied to the response's headers.
Unlike other packages that do the same thing, this doesn't allow you to change
the header name. That's because other packages in my @eropple/nestjs-*
ecosystem rely on X-Correlation-Id
and this is intended to be used in
conjunction with them.. If you're not going to go use @eropple/nestjs-data-sec
or @eropple/nestjs-auth
, you probably don't care - but almost everybody uses
X-Correlation-Id
or X-Request-Id
, so this still may work for you.
This is tested with Express; as it's a middleware it probably won't work with Fastify. If somebody wants to add a Fastify version, pull requests are gratefully accepted.
yarn install @eropple/nestjs-correlation-id
Add this as the first middleware in your global middleware chain. (That way, anything that comes after it--like, )
import { CorrelationIdMiddleware } from "@eropple/nestjs-correlation-id";
async function init() {
const app: INestApplication = /* ... */
app.use(CorrelationIdMiddleware());
/* add other middleware, interceptors, etc. */
await app.listen(3000);
}
By default, this uses uuid/v4
to generate a value, but you can do whatever
you want by passing a () => string
function to it. UUIDs tend to be the most
common option, though.
FAQs
Middleware for managing X-Correlation-Id headers in NestJS (or any other Express app).
The npm package @eropple/nestjs-correlation-id receives a total of 795 weekly downloads. As such, @eropple/nestjs-correlation-id popularity was classified as not popular.
We found that @eropple/nestjs-correlation-id demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.