@tsed/terminus 6.100.3 → 6.102.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -9
- package/readme.md +26 -22
- package/tsconfig.compile.esm.json +1 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/terminus",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.102.2",
|
|
4
4
|
"description": "Adds graceful shutdown and Kubernetes readiness / liveness checks for any HTTP applications.",
|
|
5
5
|
"author": "Romain Lenzotti",
|
|
6
6
|
"private": false,
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"tslib": "2.2.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tsed/core": "6.
|
|
28
|
-
"@tsed/di": "6.
|
|
29
|
-
"@tsed/openspec": "6.
|
|
30
|
-
"@tsed/schema": "6.
|
|
27
|
+
"@tsed/core": "6.102.2",
|
|
28
|
+
"@tsed/di": "6.102.2",
|
|
29
|
+
"@tsed/openspec": "6.102.2",
|
|
30
|
+
"@tsed/schema": "6.102.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@tsed/core": "^6.
|
|
34
|
-
"@tsed/di": "^6.
|
|
35
|
-
"@tsed/openspec": "^6.
|
|
36
|
-
"@tsed/schema": "^6.
|
|
33
|
+
"@tsed/core": "^6.102.2",
|
|
34
|
+
"@tsed/di": "^6.102.2",
|
|
35
|
+
"@tsed/openspec": "^6.102.2",
|
|
36
|
+
"@tsed/schema": "^6.102.2"
|
|
37
37
|
},
|
|
38
38
|
"repository": "https://github.com/tsedio/tsed",
|
|
39
39
|
"bugs": {
|
package/readme.md
CHANGED
|
@@ -59,27 +59,28 @@ export class Server {}
|
|
|
59
59
|
`terminus` configuration options waiting the same option description in the official Terminus documentation [here](https://github.com/godaddy/terminus).
|
|
60
60
|
The following the options are managed by the `@tsed/terminus` package:
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
- healthChecks
|
|
63
|
+
- onSignal
|
|
64
|
+
- onSendFailureDuringShutdown
|
|
65
|
+
- onShutdown
|
|
66
|
+
- beforeShutdown
|
|
67
|
+
- onSigterm
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
70
|
export type TerminusSettings = Omit<
|
|
71
|
-
TerminusOptions,
|
|
72
|
-
"healthChecks" | "onSignal" | "onSendFailureDuringShutdown" | "onShutdown" | "beforeShutdown" | "onSigterm"
|
|
71
|
+
TerminusOptions,
|
|
72
|
+
"healthChecks" | "onSignal" | "onSendFailureDuringShutdown" | "onShutdown" | "beforeShutdown" | "onSigterm"
|
|
73
73
|
>;
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
## Usage
|
|
77
|
+
|
|
77
78
|
### Readiness / liveness checks
|
|
78
79
|
|
|
79
80
|
To create a readiness / liveness checks use the `@Health` decorator.
|
|
80
81
|
|
|
81
82
|
```ts
|
|
82
|
-
import {
|
|
83
|
+
import {Health} from "@tsed/terminus";
|
|
83
84
|
|
|
84
85
|
@Controller("/mongo")
|
|
85
86
|
class MongoCtrl {
|
|
@@ -91,27 +92,29 @@ class MongoCtrl {
|
|
|
91
92
|
}
|
|
92
93
|
```
|
|
93
94
|
|
|
94
|
-
You can also create an
|
|
95
|
+
You can also create an `HealthCheckError` when an error appear during your check.
|
|
95
96
|
|
|
96
97
|
```ts
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
98
|
+
import {Health} from "@tsed/terminus";
|
|
99
|
+
import {HealthCheckError} from "@godaddy/terminus";
|
|
99
100
|
|
|
100
101
|
@Controller("/redis")
|
|
101
102
|
class Redis {
|
|
102
103
|
@Health("/health")
|
|
103
104
|
health() {
|
|
104
105
|
// Here check the redis health
|
|
105
|
-
return Promise.reject(
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
return Promise.reject(
|
|
107
|
+
new HealthCheckError("failed", {
|
|
108
|
+
redis: "down"
|
|
109
|
+
})
|
|
110
|
+
);
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
```
|
|
111
114
|
|
|
112
115
|
### Graceful shutdown
|
|
113
116
|
|
|
114
|
-
`@tsed/terminus` package give some decorators to handle Terminus hooks. These hooks allow you to adds graceful shutdown.
|
|
117
|
+
`@tsed/terminus` package give some decorators to handle Terminus hooks. These hooks allow you to adds graceful shutdown.
|
|
115
118
|
Here is the list of decorators:
|
|
116
119
|
|
|
117
120
|
- `BeforeShutdown`: Use this hook if you deploy your application with Kubernetes (see more details [here](https://github.com/godaddy/terminus#how-to-set-terminus-up-with-kubernetes)),
|
|
@@ -120,34 +123,36 @@ Here is the list of decorators:
|
|
|
120
123
|
- `OnSendFailureDuringShutdown`: called before sending each 503 during shutdowns.
|
|
121
124
|
|
|
122
125
|
**Example:**
|
|
126
|
+
|
|
123
127
|
```typescript
|
|
124
|
-
import {
|
|
128
|
+
import {BeforeShutdown, OnSendFailureDuringShutdown, OnShutdown, OnSignal} from "@tsed/terminus";
|
|
125
129
|
|
|
126
130
|
@Controller("/redis")
|
|
127
131
|
class RedisCtrl {
|
|
128
132
|
@BeforeShutdown()
|
|
129
133
|
beforeShutdow() {
|
|
130
|
-
console.log(
|
|
134
|
+
console.log("called before shutdown");
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
@OnSignal()
|
|
134
138
|
OnSignal() {
|
|
135
|
-
console.log(
|
|
139
|
+
console.log("called on signal");
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
@OnShutdown()
|
|
139
143
|
OnShutdown() {
|
|
140
|
-
console.log(
|
|
144
|
+
console.log("called on shutdown");
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
@OnSendFailureDuringShutdown()
|
|
144
148
|
OnSendFailureDuringShutdown() {
|
|
145
|
-
console.log(
|
|
149
|
+
console.log("on send failure during shutdown");
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
```
|
|
149
153
|
|
|
150
154
|
## Contributors
|
|
155
|
+
|
|
151
156
|
Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html).
|
|
152
157
|
|
|
153
158
|
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
@@ -158,7 +163,6 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com
|
|
|
158
163
|
|
|
159
164
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
|
|
160
165
|
|
|
161
|
-
|
|
162
166
|
## Sponsors
|
|
163
167
|
|
|
164
168
|
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
|
|
@@ -8,16 +8,5 @@
|
|
|
8
8
|
"declaration": true,
|
|
9
9
|
"declarationDir": "./lib/types"
|
|
10
10
|
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"test",
|
|
14
|
-
"lib",
|
|
15
|
-
"benchmark",
|
|
16
|
-
"coverage",
|
|
17
|
-
"spec",
|
|
18
|
-
"**/*.benchmark.ts",
|
|
19
|
-
"**/*.spec.ts",
|
|
20
|
-
"keys",
|
|
21
|
-
"jest.config.js"
|
|
22
|
-
]
|
|
11
|
+
"exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
|
|
23
12
|
}
|