@tsed/terminus 7.0.0-beta.1 → 7.0.0-beta.12
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/lib/cjs/TerminusModule.js +14 -12
- package/lib/cjs/TerminusModule.js.map +1 -1
- package/lib/cjs/index.js +8 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/interfaces.js +3 -0
- package/lib/cjs/interfaces/interfaces.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/esm/TerminusModule.js +3 -1
- package/lib/esm/TerminusModule.js.map +1 -1
- package/lib/esm/index.js +8 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/interfaces.js +2 -0
- package/lib/esm/interfaces/interfaces.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/types/index.d.ts +6 -2
- package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +0 -1
- package/package.json +32 -14
- package/readme.md +28 -25
- package/tsconfig.compile.esm.json +1 -12
- package/lib/cjs/interfaces/index.js +0 -5
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/esm/interfaces/index.js +0 -2
- package/lib/esm/interfaces/index.js.map +0 -1
|
@@ -4,8 +4,8 @@ exports.TerminusModule = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const terminus_1 = require("@godaddy/terminus");
|
|
6
6
|
const di_1 = require("@tsed/di");
|
|
7
|
-
const https_1 =
|
|
8
|
-
const http_1 =
|
|
7
|
+
const https_1 = tslib_1.__importDefault(require("https"));
|
|
8
|
+
const http_1 = tslib_1.__importDefault(require("http"));
|
|
9
9
|
let TerminusModule = class TerminusModule {
|
|
10
10
|
$onInit() {
|
|
11
11
|
this.mount();
|
|
@@ -51,27 +51,29 @@ let TerminusModule = class TerminusModule {
|
|
|
51
51
|
}
|
|
52
52
|
execShutdown(name) {
|
|
53
53
|
return async () => {
|
|
54
|
-
this.getStore(name)
|
|
54
|
+
for (const func of this.getStore(name)) {
|
|
55
|
+
await func();
|
|
56
|
+
}
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
|
-
|
|
60
|
+
tslib_1.__decorate([
|
|
59
61
|
(0, di_1.Configuration)(),
|
|
60
|
-
|
|
62
|
+
tslib_1.__metadata("design:type", Object)
|
|
61
63
|
], TerminusModule.prototype, "configuration", void 0);
|
|
62
|
-
|
|
64
|
+
tslib_1.__decorate([
|
|
63
65
|
(0, di_1.Inject)(),
|
|
64
|
-
|
|
66
|
+
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
65
67
|
], TerminusModule.prototype, "injector", void 0);
|
|
66
|
-
|
|
68
|
+
tslib_1.__decorate([
|
|
67
69
|
(0, di_1.Inject)(http_1.default.Server),
|
|
68
|
-
|
|
70
|
+
tslib_1.__metadata("design:type", Object)
|
|
69
71
|
], TerminusModule.prototype, "httpServer", void 0);
|
|
70
|
-
|
|
72
|
+
tslib_1.__decorate([
|
|
71
73
|
(0, di_1.Inject)(https_1.default.Server),
|
|
72
|
-
|
|
74
|
+
tslib_1.__metadata("design:type", Object)
|
|
73
75
|
], TerminusModule.prototype, "httpsServer", void 0);
|
|
74
|
-
TerminusModule =
|
|
76
|
+
TerminusModule = tslib_1.__decorate([
|
|
75
77
|
(0, di_1.Module)()
|
|
76
78
|
], TerminusModule);
|
|
77
79
|
exports.TerminusModule = TerminusModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerminusModule.js","sourceRoot":"","sources":["../../src/TerminusModule.ts"],"names":[],"mappings":";;;;AAAA,gDAAiD;AACjD,iCAAgF;AAChF
|
|
1
|
+
{"version":3,"file":"TerminusModule.js","sourceRoot":"","sources":["../../src/TerminusModule.ts"],"names":[],"mappings":";;;;AAAA,gDAAiD;AACjD,iCAAgF;AAChF,0DAA0B;AAC1B,wDAAwB;AAGxB,IAAa,cAAc,GAA3B,MAAa,cAAc;IAalB,OAAO;QACZ,IAAI,CAAC,KAA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M,OAAO,GAAsC,EAAE,CAAC;QAEtD,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACjD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC3D,OAAO,CAAC,GAAG,QAAQ,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;YAC5E,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,OAAO,KAAK,IAAI,EAAE;YAChB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACtC,MAAM,IAAI,EAAE,CAAC;aACd;QACH,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AArEC;IADC,IAAA,kBAAa,GAAE;;qDACqB;AAGrC;IADC,IAAA,WAAM,GAAE;sCACS,oBAAe;gDAAC;AAGlC;IADC,IAAA,WAAM,EAAC,cAAI,CAAC,MAAM,CAAC;;kDACmB;AAGvC;IADC,IAAA,WAAM,EAAC,eAAK,CAAC,MAAM,CAAC;;mDACoB;AAX9B,cAAc;IAD1B,IAAA,WAAM,GAAE;GACI,cAAc,CAuE1B;AAvEY,wCAAc","sourcesContent":["import {createTerminus} from \"@godaddy/terminus\";\nimport {Configuration, Inject, InjectorService, Module, OnInit} from \"@tsed/di\";\nimport Https from \"https\";\nimport Http from \"http\";\n\n@Module()\nexport class TerminusModule implements OnInit {\n @Configuration()\n private configuration: Configuration;\n\n @Inject()\n private injector: InjectorService;\n\n @Inject(Http.Server)\n private httpServer: Http.Server | null;\n\n @Inject(Https.Server)\n private httpsServer: Https.Server | null;\n\n public $onInit() {\n this.mount();\n }\n\n private mount() {\n const {terminus} = this.configuration;\n const terminusConfig = {\n logger: this.injector.logger as any,\n healthChecks: this.getHealths(),\n onSignal: this.execShutdown(\"onSignal\"),\n onShutdown: this.execShutdown(\"onShutdown\"),\n beforeShutdown: this.execShutdown(\"beforeShutdown\"),\n onSendFailureDuringShutdown: this.execShutdown(\"onSendFailureDuringShutdown\"),\n ...terminus\n };\n\n if (this.httpServer) {\n createTerminus(this.httpServer, terminusConfig);\n }\n\n if (this.httpsServer) {\n createTerminus(this.httpsServer, terminusConfig);\n }\n }\n\n private getProviders(name: string) {\n return this.injector.getProviders().filter((provider) => {\n return provider.store.get(name);\n });\n }\n\n private getStore(name: string) {\n return this.injector\n .getProviders()\n .map((provider) => provider.store.get(name))\n .filter((x) => !!x)\n .flat();\n }\n\n private getHealths() {\n const healths: {[k: string]: () => Promise<any>} = {};\n\n this.getProviders(\"terminus\").forEach((provider) => {\n Object.keys(provider.store.get(\"terminus\")).forEach((name) => {\n healths[`${provider.path}${name}`] = provider.store.get(\"terminus\")[name];\n });\n });\n\n return healths;\n }\n\n private execShutdown(name: string) {\n return async () => {\n for (const func of this.getStore(name)) {\n await func();\n }\n };\n }\n}\n"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Automatically generated by barrelsby.
|
|
4
|
+
*/
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
tslib_1.__exportStar(require("./TerminusModule"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./decorators/health"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./decorators/shutdown"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./interfaces/TerminusSettings"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./interfaces/interfaces"), exports);
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2DAAiC;AACjC,8DAAoC;AACpC,gEAAsC;AACtC,wEAA8C;AAC9C,kEAAwC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./TerminusModule\";\nexport * from \"./decorators/health\";\nexport * from \"./decorators/shutdown\";\nexport * from \"./interfaces/TerminusSettings\";\nexport * from \"./interfaces/interfaces\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {TerminusSettings} from \"./TerminusSettings\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n terminus: TerminusSettings;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerminusModule.js","sourceRoot":"","sources":["../../src/TerminusModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,aAAa,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAS,MAAM,UAAU,CAAC;AAChF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,IAAa,cAAc,GAA3B,MAAa,cAAc;IAalB,OAAO;QACZ,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAEO,KAAK;QACX,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC,aAAa,CAAC;QACtC,MAAM,cAAc,GAAG;YACrB,MAAM,EAAE,I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C/B,OAAO,KAAK,IAAI,EAAE;YAChB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACtC,MAAM,IAAI,EAAE,CAAC;aACd;QACH,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AArEC;IADC,aAAa,EAAE;;qDACqB;AAGrC;IADC,MAAM,EAAE;8BACS,eAAe;gDAAC;AAGlC;IADC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;;kDACmB;AAGvC;IADC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;;mDACoB;AAX9B,cAAc;IAD1B,MAAM,EAAE;GACI,cAAc,CAuE1B;SAvEY,cAAc","sourcesContent":["import {createTerminus} from \"@godaddy/terminus\";\nimport {Configuration, Inject, InjectorService, Module, OnInit} from \"@tsed/di\";\nimport Https from \"https\";\nimport Http from \"http\";\n\n@Module()\nexport class TerminusModule implements OnInit {\n @Configuration()\n private configuration: Configuration;\n\n @Inject()\n private injector: InjectorService;\n\n @Inject(Http.Server)\n private httpServer: Http.Server | null;\n\n @Inject(Https.Server)\n private httpsServer: Https.Server | null;\n\n public $onInit() {\n this.mount();\n }\n\n private mount() {\n const {terminus} = this.configuration;\n const terminusConfig = {\n logger: this.injector.logger as any,\n healthChecks: this.getHealths(),\n onSignal: this.execShutdown(\"onSignal\"),\n onShutdown: this.execShutdown(\"onShutdown\"),\n beforeShutdown: this.execShutdown(\"beforeShutdown\"),\n onSendFailureDuringShutdown: this.execShutdown(\"onSendFailureDuringShutdown\"),\n ...terminus\n };\n\n if (this.httpServer) {\n createTerminus(this.httpServer, terminusConfig);\n }\n\n if (this.httpsServer) {\n createTerminus(this.httpsServer, terminusConfig);\n }\n }\n\n private getProviders(name: string) {\n return this.injector.getProviders().filter((provider) => {\n return provider.store.get(name);\n });\n }\n\n private getStore(name: string) {\n return this.injector\n .getProviders()\n .map((provider) => provider.store.get(name))\n .filter((x) => !!x)\n .flat();\n }\n\n private getHealths() {\n const healths: {[k: string]: () => Promise<any>} = {};\n\n this.getProviders(\"terminus\").forEach((provider) => {\n Object.keys(provider.store.get(\"terminus\")).forEach((name) => {\n healths[`${provider.path}${name}`] = provider.store.get(\"terminus\")[name];\n });\n });\n\n return healths;\n }\n\n private execShutdown(name: string) {\n return async () => {\n for (const func of this.getStore(name)) {\n await func();\n }\n };\n }\n}\n"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export * from "./TerminusModule";
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./TerminusModule.js";
|
|
5
|
+
export * from "./decorators/health.js";
|
|
6
|
+
export * from "./decorators/shutdown.js";
|
|
7
|
+
export * from "./interfaces/TerminusSettings.js";
|
|
8
|
+
export * from "./interfaces/interfaces.js";
|
|
5
9
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./TerminusModule\";\nexport * from \"./decorators/health\";\nexport * from \"./decorators/shutdown\";\nexport * from \"./interfaces/TerminusSettings\";\nexport * from \"./interfaces/interfaces\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {TerminusSettings} from \"./TerminusSettings\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n terminus: TerminusSettings;\n }\n }\n}\n"]}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./TerminusModule";
|
|
1
5
|
export * from "./decorators/health";
|
|
2
6
|
export * from "./decorators/shutdown";
|
|
3
|
-
export * from "./interfaces";
|
|
4
|
-
export * from "./
|
|
7
|
+
export * from "./interfaces/TerminusSettings";
|
|
8
|
+
export * from "./interfaces/interfaces";
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/terminus",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.12",
|
|
4
4
|
"description": "Adds graceful shutdown and Kubernetes readiness / liveness checks for any HTTP applications.",
|
|
5
5
|
"author": "Romain Lenzotti",
|
|
6
6
|
"private": false,
|
|
7
7
|
"source": "./src/index.ts",
|
|
8
8
|
"main": "./lib/cjs/index.js",
|
|
9
|
+
"module": "./lib/esm/index.js",
|
|
9
10
|
"typings": "./lib/types/index.d.ts",
|
|
10
11
|
"exports": {
|
|
11
12
|
"types": "./lib/types/index.d.ts",
|
|
@@ -14,31 +15,48 @@
|
|
|
14
15
|
"default": "./lib/esm/index.js"
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
|
-
"build": "yarn run build:esm && yarn run build:cjs",
|
|
18
|
+
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
18
19
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
19
20
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
21
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
20
22
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts"
|
|
21
23
|
},
|
|
22
24
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"tslib": "2.2.0"
|
|
25
|
+
"tslib": "2.3.1"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@tsed/
|
|
29
|
-
"@tsed/
|
|
30
|
-
"@tsed/schema": "7.0.0-beta.
|
|
28
|
+
"@godaddy/terminus": "^4.7.1",
|
|
29
|
+
"@tsed/core": "7.0.0-beta.12",
|
|
30
|
+
"@tsed/di": "7.0.0-beta.12",
|
|
31
|
+
"@tsed/schema": "7.0.0-beta.12"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@tsed/
|
|
35
|
-
"@tsed/
|
|
36
|
-
"@tsed/schema": "^7.0.0-beta.
|
|
34
|
+
"@godaddy/terminus": "^4.7.1",
|
|
35
|
+
"@tsed/core": "^7.0.0-beta.12",
|
|
36
|
+
"@tsed/di": "^7.0.0-beta.12",
|
|
37
|
+
"@tsed/schema": "^7.0.0-beta.12"
|
|
38
|
+
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"@godaddy/terminus": {
|
|
41
|
+
"optional": false
|
|
42
|
+
},
|
|
43
|
+
"@tsed/core": {
|
|
44
|
+
"optional": false
|
|
45
|
+
},
|
|
46
|
+
"@tsed/di": {
|
|
47
|
+
"optional": false
|
|
48
|
+
},
|
|
49
|
+
"@tsed/schema": {
|
|
50
|
+
"optional": false
|
|
51
|
+
}
|
|
37
52
|
},
|
|
38
53
|
"repository": "https://github.com/tsedio/tsed",
|
|
39
54
|
"bugs": {
|
|
40
55
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
41
56
|
},
|
|
42
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
43
|
-
"license": "MIT"
|
|
57
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/third-parties/terminus",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"tag": "beta"
|
|
61
|
+
}
|
|
44
62
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -43,10 +44,8 @@ Then import `@tsed/terminus` and add the following configuration in your `Server
|
|
|
43
44
|
import {Configuration} from "@tsed/common";
|
|
44
45
|
import "@tsed/terminus"; // import terminus Ts.ED module
|
|
45
46
|
import {resolve} from "path";
|
|
46
|
-
const rootDir = resolve(__dirname);
|
|
47
47
|
|
|
48
48
|
@Configuration({
|
|
49
|
-
rootDir,
|
|
50
49
|
terminus: {
|
|
51
50
|
// ... see Terminus configuration options on https://github.com/godaddy/terminus
|
|
52
51
|
}
|
|
@@ -59,27 +58,28 @@ export class Server {}
|
|
|
59
58
|
`terminus` configuration options waiting the same option description in the official Terminus documentation [here](https://github.com/godaddy/terminus).
|
|
60
59
|
The following the options are managed by the `@tsed/terminus` package:
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
- healthChecks
|
|
62
|
+
- onSignal
|
|
63
|
+
- onSendFailureDuringShutdown
|
|
64
|
+
- onShutdown
|
|
65
|
+
- beforeShutdown
|
|
66
|
+
- onSigterm
|
|
68
67
|
|
|
69
68
|
```typescript
|
|
70
69
|
export type TerminusSettings = Omit<
|
|
71
|
-
TerminusOptions,
|
|
72
|
-
"healthChecks" | "onSignal" | "onSendFailureDuringShutdown" | "onShutdown" | "beforeShutdown" | "onSigterm"
|
|
70
|
+
TerminusOptions,
|
|
71
|
+
"healthChecks" | "onSignal" | "onSendFailureDuringShutdown" | "onShutdown" | "beforeShutdown" | "onSigterm"
|
|
73
72
|
>;
|
|
74
73
|
```
|
|
75
74
|
|
|
76
75
|
## Usage
|
|
76
|
+
|
|
77
77
|
### Readiness / liveness checks
|
|
78
78
|
|
|
79
79
|
To create a readiness / liveness checks use the `@Health` decorator.
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
|
-
import {
|
|
82
|
+
import {Health} from "@tsed/terminus";
|
|
83
83
|
|
|
84
84
|
@Controller("/mongo")
|
|
85
85
|
class MongoCtrl {
|
|
@@ -91,27 +91,29 @@ class MongoCtrl {
|
|
|
91
91
|
}
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
You can also create an
|
|
94
|
+
You can also create an `HealthCheckError` when an error appear during your check.
|
|
95
95
|
|
|
96
96
|
```ts
|
|
97
|
-
import {
|
|
98
|
-
import {
|
|
97
|
+
import {Health} from "@tsed/terminus";
|
|
98
|
+
import {HealthCheckError} from "@godaddy/terminus";
|
|
99
99
|
|
|
100
100
|
@Controller("/redis")
|
|
101
101
|
class Redis {
|
|
102
102
|
@Health("/health")
|
|
103
103
|
health() {
|
|
104
104
|
// Here check the redis health
|
|
105
|
-
return Promise.reject(
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
return Promise.reject(
|
|
106
|
+
new HealthCheckError("failed", {
|
|
107
|
+
redis: "down"
|
|
108
|
+
})
|
|
109
|
+
);
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
```
|
|
111
113
|
|
|
112
114
|
### Graceful shutdown
|
|
113
115
|
|
|
114
|
-
`@tsed/terminus` package give some decorators to handle Terminus hooks. These hooks allow you to adds graceful shutdown.
|
|
116
|
+
`@tsed/terminus` package give some decorators to handle Terminus hooks. These hooks allow you to adds graceful shutdown.
|
|
115
117
|
Here is the list of decorators:
|
|
116
118
|
|
|
117
119
|
- `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 +122,36 @@ Here is the list of decorators:
|
|
|
120
122
|
- `OnSendFailureDuringShutdown`: called before sending each 503 during shutdowns.
|
|
121
123
|
|
|
122
124
|
**Example:**
|
|
125
|
+
|
|
123
126
|
```typescript
|
|
124
|
-
import {
|
|
127
|
+
import {BeforeShutdown, OnSendFailureDuringShutdown, OnShutdown, OnSignal} from "@tsed/terminus";
|
|
125
128
|
|
|
126
129
|
@Controller("/redis")
|
|
127
130
|
class RedisCtrl {
|
|
128
131
|
@BeforeShutdown()
|
|
129
132
|
beforeShutdow() {
|
|
130
|
-
console.log(
|
|
133
|
+
console.log("called before shutdown");
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
@OnSignal()
|
|
134
137
|
OnSignal() {
|
|
135
|
-
console.log(
|
|
138
|
+
console.log("called on signal");
|
|
136
139
|
}
|
|
137
140
|
|
|
138
141
|
@OnShutdown()
|
|
139
142
|
OnShutdown() {
|
|
140
|
-
console.log(
|
|
143
|
+
console.log("called on shutdown");
|
|
141
144
|
}
|
|
142
145
|
|
|
143
146
|
@OnSendFailureDuringShutdown()
|
|
144
147
|
OnSendFailureDuringShutdown() {
|
|
145
|
-
console.log(
|
|
148
|
+
console.log("on send failure during shutdown");
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
151
|
```
|
|
149
152
|
|
|
150
153
|
## Contributors
|
|
154
|
+
|
|
151
155
|
Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html).
|
|
152
156
|
|
|
153
157
|
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
@@ -158,7 +162,6 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com
|
|
|
158
162
|
|
|
159
163
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
|
|
160
164
|
|
|
161
|
-
|
|
162
165
|
## Sponsors
|
|
163
166
|
|
|
164
167
|
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
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAUA,kEAAmC","sourcesContent":["import {TerminusSettings} from \"./TerminusSettings\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n terminus: TerminusSettings;\n }\n }\n}\n\nexport * from \"./TerminusSettings\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAUA,cAAc,oBAAoB,CAAC","sourcesContent":["import {TerminusSettings} from \"./TerminusSettings\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n terminus: TerminusSettings;\n }\n }\n}\n\nexport * from \"./TerminusSettings\";\n"]}
|