| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
doc: add partitioned and priority for cookies (#1816) sync latest cookie options | 2 年前 | |
docs: fix app.currentContext example (read the getter, don't assign to it) (#1978) The `app.currentContext` example assigns to the property: ```js function callSomeFunction () { app.currentContext = {} /* ctx of the middleware above */ } ``` But `currentContext` is a **getter-only** accessor (`lib/application.js`): ```js get currentContext () { if (this.ctxStorage) return this.ctxStorage.getStore() } ``` There is no setter, so assigning to it throws `TypeError: Cannot set property currentContext of #<Application> which has only a getter` in strict mode (which is the default for ES modules / class bodies). The assignment is also backwards from what the surrounding text describes — "this will **return** the current context for the request" — so the example should *read* the property, which is exactly what the adjacent v3.1.0 example does via `asyncLocalStorage.getStore()`. This changes the example to read the getter: ```js function callSomeFunction () { const ctx = app.currentContext /* ctx of the middleware above */ } ``` Docs only. ## Summary by Sourcery Documentation: - Update the `app.currentContext` documentation example to read from the getter instead of assigning to it. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Documentation** * Corrected example code in Koa v3 API documentation to properly demonstrate context retrieval. <!-- end of auto-generated comment: release notes by coderabbit.ai --> | 3 个月前 | |
docs++ | 1 年前 | |
docs++ | 1 年前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 年前 | ||
| 3 个月前 | ||
| 1 年前 | ||
| 1 年前 |