@pas7/nestjs-request-context-shared
v0.3.8
Published
Shared types and utilities for @pas7/nestjs-request-context adapters
Maintainers
Readme
@pas7/nestjs-request-context-shared
Shared adapter types and interceptor factory for the request-context ecosystem.
When to use
Usually you do not install this package directly. It is pulled in by adapter packages.
Install directly only if you are building your own adapter.
Installation
pnpm add @pas7/nestjs-request-context-sharedMain exports
RequestContextAdapterOptionsDEFAULT_ADAPTER_OPTIONScreateRequestContextInterceptorCreateInterceptorOptions
Quick custom-adapter example
import { createRequestContextInterceptor } from '@pas7/nestjs-request-context-shared';
const interceptor = createRequestContextInterceptor({
options: { header: 'x-request-id' },
getRequestId: (req, header) => req.headers[header],
setRequestId: (res, header, id) => res.setHeader(header, id),
getRequest: (ctx) => ctx.switchToHttp().getRequest(),
getResponse: (ctx) => ctx.switchToHttp().getResponse(),
});Related
- Root docs:
README.md - Changelog:
CHANGELOG.md - Express adapter:
@pas7/nestjs-request-context-adapter-express - Fastify adapter:
@pas7/nestjs-request-context-adapter-fastify
About
Developed by PAS7 - https://pas7.com.ua/
- 📖 Article: NestJS Request Context with ALS
- 📧 Contact: https://pas7.com.ua/contact
License
Apache-2.0
