Skip to content

Commit 3e1553b

Browse files
committed
docs(recipes): Address PR comments
1 parent 11683a5 commit 3e1553b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

content/recipes/async-local-storage.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ In the context of NestJS, that means if we can find a place within the request's
1010

1111
NestJS itself does not provide any built-in abstraction for `AsyncLocalStorage`, so let's walk through how we could implement it ourselves for the simplest HTTP case to get a better understanding of the whole concept:
1212

13-
> info **info** For a ready-made [dedicated package](#nestjs-cls), continue reading below.
13+
> info **info** For a ready-made [dedicated package](recipes/async-local-storage#nestjs-cls), continue reading below.
1414
1515
1. First, create a new instance of the `AsyncLocalStorage` in some shared source file. Since we're using NestJS, let's also turn it into a module with a custom provider.
1616

@@ -158,16 +158,13 @@ export class CatService {
158158
}
159159
```
160160

161-
3. To get strong typing of the store values managed by the `ClsService`, we can use an optional type parameter (`ClsService<MyStoreType>`), or use application-wide typescript module augmentation.
161+
3. To get strong typing of the store values managed by the `ClsService` (and also get auto-suggestions of the string keys), we can use an optional type parameter `ClsService<MyClsStore>` when injecting it.
162162

163163
```ts
164-
declare module `nestjs-cls` {
165-
interface ClsStore {
166-
userId: number
167-
}
164+
export interface MyClsStore extends ClsStore {
165+
userId: number
168166
}
169167
```
170-
171168
#### Testing
172169

173170
Since the `ClsService` is just another injectable provider, it can be entirely mocked out in unit tests.

0 commit comments

Comments
 (0)