Skip to content

Commit 0bd7775

Browse files
docs(standalone): mention features that are not compatible #3025
1 parent 8cd1ec2 commit 0bd7775

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

content/application-context.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ bootstrap();
1717

1818
#### Retrieving providers from static modules
1919

20-
The standalone application object allows you to obtain a reference to any instance registered within the Nest application. Let's imagine that we have a `TasksService` provider in the `TasksModule` module that was imported by our `AppModule` module. This class provides a set of methods that we want to call from within a CRON job.
20+
The standalone application object allows you to obtain a reference to any instance registered within the Nest application. Let's imagine that we have a `TasksService` provider in the `TasksModule` module that was imported by our `AppModule` module. This class provides a set of methods that we want to call from within a CRON job.
2121

2222
```typescript
2323
@@filename()
2424
const tasksService = app.get(TasksService);
2525
```
2626

27-
To access the `TasksService` instance we use the `get()` method. The `get()` method acts like a **query** that searches for an instance in each registered module. You can pass any provider's token to it. Alternatively, for strict context checking, pass an options object with the `strict: true` property. With this option in effect, you have to navigate through specific modules to obtain a particular instance from the selected context.
27+
To access the `TasksService` instance we use the `get()` method. The `get()` method acts like a **query** that searches for an instance in each registered module. You can pass any provider's token to it. Alternatively, for strict context checking, pass an options object with the `strict: true` property. With this option in effect, you have to navigate through specific modules to obtain a particular instance from the selected context.
2828

2929
```typescript
3030
@@filename()
@@ -54,6 +54,10 @@ Following is a summary of the methods available for retrieving instance referenc
5454

5555
> info **Hint** In non-strict mode, the root module is selected by default. To select any other module, you need to navigate the modules graph manually, step by step.
5656
57+
Keep in mind that a standalone application does not have any network listeners, so any Nest features related to HTTP (e.g., middleware, interceptors, pipes, guards, etc.) are not available in this context.
58+
59+
For example, even if you register a global interceptor in your application and then retrieve a controller's instance using the `app.get()` method, the interceptor will not be executed.
60+
5761
#### Retrieving providers from dynamic modules
5862

5963
When dealing with [dynamic modules](./fundamentals/dynamic-modules.md), we should supply the same object that represents the registered dynamic module in the application to `app.select`. For example:
@@ -75,7 +79,6 @@ Then you can select that module later on:
7579
const configService = app.select(dynamicConfigModule).get(ConfigService, { strict: true });
7680
```
7781

78-
7982
#### Terminating phase
8083

8184
If you want the Node application to close after the script finishes (e.g., for a script running CRON jobs), you must call the `app.close()` method in the end of your `bootstrap` function like this:

0 commit comments

Comments
 (0)