Skip to content

Commit 32868dc

Browse files
authored
docs: better titles for discovery service
1 parent ce7507b commit 32868dc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

content/fundamentals/discovery-service.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
The `DiscoveryService` is a utility provided by `@nestjs/core` that allows developers to dynamically discover providers, controllers, and other metadata within a NestJS application. This can be particularly useful for building plugins, decorators, or features that rely on runtime introspection.
44

5-
## Installation
5+
### Installation
66

77
`DiscoveryService` is part of `@nestjs/core`, so it does not require separate installation. You can use it directly within your NestJS application.
88

9-
## Importing DiscoveryService and DiscoveryModule
9+
### Importing DiscoveryService and DiscoveryModule
1010

1111
Before using the `DiscoveryService`, you need to import the `DiscoveryModule` in your module:
1212

@@ -43,9 +43,9 @@ export class ExampleService {
4343

4444
> info **Hint** The `DiscoveryService` class is imported from the `@nestjs/core` package.
4545
46-
## Use Cases
46+
### Use Cases
4747

48-
### 1. Discovering Providers
48+
#### 1. Discovering Providers
4949

5050
You can retrieve all registered providers in the application:
5151

@@ -56,7 +56,7 @@ console.log(providers);
5656

5757
Each provider object contains information about the instance, token, and metadata.
5858

59-
### 2. Discovering Controllers
59+
#### 2. Discovering Controllers
6060

6161
Retrieve all registered controllers:
6262

@@ -65,7 +65,7 @@ const controllers = this.discoveryService.getControllers();
6565
console.log(controllers);
6666
```
6767

68-
### 3. Finding Metadata
68+
#### 3. Finding Metadata
6969

7070
`DiscoveryService` can help find metadata attached to providers or controllers. This is useful when working with decorators that add metadata.
7171

@@ -80,7 +80,7 @@ for (const provider of providers) {
8080
}
8181
```
8282

83-
## Example: Custom Decorator with DiscoveryService
83+
##### Example: Custom Decorator with DiscoveryService
8484

8585
Suppose you have a custom decorator that adds metadata to a provider:
8686

@@ -114,6 +114,6 @@ const filteredProviders = providers.filter((provider) => {
114114
console.log('Providers with custom metadata:', filteredProviders);
115115
```
116116

117-
## Conclusion
117+
### Conclusion
118118

119119
`DiscoveryService` is a powerful tool for runtime introspection in NestJS applications. It allows you to discover providers, controllers, and metadata dynamically, making it useful for plugin development, custom decorators, and advanced framework-level features.

0 commit comments

Comments
 (0)