Skip to content

Commit bbd24d8

Browse files
Papoochmicalevisk
andcommitted
docs(recipes): Use filename pipe
Co-authored-by: Micael Levi L. Cavalcante <[email protected]>
1 parent e4585e9 commit bbd24d8

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

content/recipes/async-local-storage.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ NestJS itself does not provide any built-in abstraction for `AsyncLocalStorage`,
1717
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.
1818

1919
```ts
20-
/** als.module.ts */
21-
20+
@@filename(als.module)
2221
@Module({
2322
providers: [
2423
{
@@ -35,8 +34,7 @@ export class AlsModule {}
3534
2. We're only concerned with HTTP, so let's use a middleware to wrap the `next` function with `AsyncLocalStorage#run`. Since a middleware is the first thing that the request hits, this will make the `store` available in all enhancers and the rest of the system.
3635

3736
```ts
38-
/** app.module.ts */
39-
37+
@@filename(app.module)
4038
@Module({
4139
imports: [AlsModule]
4240
providers: [CatService],
@@ -70,8 +68,7 @@ export class AppModule implements NestModule {
7068
3. Now, anywhere within the lifecycle of a request, we can access the local store instance.
7169

7270
```ts
73-
/** cat.service.ts */
74-
71+
@@filename(cat.service)
7572
export class CatService {
7673
constructor(
7774
// We can inject the provided ALS instance.
@@ -115,8 +112,7 @@ A similar functionality as described [above](#custom-implementation) can be impl
115112
1. Import the `ClsModule` in the root module.
116113

117114
```ts
118-
/** app.module.ts */
119-
115+
@@filename(app.module)
120116
@Module({
121117
imports: [
122118
// Register the ClsModule,
@@ -142,8 +138,7 @@ export class AppModule {}
142138
2. And then can use the `ClsService` to access the store values.
143139

144140
```ts
145-
/** cat.service.ts */
146-
141+
@@filename(cat.service)
147142
export class CatService {
148143
constructor(
149144
// We can inject the provided ClsService instance,

src/app/homepage/pages/recipes/recipes.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const routes: Routes = [
124124
RouterModuleComponent,
125125
ServeStaticComponent,
126126
NestCommanderComponent,
127+
AsyncLocalStorageComponent,
127128
ReplComponent,
128129
],
129130
})

0 commit comments

Comments
 (0)