@tsed/terminus 7.0.0-alpha.1 → 7.0.0-beta.3

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.
Files changed (36) hide show
  1. package/lib/cjs/TerminusModule.js +78 -0
  2. package/lib/cjs/TerminusModule.js.map +1 -0
  3. package/lib/cjs/decorators/health.js +34 -0
  4. package/lib/cjs/decorators/health.js.map +1 -0
  5. package/lib/cjs/decorators/shutdown.js +54 -0
  6. package/lib/cjs/decorators/shutdown.js.map +1 -0
  7. package/lib/cjs/index.js +8 -0
  8. package/lib/cjs/index.js.map +1 -0
  9. package/lib/cjs/interfaces/TerminusSettings.js +3 -0
  10. package/lib/cjs/interfaces/TerminusSettings.js.map +1 -0
  11. package/lib/cjs/interfaces/index.js +5 -0
  12. package/lib/cjs/interfaces/index.js.map +1 -0
  13. package/lib/esm/TerminusModule.js +75 -0
  14. package/lib/esm/TerminusModule.js.map +1 -0
  15. package/lib/esm/decorators/health.js +30 -0
  16. package/lib/esm/decorators/health.js.map +1 -0
  17. package/lib/esm/decorators/shutdown.js +47 -0
  18. package/lib/esm/decorators/shutdown.js.map +1 -0
  19. package/lib/esm/index.js +5 -0
  20. package/lib/esm/index.js.map +1 -0
  21. package/lib/esm/interfaces/TerminusSettings.js +2 -0
  22. package/lib/esm/interfaces/TerminusSettings.js.map +1 -0
  23. package/lib/esm/interfaces/index.js +2 -0
  24. package/lib/esm/interfaces/index.js.map +1 -0
  25. package/lib/{TerminusModule.d.ts → types/TerminusModule.d.ts} +1 -1
  26. package/lib/{decorators → types/decorators}/health.d.ts +0 -0
  27. package/lib/{decorators → types/decorators}/shutdown.d.ts +0 -0
  28. package/lib/{index.d.ts → types/index.d.ts} +0 -0
  29. package/lib/{interfaces → types/interfaces}/TerminusSettings.d.ts +0 -0
  30. package/lib/{interfaces → types/interfaces}/index.d.ts +0 -0
  31. package/package.json +19 -17
  32. package/tsconfig.compile.esm.json +23 -0
  33. package/lib/index.js +0 -176
  34. package/lib/index.js.map +0 -1
  35. package/lib/index.modern.js +0 -174
  36. package/lib/index.modern.js.map +0 -1
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TerminusModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const terminus_1 = require("@godaddy/terminus");
6
+ const di_1 = require("@tsed/di");
7
+ const https_1 = (0, tslib_1.__importDefault)(require("https"));
8
+ const http_1 = (0, tslib_1.__importDefault)(require("http"));
9
+ let TerminusModule = class TerminusModule {
10
+ $onInit() {
11
+ this.mount();
12
+ }
13
+ mount() {
14
+ const { terminus } = this.configuration;
15
+ const terminusConfig = {
16
+ logger: this.injector.logger,
17
+ healthChecks: this.getHealths(),
18
+ onSignal: this.execShutdown("onSignal"),
19
+ onShutdown: this.execShutdown("onShutdown"),
20
+ beforeShutdown: this.execShutdown("beforeShutdown"),
21
+ onSendFailureDuringShutdown: this.execShutdown("onSendFailureDuringShutdown"),
22
+ ...terminus
23
+ };
24
+ if (this.httpServer) {
25
+ (0, terminus_1.createTerminus)(this.httpServer, terminusConfig);
26
+ }
27
+ if (this.httpsServer) {
28
+ (0, terminus_1.createTerminus)(this.httpsServer, terminusConfig);
29
+ }
30
+ }
31
+ getProviders(name) {
32
+ return this.injector.getProviders().filter((provider) => {
33
+ return provider.store.get(name);
34
+ });
35
+ }
36
+ getStore(name) {
37
+ return this.injector
38
+ .getProviders()
39
+ .map((provider) => provider.store.get(name))
40
+ .filter((x) => !!x)
41
+ .flat();
42
+ }
43
+ getHealths() {
44
+ const healths = {};
45
+ this.getProviders("terminus").forEach((provider) => {
46
+ Object.keys(provider.store.get("terminus")).forEach((name) => {
47
+ healths[`${provider.path}${name}`] = provider.store.get("terminus")[name];
48
+ });
49
+ });
50
+ return healths;
51
+ }
52
+ execShutdown(name) {
53
+ return async () => {
54
+ this.getStore(name).forEach((func) => func());
55
+ };
56
+ }
57
+ };
58
+ (0, tslib_1.__decorate)([
59
+ (0, di_1.Configuration)(),
60
+ (0, tslib_1.__metadata)("design:type", Object)
61
+ ], TerminusModule.prototype, "configuration", void 0);
62
+ (0, tslib_1.__decorate)([
63
+ (0, di_1.Inject)(),
64
+ (0, tslib_1.__metadata)("design:type", di_1.InjectorService)
65
+ ], TerminusModule.prototype, "injector", void 0);
66
+ (0, tslib_1.__decorate)([
67
+ (0, di_1.Inject)(http_1.default.Server),
68
+ (0, tslib_1.__metadata)("design:type", Object)
69
+ ], TerminusModule.prototype, "httpServer", void 0);
70
+ (0, tslib_1.__decorate)([
71
+ (0, di_1.Inject)(https_1.default.Server),
72
+ (0, tslib_1.__metadata)("design:type", Object)
73
+ ], TerminusModule.prototype, "httpsServer", void 0);
74
+ TerminusModule = (0, tslib_1.__decorate)([
75
+ (0, di_1.Module)()
76
+ ], TerminusModule);
77
+ exports.TerminusModule = TerminusModule;
78
+ //# sourceMappingURL=TerminusModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerminusModule.js","sourceRoot":"","sources":["../../src/TerminusModule.ts"],"names":[],"mappings":";;;;AAAA,gDAAiD;AACjD,iCAAgF;AAChF,+DAA0B;AAC1B,6DAAwB;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,IAAI,CAAC,QAAQ,CAAC,MAAa;YACnC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;YACvC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;YAC3C,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC;YACnD,2BAA2B,EAAE,IAAI,CAAC,YAAY,CAAC,6BAA6B,C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AC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,OAAO,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAnEC;IADC,IAAA,kBAAa,GAAE;;qDACqB;AAGrC;IADC,IAAA,WAAM,GAAE;2CACS,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,CAqE1B;AArEY,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 this.getStore(name).forEach((func) => func());\n };\n }\n}\n"]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Health = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ /**
6
+ * Create a readiness / liveness checks.
7
+ *
8
+ * ```ts
9
+ * import { Health } from "@tsed/terminus";
10
+ *
11
+ * @Controller("/mongo")
12
+ * class MongoCtrl {
13
+ * @Health("/health")
14
+ * health() {
15
+ * // Here check the mongo health
16
+ * return Promise.resolve();
17
+ * }
18
+ * }
19
+ *
20
+ * @param name
21
+ * @decorator
22
+ * @terminus
23
+ */
24
+ function Health(name) {
25
+ return (target, propertyKey, descriptor) => {
26
+ if (descriptor.value) {
27
+ core_1.Store.from(target).merge("terminus", {
28
+ [name]: descriptor.value
29
+ });
30
+ }
31
+ };
32
+ }
33
+ exports.Health = Health;
34
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/decorators/health.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAEjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,MAAM,CAAC,IAAY;IACjC,OAAO,CAAW,MAAc,EAAE,WAAmB,EAAE,UAA6C,EAAE,EAAE;QACtG,IAAI,UAAU,CAAC,KAAK,EAAE;YACpB,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE;gBACnC,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,KAAK;aACzB,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC;AARD,wBAQC","sourcesContent":["import {Store} from \"@tsed/core\";\n\n/**\n * Create a readiness / liveness checks.\n *\n * ```ts\n * import { Health } from \"@tsed/terminus\";\n *\n * @Controller(\"/mongo\")\n * class MongoCtrl {\n * @Health(\"/health\")\n * health() {\n * // Here check the mongo health\n * return Promise.resolve();\n * }\n * }\n *\n * @param name\n * @decorator\n * @terminus\n */\nexport function Health(name: string): MethodDecorator {\n return <Function>(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) => {\n if (descriptor.value) {\n Store.from(target).merge(\"terminus\", {\n [name]: descriptor.value\n });\n }\n };\n}\n"]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnSendFailureDuringShutdown = exports.OnShutdown = exports.OnSignal = exports.BeforeShutdown = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ function register(name) {
6
+ return (target, propertyKey, descriptor) => {
7
+ if (descriptor.value) {
8
+ const store = core_1.Store.from(target);
9
+ const values = store.get(name) || [];
10
+ store.merge(name, [...values, descriptor.value]);
11
+ }
12
+ };
13
+ }
14
+ /**
15
+ * Listen the `beforeShutdown` terminus event.
16
+ *
17
+ * @decorator
18
+ * @terminus
19
+ */
20
+ function BeforeShutdown() {
21
+ return register("beforeShutdown");
22
+ }
23
+ exports.BeforeShutdown = BeforeShutdown;
24
+ /**
25
+ * Listen the `onSignal` terminus event.
26
+ *
27
+ * @decorator
28
+ * @terminus
29
+ */
30
+ function OnSignal() {
31
+ return register("onSignal");
32
+ }
33
+ exports.OnSignal = OnSignal;
34
+ /**
35
+ * Listen the `onShutdown` terminus event.
36
+ *
37
+ * @decorator
38
+ * @terminus
39
+ */
40
+ function OnShutdown() {
41
+ return register("onShutdown");
42
+ }
43
+ exports.OnShutdown = OnShutdown;
44
+ /**
45
+ * Listen the `onSendFailureDuringShutdown` terminus event.
46
+ *
47
+ * @decorator
48
+ * @terminus
49
+ */
50
+ function OnSendFailureDuringShutdown() {
51
+ return register("onSendFailureDuringShutdown");
52
+ }
53
+ exports.OnSendFailureDuringShutdown = OnSendFailureDuringShutdown;
54
+ //# sourceMappingURL=shutdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../../src/decorators/shutdown.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAEjC,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,CAAW,MAAc,EAAE,WAAmB,EAAE,UAA6C,EAAE,EAAE;QACtG,IAAI,UAAU,CAAC,KAAK,EAAE;YACpB,MAAM,KAAK,GAAG,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAErC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc;IAC5B,OAAO,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACpC,CAAC;AAFD,wCAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ;IACtB,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAFD,4BAEC;AAED;;;;;GAKG;AACH,SAAgB,UAAU;IACxB,OAAO,QAAQ,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAFD,gCAEC;AAED;;;;;GAKG;AACH,SAAgB,2BAA2B;IACzC,OAAO,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC;AAFD,kEAEC","sourcesContent":["import {Store} from \"@tsed/core\";\n\nfunction register(name: string) {\n return <Function>(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) => {\n if (descriptor.value) {\n const store = Store.from(target);\n const values = store.get(name) || [];\n\n store.merge(name, [...values, descriptor.value]);\n }\n };\n}\n\n/**\n * Listen the `beforeShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function BeforeShutdown(): MethodDecorator {\n return register(\"beforeShutdown\");\n}\n\n/**\n * Listen the `onSignal` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnSignal(): MethodDecorator {\n return register(\"onSignal\");\n}\n\n/**\n * Listen the `onShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnShutdown(): MethodDecorator {\n return register(\"onShutdown\");\n}\n\n/**\n * Listen the `onSendFailureDuringShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnSendFailureDuringShutdown(): MethodDecorator {\n return register(\"onSendFailureDuringShutdown\");\n}\n"]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./decorators/health"), exports);
5
+ (0, tslib_1.__exportStar)(require("./decorators/shutdown"), exports);
6
+ (0, tslib_1.__exportStar)(require("./interfaces"), exports);
7
+ (0, tslib_1.__exportStar)(require("./TerminusModule"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAAoC;AACpC,qEAAsC;AACtC,4DAA6B;AAC7B,gEAAiC","sourcesContent":["export * from \"./decorators/health\";\nexport * from \"./decorators/shutdown\";\nexport * from \"./interfaces\";\nexport * from \"./TerminusModule\";\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TerminusSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerminusSettings.js","sourceRoot":"","sources":["../../../src/interfaces/TerminusSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {TerminusOptions} from \"@godaddy/terminus\";\n\nexport type TerminusSettings = Omit<\n TerminusOptions,\n \"healthChecks\" | \"onSignal\" | \"onSendFailureDuringShutdown\" | \"onShutdown\" | \"beforeShutdown\" | \"onSigterm\"\n>;\n"]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./TerminusSettings"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,75 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { createTerminus } from "@godaddy/terminus";
3
+ import { Configuration, Inject, InjectorService, Module } from "@tsed/di";
4
+ import Https from "https";
5
+ import Http from "http";
6
+ let TerminusModule = class TerminusModule {
7
+ $onInit() {
8
+ this.mount();
9
+ }
10
+ mount() {
11
+ const { terminus } = this.configuration;
12
+ const terminusConfig = {
13
+ logger: this.injector.logger,
14
+ healthChecks: this.getHealths(),
15
+ onSignal: this.execShutdown("onSignal"),
16
+ onShutdown: this.execShutdown("onShutdown"),
17
+ beforeShutdown: this.execShutdown("beforeShutdown"),
18
+ onSendFailureDuringShutdown: this.execShutdown("onSendFailureDuringShutdown"),
19
+ ...terminus
20
+ };
21
+ if (this.httpServer) {
22
+ createTerminus(this.httpServer, terminusConfig);
23
+ }
24
+ if (this.httpsServer) {
25
+ createTerminus(this.httpsServer, terminusConfig);
26
+ }
27
+ }
28
+ getProviders(name) {
29
+ return this.injector.getProviders().filter((provider) => {
30
+ return provider.store.get(name);
31
+ });
32
+ }
33
+ getStore(name) {
34
+ return this.injector
35
+ .getProviders()
36
+ .map((provider) => provider.store.get(name))
37
+ .filter((x) => !!x)
38
+ .flat();
39
+ }
40
+ getHealths() {
41
+ const healths = {};
42
+ this.getProviders("terminus").forEach((provider) => {
43
+ Object.keys(provider.store.get("terminus")).forEach((name) => {
44
+ healths[`${provider.path}${name}`] = provider.store.get("terminus")[name];
45
+ });
46
+ });
47
+ return healths;
48
+ }
49
+ execShutdown(name) {
50
+ return async () => {
51
+ this.getStore(name).forEach((func) => func());
52
+ };
53
+ }
54
+ };
55
+ __decorate([
56
+ Configuration(),
57
+ __metadata("design:type", Object)
58
+ ], TerminusModule.prototype, "configuration", void 0);
59
+ __decorate([
60
+ Inject(),
61
+ __metadata("design:type", InjectorService)
62
+ ], TerminusModule.prototype, "injector", void 0);
63
+ __decorate([
64
+ Inject(Http.Server),
65
+ __metadata("design:type", Object)
66
+ ], TerminusModule.prototype, "httpServer", void 0);
67
+ __decorate([
68
+ Inject(Https.Server),
69
+ __metadata("design:type", Object)
70
+ ], TerminusModule.prototype, "httpsServer", void 0);
71
+ TerminusModule = __decorate([
72
+ Module()
73
+ ], TerminusModule);
74
+ export { TerminusModule };
75
+ //# sourceMappingURL=TerminusModule.js.map
@@ -0,0 +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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jD,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,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAnEC;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,CAqE1B;SArEY,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 this.getStore(name).forEach((func) => func());\n };\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import { Store } from "@tsed/core";
2
+ /**
3
+ * Create a readiness / liveness checks.
4
+ *
5
+ * ```ts
6
+ * import { Health } from "@tsed/terminus";
7
+ *
8
+ * @Controller("/mongo")
9
+ * class MongoCtrl {
10
+ * @Health("/health")
11
+ * health() {
12
+ * // Here check the mongo health
13
+ * return Promise.resolve();
14
+ * }
15
+ * }
16
+ *
17
+ * @param name
18
+ * @decorator
19
+ * @terminus
20
+ */
21
+ export function Health(name) {
22
+ return (target, propertyKey, descriptor) => {
23
+ if (descriptor.value) {
24
+ Store.from(target).merge("terminus", {
25
+ [name]: descriptor.value
26
+ });
27
+ }
28
+ };
29
+ }
30
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/decorators/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,CAAW,MAAc,EAAE,WAAmB,EAAE,UAA6C,EAAE,EAAE;QACtG,IAAI,UAAU,CAAC,KAAK,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE;gBACnC,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,KAAK;aACzB,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {Store} from \"@tsed/core\";\n\n/**\n * Create a readiness / liveness checks.\n *\n * ```ts\n * import { Health } from \"@tsed/terminus\";\n *\n * @Controller(\"/mongo\")\n * class MongoCtrl {\n * @Health(\"/health\")\n * health() {\n * // Here check the mongo health\n * return Promise.resolve();\n * }\n * }\n *\n * @param name\n * @decorator\n * @terminus\n */\nexport function Health(name: string): MethodDecorator {\n return <Function>(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) => {\n if (descriptor.value) {\n Store.from(target).merge(\"terminus\", {\n [name]: descriptor.value\n });\n }\n };\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import { Store } from "@tsed/core";
2
+ function register(name) {
3
+ return (target, propertyKey, descriptor) => {
4
+ if (descriptor.value) {
5
+ const store = Store.from(target);
6
+ const values = store.get(name) || [];
7
+ store.merge(name, [...values, descriptor.value]);
8
+ }
9
+ };
10
+ }
11
+ /**
12
+ * Listen the `beforeShutdown` terminus event.
13
+ *
14
+ * @decorator
15
+ * @terminus
16
+ */
17
+ export function BeforeShutdown() {
18
+ return register("beforeShutdown");
19
+ }
20
+ /**
21
+ * Listen the `onSignal` terminus event.
22
+ *
23
+ * @decorator
24
+ * @terminus
25
+ */
26
+ export function OnSignal() {
27
+ return register("onSignal");
28
+ }
29
+ /**
30
+ * Listen the `onShutdown` terminus event.
31
+ *
32
+ * @decorator
33
+ * @terminus
34
+ */
35
+ export function OnShutdown() {
36
+ return register("onShutdown");
37
+ }
38
+ /**
39
+ * Listen the `onSendFailureDuringShutdown` terminus event.
40
+ *
41
+ * @decorator
42
+ * @terminus
43
+ */
44
+ export function OnSendFailureDuringShutdown() {
45
+ return register("onSendFailureDuringShutdown");
46
+ }
47
+ //# sourceMappingURL=shutdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../../src/decorators/shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEjC,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,CAAW,MAAc,EAAE,WAAmB,EAAE,UAA6C,EAAE,EAAE;QACtG,IAAI,UAAU,CAAC,KAAK,EAAE;YACpB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAErC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,QAAQ,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {Store} from \"@tsed/core\";\n\nfunction register(name: string) {\n return <Function>(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) => {\n if (descriptor.value) {\n const store = Store.from(target);\n const values = store.get(name) || [];\n\n store.merge(name, [...values, descriptor.value]);\n }\n };\n}\n\n/**\n * Listen the `beforeShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function BeforeShutdown(): MethodDecorator {\n return register(\"beforeShutdown\");\n}\n\n/**\n * Listen the `onSignal` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnSignal(): MethodDecorator {\n return register(\"onSignal\");\n}\n\n/**\n * Listen the `onShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnShutdown(): MethodDecorator {\n return register(\"onShutdown\");\n}\n\n/**\n * Listen the `onSendFailureDuringShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnSendFailureDuringShutdown(): MethodDecorator {\n return register(\"onSendFailureDuringShutdown\");\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from "./decorators/health";
2
+ export * from "./decorators/shutdown";
3
+ export * from "./interfaces";
4
+ export * from "./TerminusModule";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC","sourcesContent":["export * from \"./decorators/health\";\nexport * from \"./decorators/shutdown\";\nexport * from \"./interfaces\";\nexport * from \"./TerminusModule\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TerminusSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerminusSettings.js","sourceRoot":"","sources":["../../../src/interfaces/TerminusSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {TerminusOptions} from \"@godaddy/terminus\";\n\nexport type TerminusSettings = Omit<\n TerminusOptions,\n \"healthChecks\" | \"onSignal\" | \"onSendFailureDuringShutdown\" | \"onShutdown\" | \"beforeShutdown\" | \"onSigterm\"\n>;\n"]}
@@ -0,0 +1,2 @@
1
+ export * from "./TerminusSettings";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"]}
@@ -1,4 +1,4 @@
1
- import { OnInit } from "@tsed/common";
1
+ import { OnInit } from "@tsed/di";
2
2
  export declare class TerminusModule implements OnInit {
3
3
  private configuration;
4
4
  private injector;
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "@tsed/terminus",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-beta.3",
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
- "main": "./lib/index.js",
9
- "typings": "./lib/index.d.ts",
8
+ "main": "./lib/cjs/index.js",
9
+ "typings": "./lib/types/index.d.ts",
10
10
  "exports": {
11
- "require": "./lib/index.js",
12
- "default": "./lib/index.modern.js"
11
+ "types": "./lib/types/index.d.ts",
12
+ "import": "./lib/esm/index.js",
13
+ "require": "./lib/cjs/index.js",
14
+ "default": "./lib/esm/index.js"
13
15
  },
14
16
  "scripts": {
15
- "build": "microbundle --target node --no-compress --format modern,cjs --tsconfig ./tsconfig.compile.json",
17
+ "build": "yarn run build:esm && yarn run build:cjs",
18
+ "build:cjs": "tsc --build tsconfig.compile.json",
19
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
16
20
  "start": "ts-node -r tsconfig-paths/register test/app/index.ts"
17
21
  },
18
22
  "dependencies": {
@@ -20,23 +24,21 @@
20
24
  "tslib": "2.2.0"
21
25
  },
22
26
  "devDependencies": {
23
- "@tsed/common": "7.0.0-alpha.1",
24
- "@tsed/core": "7.0.0-alpha.1",
25
- "@tsed/di": "7.0.0-alpha.1",
26
- "@tsed/openspec": "7.0.0-alpha.1",
27
- "@tsed/schema": "7.0.0-alpha.1"
27
+ "@tsed/core": "7.0.0-beta.3",
28
+ "@tsed/di": "7.0.0-beta.3",
29
+ "@tsed/openspec": "7.0.0-beta.3",
30
+ "@tsed/schema": "7.0.0-beta.3"
28
31
  },
29
32
  "peerDependencies": {
30
- "@tsed/common": "^7.0.0-alpha.1",
31
- "@tsed/core": "^7.0.0-alpha.1",
32
- "@tsed/di": "^7.0.0-alpha.1",
33
- "@tsed/openspec": "^7.0.0-alpha.1",
34
- "@tsed/schema": "^7.0.0-alpha.1"
33
+ "@tsed/core": "^7.0.0-beta.3",
34
+ "@tsed/di": "^7.0.0-beta.3",
35
+ "@tsed/openspec": "^7.0.0-beta.3",
36
+ "@tsed/schema": "^7.0.0-beta.3"
35
37
  },
36
38
  "repository": "https://github.com/tsedio/tsed",
37
39
  "bugs": {
38
40
  "url": "https://github.com/tsedio/tsed/issues"
39
41
  },
40
- "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/third-parties/terminus",
42
+ "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/third-parties/terminus",
41
43
  "license": "MIT"
42
44
  }
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "./tsconfig.compile.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types"
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
+ ]
23
+ }
package/lib/index.js DELETED
@@ -1,176 +0,0 @@
1
- var core = require('@tsed/core');
2
- var tslib = require('tslib');
3
- var terminus = require('@godaddy/terminus');
4
- var common = require('@tsed/common');
5
-
6
- /**
7
- * Create a readiness / liveness checks.
8
- *
9
- * ```ts
10
- * import { Health } from "@tsed/terminus";
11
- *
12
- * @Controller("/mongo")
13
- * class MongoCtrl {
14
- * @Health("/health")
15
- * health() {
16
- * // Here check the mongo health
17
- * return Promise.resolve();
18
- * }
19
- * }
20
- *
21
- * @param name
22
- * @decorator
23
- * @terminus
24
- */
25
-
26
- function Health(name) {
27
- return (target, propertyKey, descriptor) => {
28
- if (descriptor.value) {
29
- core.Store.from(target).merge("terminus", {
30
- [name]: descriptor.value
31
- });
32
- }
33
- };
34
- }
35
-
36
- function register(name) {
37
- return (target, propertyKey, descriptor) => {
38
- if (descriptor.value) {
39
- const store = core.Store.from(target);
40
- const values = store.get(name, []);
41
- store.merge(name, [...values, descriptor.value]);
42
- }
43
- };
44
- }
45
- /**
46
- * Listen the `beforeShutdown` terminus event.
47
- *
48
- * @decorator
49
- * @terminus
50
- */
51
-
52
-
53
- function BeforeShutdown() {
54
- return register("beforeShutdown");
55
- }
56
- /**
57
- * Listen the `onSignal` terminus event.
58
- *
59
- * @decorator
60
- * @terminus
61
- */
62
-
63
- function OnSignal() {
64
- return register("onSignal");
65
- }
66
- /**
67
- * Listen the `onShutdown` terminus event.
68
- *
69
- * @decorator
70
- * @terminus
71
- */
72
-
73
- function OnShutdown() {
74
- return register("onShutdown");
75
- }
76
- /**
77
- * Listen the `onSendFailureDuringShutdown` terminus event.
78
- *
79
- * @decorator
80
- * @terminus
81
- */
82
-
83
- function OnSendFailureDuringShutdown() {
84
- return register("onSendFailureDuringShutdown");
85
- }
86
-
87
- function _extends() {
88
- _extends = Object.assign || function (target) {
89
- for (var i = 1; i < arguments.length; i++) {
90
- var source = arguments[i];
91
-
92
- for (var key in source) {
93
- if (Object.prototype.hasOwnProperty.call(source, key)) {
94
- target[key] = source[key];
95
- }
96
- }
97
- }
98
-
99
- return target;
100
- };
101
-
102
- return _extends.apply(this, arguments);
103
- }
104
-
105
- exports.TerminusModule = class TerminusModule {
106
- $onInit() {
107
- this.mount(this.httpServer, this.httpsServer);
108
- }
109
-
110
- mount(httpServer, httpsServer) {
111
- const {
112
- terminus: terminus$1
113
- } = this.configuration;
114
-
115
- const terminusConfig = _extends({
116
- logger: this.injector.logger,
117
- healthChecks: this.getHealths(),
118
- onSignal: this.execShutdown("onSignal"),
119
- onShutdown: this.execShutdown("onShutdown"),
120
- beforeShutdown: this.execShutdown("beforeShutdown"),
121
- onSendFailureDuringShutdown: this.execShutdown("onSendFailureDuringShutdown")
122
- }, terminus$1);
123
-
124
- if (httpServer) {
125
- terminus.createTerminus(httpServer, terminusConfig);
126
- }
127
-
128
- if (httpsServer) {
129
- terminus.createTerminus(httpsServer, terminusConfig);
130
- }
131
- }
132
-
133
- getProviders(name) {
134
- return this.injector.getProviders().filter(provider => {
135
- return provider.store.get(name);
136
- });
137
- }
138
-
139
- getStore(name) {
140
- return this.injector.getProviders().map(provider => provider.store.get(name)).filter(x => !!x).flat();
141
- }
142
-
143
- getHealths() {
144
- const healths = {};
145
- this.getProviders("terminus").forEach(provider => {
146
- Object.keys(provider.store.get("terminus")).forEach(name => {
147
- healths[`${provider.path}${name}`] = provider.store.get("terminus")[name];
148
- });
149
- });
150
- return healths;
151
- }
152
-
153
- execShutdown(name) {
154
- return async () => {
155
- this.getStore(name).forEach(func => func());
156
- };
157
- }
158
-
159
- };
160
-
161
- tslib.__decorate([common.Configuration(), tslib.__metadata("design:type", Object)], exports.TerminusModule.prototype, "configuration", void 0);
162
-
163
- tslib.__decorate([common.Inject(), tslib.__metadata("design:type", common.InjectorService)], exports.TerminusModule.prototype, "injector", void 0);
164
-
165
- tslib.__decorate([common.Inject(common.HttpServer), tslib.__metadata("design:type", Object)], exports.TerminusModule.prototype, "httpServer", void 0);
166
-
167
- tslib.__decorate([common.Inject(common.HttpsServer), tslib.__metadata("design:type", Object)], exports.TerminusModule.prototype, "httpsServer", void 0);
168
-
169
- exports.TerminusModule = tslib.__decorate([common.Module()], exports.TerminusModule);
170
-
171
- exports.BeforeShutdown = BeforeShutdown;
172
- exports.Health = Health;
173
- exports.OnSendFailureDuringShutdown = OnSendFailureDuringShutdown;
174
- exports.OnShutdown = OnShutdown;
175
- exports.OnSignal = OnSignal;
176
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/decorators/health.ts","../src/decorators/shutdown.ts","../src/TerminusModule.ts"],"sourcesContent":["import {Store} from \"@tsed/core\";\n\n/**\n * Create a readiness / liveness checks.\n *\n * ```ts\n * import { Health } from \"@tsed/terminus\";\n *\n * @Controller(\"/mongo\")\n * class MongoCtrl {\n * @Health(\"/health\")\n * health() {\n * // Here check the mongo health\n * return Promise.resolve();\n * }\n * }\n *\n * @param name\n * @decorator\n * @terminus\n */\nexport function Health(name: string): MethodDecorator {\n return <Function>(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) => {\n if (descriptor.value) {\n Store.from(target).merge(\"terminus\", {\n [name]: descriptor.value\n });\n }\n };\n}\n","import {Store} from \"@tsed/core\";\n\nfunction register(name: string) {\n return <Function>(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) => {\n if (descriptor.value) {\n const store = Store.from(target);\n const values = store.get(name, []);\n\n store.merge(name, [...values, descriptor.value]);\n }\n };\n}\n\n/**\n * Listen the `beforeShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function BeforeShutdown(): MethodDecorator {\n return register(\"beforeShutdown\");\n}\n\n/**\n * Listen the `onSignal` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnSignal(): MethodDecorator {\n return register(\"onSignal\");\n}\n\n/**\n * Listen the `onShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnShutdown(): MethodDecorator {\n return register(\"onShutdown\");\n}\n\n/**\n * Listen the `onSendFailureDuringShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnSendFailureDuringShutdown(): MethodDecorator {\n return register(\"onSendFailureDuringShutdown\");\n}\n","import {createTerminus} from \"@godaddy/terminus\";\nimport {Configuration, HttpServer, HttpsServer, Inject, InjectorService, Module, OnInit} from \"@tsed/common\";\n\n@Module()\nexport class TerminusModule implements OnInit {\n @Configuration()\n private configuration: Configuration;\n\n @Inject()\n private injector: InjectorService;\n\n @Inject(HttpServer)\n private httpServer: HttpServer;\n\n @Inject(HttpsServer)\n private httpsServer: HttpsServer;\n\n public $onInit() {\n this.mount(this.httpServer, this.httpsServer);\n }\n\n private mount(httpServer?: HttpServer, httpsServer?: HttpsServer) {\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 (httpServer) {\n createTerminus(httpServer, terminusConfig);\n }\n\n if (httpsServer) {\n createTerminus(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 this.getStore(name).forEach((func) => func());\n };\n }\n}\n"],"names":["Health","name","target","propertyKey","descriptor","value","Store","from","merge","register","store","values","get","BeforeShutdown","OnSignal","OnShutdown","OnSendFailureDuringShutdown","TerminusModule","$onInit","mount","httpServer","httpsServer","terminus","configuration","terminusConfig","logger","injector","healthChecks","getHealths","onSignal","execShutdown","onShutdown","beforeShutdown","onSendFailureDuringShutdown","createTerminus","getProviders","filter","provider","getStore","map","x","flat","healths","forEach","Object","keys","path","func","__decorate","Configuration","Inject","InjectorService","HttpServer","HttpsServer","Module"],"mappings":";;;;;AAEA;;;;;;;;;;;;;;;;;;;;SAmBgBA,OAAOC;AACrB,SAAO,CAAWC,MAAX,EAA2BC,WAA3B,EAAgDC,UAAhD;AACL,QAAIA,UAAU,CAACC,KAAf,EAAsB;AACpBC,MAAAA,UAAK,CAACC,IAAN,CAAWL,MAAX,EAAmBM,KAAnB,CAAyB,UAAzB,EAAqC;AACnC,SAACP,IAAD,GAAQG,UAAU,CAACC;AADgB,OAArC;AAGD;AACF,GAND;AAOD;;AC3BD,SAASI,QAAT,CAAkBR,IAAlB;AACE,SAAO,CAAWC,MAAX,EAA2BC,WAA3B,EAAgDC,UAAhD;AACL,QAAIA,UAAU,CAACC,KAAf,EAAsB;AACpB,YAAMK,KAAK,GAAGJ,UAAK,CAACC,IAAN,CAAWL,MAAX,CAAd;AACA,YAAMS,MAAM,GAAGD,KAAK,CAACE,GAAN,CAAUX,IAAV,EAAgB,EAAhB,CAAf;AAEAS,MAAAA,KAAK,CAACF,KAAN,CAAYP,IAAZ,EAAkB,CAAC,GAAGU,MAAJ,EAAYP,UAAU,CAACC,KAAvB,CAAlB;AACD;AACF,GAPD;AAQD;AAED;;;;;;;;SAMgBQ;AACd,SAAOJ,QAAQ,CAAC,gBAAD,CAAf;AACD;AAED;;;;;;;SAMgBK;AACd,SAAOL,QAAQ,CAAC,UAAD,CAAf;AACD;AAED;;;;;;;SAMgBM;AACd,SAAON,QAAQ,CAAC,YAAD,CAAf;AACD;AAED;;;;;;;SAMgBO;AACd,SAAOP,QAAQ,CAAC,6BAAD,CAAf;AACD;;;;;;;;;;;;;;;;;;;;AC/CYQ,sBAAc,GAA3B,MAAaA,cAAb;AAaSC,EAA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AEA,SAAKP,YAAL,CAAkB,UAAlB,EAA8BQ,OAA9B,CAAuCN,QAAD;AACpCO,MAAAA,MAAM,CAACC,IAAP,CAAYR,QAAQ,CAAC3B,KAAT,CAAeE,GAAf,CAAmB,UAAnB,CAAZ,EAA4C+B,OAA5C,CAAqD1C,IAAD;AAClDyC,QAAAA,OAAO,IAAIL,QAAQ,CAACS,OAAO7C,MAApB,CAAP,GAAqCoC,QAAQ,CAAC3B,KAAT,CAAeE,GAAf,CAAmB,UAAnB,EAA+BX,IAA/B,CAArC;AACD,OAFD;AAGD,KAJD;AAMA,WAAOyC,OAAP;AACD;;AAEOZ,EAAAA,YAAY,CAAC7B,IAAD;AAClB,WAAO;AACL,WAAKqC,QAAL,CAAcrC,IAAd,EAAoB0C,OAApB,CAA6BI,IAAD,IAAUA,IAAI,EAA1C;AACD,KAFD;AAGD;;;;AAlEDC,kBADCC,oBAAa,wGACd;;AAGAD,kBADCE,aAAM,oCACWC,+EAAlB;;AAGAH,kBADCE,aAAM,CAACE,iBAAD,oGACP;;AAGAJ,kBADCE,aAAM,CAACG,kBAAD,qGACP;;AAXWpC,sBAAc,qBAD1BqC,aAAM,KACMrC,uBAAA;;;;;;;;"}
@@ -1,174 +0,0 @@
1
- import { Store } from '@tsed/core';
2
- import { __decorate, __metadata } from 'tslib';
3
- import { createTerminus } from '@godaddy/terminus';
4
- import { Configuration, Inject, InjectorService, HttpServer, HttpsServer, Module } from '@tsed/common';
5
-
6
- /**
7
- * Create a readiness / liveness checks.
8
- *
9
- * ```ts
10
- * import { Health } from "@tsed/terminus";
11
- *
12
- * @Controller("/mongo")
13
- * class MongoCtrl {
14
- * @Health("/health")
15
- * health() {
16
- * // Here check the mongo health
17
- * return Promise.resolve();
18
- * }
19
- * }
20
- *
21
- * @param name
22
- * @decorator
23
- * @terminus
24
- */
25
-
26
- function Health(name) {
27
- return (target, propertyKey, descriptor) => {
28
- if (descriptor.value) {
29
- Store.from(target).merge("terminus", {
30
- [name]: descriptor.value
31
- });
32
- }
33
- };
34
- }
35
-
36
- function register(name) {
37
- return (target, propertyKey, descriptor) => {
38
- if (descriptor.value) {
39
- const store = Store.from(target);
40
- const values = store.get(name, []);
41
- store.merge(name, [...values, descriptor.value]);
42
- }
43
- };
44
- }
45
- /**
46
- * Listen the `beforeShutdown` terminus event.
47
- *
48
- * @decorator
49
- * @terminus
50
- */
51
-
52
-
53
- function BeforeShutdown() {
54
- return register("beforeShutdown");
55
- }
56
- /**
57
- * Listen the `onSignal` terminus event.
58
- *
59
- * @decorator
60
- * @terminus
61
- */
62
-
63
- function OnSignal() {
64
- return register("onSignal");
65
- }
66
- /**
67
- * Listen the `onShutdown` terminus event.
68
- *
69
- * @decorator
70
- * @terminus
71
- */
72
-
73
- function OnShutdown() {
74
- return register("onShutdown");
75
- }
76
- /**
77
- * Listen the `onSendFailureDuringShutdown` terminus event.
78
- *
79
- * @decorator
80
- * @terminus
81
- */
82
-
83
- function OnSendFailureDuringShutdown() {
84
- return register("onSendFailureDuringShutdown");
85
- }
86
-
87
- function _extends() {
88
- _extends = Object.assign || function (target) {
89
- for (var i = 1; i < arguments.length; i++) {
90
- var source = arguments[i];
91
-
92
- for (var key in source) {
93
- if (Object.prototype.hasOwnProperty.call(source, key)) {
94
- target[key] = source[key];
95
- }
96
- }
97
- }
98
-
99
- return target;
100
- };
101
-
102
- return _extends.apply(this, arguments);
103
- }
104
-
105
- let TerminusModule = class TerminusModule {
106
- $onInit() {
107
- this.mount(this.httpServer, this.httpsServer);
108
- }
109
-
110
- mount(httpServer, httpsServer) {
111
- const {
112
- terminus
113
- } = this.configuration;
114
-
115
- const terminusConfig = _extends({
116
- logger: this.injector.logger,
117
- healthChecks: this.getHealths(),
118
- onSignal: this.execShutdown("onSignal"),
119
- onShutdown: this.execShutdown("onShutdown"),
120
- beforeShutdown: this.execShutdown("beforeShutdown"),
121
- onSendFailureDuringShutdown: this.execShutdown("onSendFailureDuringShutdown")
122
- }, terminus);
123
-
124
- if (httpServer) {
125
- createTerminus(httpServer, terminusConfig);
126
- }
127
-
128
- if (httpsServer) {
129
- createTerminus(httpsServer, terminusConfig);
130
- }
131
- }
132
-
133
- getProviders(name) {
134
- return this.injector.getProviders().filter(provider => {
135
- return provider.store.get(name);
136
- });
137
- }
138
-
139
- getStore(name) {
140
- return this.injector.getProviders().map(provider => provider.store.get(name)).filter(x => !!x).flat();
141
- }
142
-
143
- getHealths() {
144
- const healths = {};
145
- this.getProviders("terminus").forEach(provider => {
146
- Object.keys(provider.store.get("terminus")).forEach(name => {
147
- healths[`${provider.path}${name}`] = provider.store.get("terminus")[name];
148
- });
149
- });
150
- return healths;
151
- }
152
-
153
- execShutdown(name) {
154
- var _this = this;
155
-
156
- return async function () {
157
- _this.getStore(name).forEach(func => func());
158
- };
159
- }
160
-
161
- };
162
-
163
- __decorate([Configuration(), __metadata("design:type", Object)], TerminusModule.prototype, "configuration", void 0);
164
-
165
- __decorate([Inject(), __metadata("design:type", InjectorService)], TerminusModule.prototype, "injector", void 0);
166
-
167
- __decorate([Inject(HttpServer), __metadata("design:type", Object)], TerminusModule.prototype, "httpServer", void 0);
168
-
169
- __decorate([Inject(HttpsServer), __metadata("design:type", Object)], TerminusModule.prototype, "httpsServer", void 0);
170
-
171
- TerminusModule = __decorate([Module()], TerminusModule);
172
-
173
- export { BeforeShutdown, Health, OnSendFailureDuringShutdown, OnShutdown, OnSignal, TerminusModule };
174
- //# sourceMappingURL=index.modern.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/decorators/health.ts","../src/decorators/shutdown.ts","../src/TerminusModule.ts"],"sourcesContent":["import {Store} from \"@tsed/core\";\n\n/**\n * Create a readiness / liveness checks.\n *\n * ```ts\n * import { Health } from \"@tsed/terminus\";\n *\n * @Controller(\"/mongo\")\n * class MongoCtrl {\n * @Health(\"/health\")\n * health() {\n * // Here check the mongo health\n * return Promise.resolve();\n * }\n * }\n *\n * @param name\n * @decorator\n * @terminus\n */\nexport function Health(name: string): MethodDecorator {\n return <Function>(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) => {\n if (descriptor.value) {\n Store.from(target).merge(\"terminus\", {\n [name]: descriptor.value\n });\n }\n };\n}\n","import {Store} from \"@tsed/core\";\n\nfunction register(name: string) {\n return <Function>(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) => {\n if (descriptor.value) {\n const store = Store.from(target);\n const values = store.get(name, []);\n\n store.merge(name, [...values, descriptor.value]);\n }\n };\n}\n\n/**\n * Listen the `beforeShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function BeforeShutdown(): MethodDecorator {\n return register(\"beforeShutdown\");\n}\n\n/**\n * Listen the `onSignal` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnSignal(): MethodDecorator {\n return register(\"onSignal\");\n}\n\n/**\n * Listen the `onShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnShutdown(): MethodDecorator {\n return register(\"onShutdown\");\n}\n\n/**\n * Listen the `onSendFailureDuringShutdown` terminus event.\n *\n * @decorator\n * @terminus\n */\nexport function OnSendFailureDuringShutdown(): MethodDecorator {\n return register(\"onSendFailureDuringShutdown\");\n}\n","import {createTerminus} from \"@godaddy/terminus\";\nimport {Configuration, HttpServer, HttpsServer, Inject, InjectorService, Module, OnInit} from \"@tsed/common\";\n\n@Module()\nexport class TerminusModule implements OnInit {\n @Configuration()\n private configuration: Configuration;\n\n @Inject()\n private injector: InjectorService;\n\n @Inject(HttpServer)\n private httpServer: HttpServer;\n\n @Inject(HttpsServer)\n private httpsServer: HttpsServer;\n\n public $onInit() {\n this.mount(this.httpServer, this.httpsServer);\n }\n\n private mount(httpServer?: HttpServer, httpsServer?: HttpsServer) {\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 (httpServer) {\n createTerminus(httpServer, terminusConfig);\n }\n\n if (httpsServer) {\n createTerminus(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 this.getStore(name).forEach((func) => func());\n };\n }\n}\n"],"names":["Health","name","target","propertyKey","descriptor","value","Store","from","merge","register","store","values","get","BeforeShutdown","OnSignal","OnShutdown","OnSendFailureDuringShutdown","TerminusModule","$onInit","mount","httpServer","httpsServer","terminus","configuration","terminusConfig","logger","injector","healthChecks","getHealths","onSignal","execShutdown","onShutdown","beforeShutdown","onSendFailureDuringShutdown","createTerminus","getProviders","filter","provider","getStore","map","x","flat","healths","forEach","Object","keys","path","func","__decorate","Configuration","Inject","InjectorService","HttpServer","HttpsServer","Module"],"mappings":";;;;;AAEA;;;;;;;;;;;;;;;;;;;;SAmBgBA,OAAOC;AACrB,SAAO,CAAWC,MAAX,EAA2BC,WAA3B,EAAgDC,UAAhD;AACL,QAAIA,UAAU,CAACC,KAAf,EAAsB;AACpBC,MAAAA,KAAK,CAACC,IAAN,CAAWL,MAAX,EAAmBM,KAAnB,CAAyB,UAAzB,EAAqC;AACnC,SAACP,IAAD,GAAQG,UAAU,CAACC;AADgB,OAArC;AAGD;AACF,GAND;AAOD;;AC3BD,SAASI,QAAT,CAAkBR,IAAlB;AACE,SAAO,CAAWC,MAAX,EAA2BC,WAA3B,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