@pas7/request-context-core
v0.3.8
Published
Core request context management library
Readme
@pas7/request-context-core
Framework-agnostic request context primitives built on AsyncLocalStorage.
When to use
Use this package if you need request context outside NestJS abstractions, or when building custom integrations.
Installation
pnpm add @pas7/request-context-coreQuick example
import { ContextKey, get, run, set } from '@pas7/request-context-core';
const REQUEST_ID = new ContextKey<string>('requestId');
run({ requestId: 'req-1' }, () => {
const id = get(REQUEST_ID);
set(REQUEST_ID, `${id}-next`);
});Main API
Context,ContextKeyrun,get,set,has,require,mergesnapshot,restoreKeyExistsError,ContextMissingError,ContextNotActiveError,ContextKeyCollisionError
Related
- Root docs:
README.md - Changelog:
CHANGELOG.md - NestJS module:
@pas7/nestjs-request-context
About
Developed by PAS7 - https://pas7.com.ua/
- 📖 Article: NestJS Request Context with ALS
- 📧 Contact: https://pas7.com.ua/contact
License
Apache-2.0
