Papooch/nestjs-cls
关于
与 NestJS 依赖注入兼容的延续本地存储(异步上下文)模块。
开发工具实测星标增长
- 24小时
- 0
- 7天
- +1
- 15天
- +2
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文NestJS CLS (Async Context)
A continuation-local storage module compatible with NestJS' dependency injection based on AsyncLocalStorage.
Notice: The documentation has been moved to a dedicated website.
Continuation-local storage allows to store state and propagate it throughout callbacks and promise chains. It allows storing data throughout the lifetime of a web request or any other asynchronous duration. It is similar to thread-local storage in other languages.
Some common use cases that this library enables include:
- Tracking the Request ID and other metadata for logging purposes
- Keeping track of the user throughout the whole request
- Making the dynamic Tenant database connection available everywhere in multi-tenant apps
- Propagating the authentication level or role to restrict access to resources
- Seamlessly propagating database transaction across services without breaking encapsulation and isolation by explicitly passing it around (Now available with the Transactional plugin)
- Using "request" context in cases where actual REQUEST-scoped providers are not supported (passport strategies, cron controllers, websocket gateways, queue consumers, ...)
- Replace REQUEST-scoped providers with Proxy Providers.
Most of these are to some extent solvable using REQUEST-scoped providers or passing the context as a parameter, but these solutions are often clunky and come with a whole lot of other issues.
Documentation
➡️ Go to the documentation website 📖
Contributing
Contributing to a community project is always welcome, please see the Contributing guide :)
探索相关项目
加载中…