Skip to content

Commit bad75db

Browse files
Merge pull request #1112 from 2Kable/master
docs: add NestHybridApplicationOptions documentation
2 parents db48f27 + 8becf89 commit bad75db

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

content/faq/hybrid-application.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,14 @@ const microserviceRedis = app.connectMicroservice<MicroserviceOptions>({
3434
await app.startAllMicroservicesAsync();
3535
await app.listen(3001);
3636
```
37+
38+
#### Sharing configuration
39+
40+
By default a hybrid application will not inherit global pipes, interceptors, guards and filters configured for the main (HTTP-based) application.
41+
To inherit these configuration properties from the main application, set the `inheritAppConfig` property in the second argument (an optional options object) of the `connectMicroservice()` call, as follow:
42+
43+
```typescript
44+
const microservice = app.connectMicroservice({
45+
transport: Transport.TCP
46+
}, { inheritAppConfig: true });
47+
```

content/guards.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const app = await NestFactory.create(AppModule);
115115
app.useGlobalGuards(new RolesGuard());
116116
```
117117

118-
> warning **Notice** In the case of hybrid apps the `useGlobalGuards()` method doesn't set up guards for gateways and micro services. For "standard" (non-hybrid) microservice apps, `useGlobalGuards()` does mount the guards globally.
118+
> warning **Notice** In the case of hybrid apps the `useGlobalGuards()` method doesn't set up guards for gateways and micro services by default (see [Hybrid application](/faq/hybrid-application) for information on how to change this behavior). For "standard" (non-hybrid) microservice apps, `useGlobalGuards()` does mount the guards globally.
119119
120120
Global guards are used across the whole application, for every controller and every route handler. In terms of dependency injection, global guards registered from outside of any module (with `useGlobalGuards()` as in the example above) cannot inject dependencies since this is done outside the context of any module. In order to solve this issue, you can set up a guard directly from any module using the following construction:
121121

0 commit comments

Comments
 (0)