Skip to content

Commit e441591

Browse files
Merge pull request #2302 from nestjs/BrunnerLivio-patch-2
docs(terminus): more explicit guide for HTTPHealthIndicator
2 parents 0f44bfe + 63ace70 commit e441591

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

content/recipes/terminus.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ $ nest g controller health
5858

5959
Once we have installed `@nestjs/terminus`, imported our `TerminusModule` and created a new controller, we are ready to create a health check.
6060

61+
The `HTTPHealthIndicator` requires the `@nestjs/axios` package so make sure to have it installed:
62+
63+
```bash
64+
$ npm i --save @nestjs/axios
65+
```
66+
67+
Now we can setup our `HealthController`:
68+
6169
```typescript
6270
@@filename(health.controller)
6371
import { Controller, Get } from '@nestjs/common';
@@ -104,27 +112,27 @@ export class HealthController {
104112
@@filename(health.module)
105113
import { Module } from '@nestjs/common';
106114
import { TerminusModule } from '@nestjs/terminus';
115+
import { HttpModule } from '@nestjs/axios';
107116
import { HealthController } from './health.controller';
108117

109118
@Module({
110-
imports: [TerminusModule],
119+
imports: [TerminusModule, HttpModule],
111120
controllers: [HealthController],
112121
})
113122
export class HealthModule {}
114123
@@switch
115124
import { Module } from '@nestjs/common';
116125
import { TerminusModule } from '@nestjs/terminus';
126+
import { HttpModule } from '@nestjs/axios';
117127
import { HealthController } from './health.controller';
118128

119129
@Module({
120-
imports: [TerminusModule],
130+
imports: [TerminusModule, HttpModule],
121131
controllers: [HealthController],
122132
})
123133
export class HealthModule {}
124134
```
125135

126-
> warning **Warning** `HttpHealthIndicator` requires the installation of the `@nestjs/axios` package and the import of `HttpModule`.
127-
128136
Our health check will now send a _GET_-request to the `https://docs.nestjs.com` address. If
129137
we get a healthy response from that address, our route at `http://localhost:3000/health` will return
130138
the following object with a 200 status code.

0 commit comments

Comments
 (0)