You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/migration.md
+159-1Lines changed: 159 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,164 @@ In order to migrate your existing application, simply rename all the `type-graph
71
71
- use `Type` (imported from `@nestjs/common`) instead of `ClassType` (imported from `type-graphql`)
72
72
- move methods that require `@Args()` from object types (classes annotated with `@ObjectType()` decorator) under resolver classes (and use `@ResolveField()` decorator instead of `@Field()`)
73
73
74
+
#### Terminus
75
+
76
+
In the version 7 major release of `@nestjs/terminus`, a new simplified API has been introduced
77
+
to run health checks. The previously required peer dependency `@godaddy/terminus` has been removed, which allows us to integrate our health checks automatically into Swagger! Read more about the removal of `@godaddy/terminus`[here](https://github.com/nestjs/terminus/issues/340).
78
+
79
+
For most users, the biggest change will be the removal of the `TerminusModule.forRootAsync` function. With the next major version, this function will be completely removed.
80
+
To migrate to the new API, you will need to create a new controller, which will handle your health checks.
> warning **Warning** If you have set a [Global Prefix](faq#global-prefix) in your Nest application and you have not used the `useGlobalPrefix` Terminus option, the URL of your health check will change. Make sure to update the reference to that URL, or use the legacy Terminus API until [nestjs/nest#963](https://github.com/nestjs/nest/issues/963) is fixed.
199
+
200
+
If you are forced to use the legacy API, you can also disable deprecation messages for the time being.
201
+
202
+
```typescript
203
+
TerminusModule.forRootAsync({
204
+
useFactory: () => ({
205
+
disableDeprecationWarnings: true,
206
+
endpoints: [
207
+
// ...
208
+
]
209
+
})
210
+
}
211
+
```
212
+
213
+
You should enable shutdown hooks in your `main.ts` file. The Terminus integration will listen on POSIX signals such as SIGTERM (see the [Application shutdown chapter](fundamentals/lifecycle-events#application-shutdown) for more information). When enabled, the health check route(s) will automatically respond with a Service Unavailable (503) HTTP error response when the server is shutting down.
214
+
215
+
With the removal of `@godaddy/terminus`, you will need to update your `import` statements
216
+
to use `@nestjs/terminus` instead. Most notable is the import of the `HealthCheckError`.
Once you have fully migrated, make sure you uninstall `@godaddy/terminus`.
227
+
228
+
```bash
229
+
npmuninstall--save @godaddy/terminus
230
+
```
231
+
74
232
#### HTTP exceptions body
75
233
76
234
Previously, the generated response bodies for the `HttpException` class and other exceptions derived from it (e.g., `BadRequestException` or `NotFoundException`) were inconsistent. In the latest major release, these exception responses will follow the same structure.
@@ -127,7 +285,7 @@ If you prefer the previous approach, you can restore it by setting the `exceptio
0 commit comments