@tsed/terminus 8.37.0 → 8.38.0-beta.1

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.
@@ -1,17 +1,23 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { Constant, Inject, InjectorService, Module } from "@tsed/di";
1
+ import { constant, inject, injectable, injector, logger } from "@tsed/di";
3
2
  import Http from "node:http";
4
3
  import Https from "node:https";
5
4
  import { concatPath } from "@tsed/schema";
6
5
  import { createTerminus } from "@godaddy/terminus";
7
- let TerminusModule = class TerminusModule {
6
+ import { $asyncEmit } from "@tsed/hooks";
7
+ export class TerminusModule {
8
+ constructor() {
9
+ this.httpServer = inject(Http.Server);
10
+ this.httpsServer = inject(Https.Server);
11
+ this.settings = constant("terminus", {});
12
+ this.basePath = constant("terminus.path", "/health");
13
+ }
8
14
  $onInit() {
9
15
  this.mount();
10
16
  }
11
17
  getConfiguration() {
12
18
  const { path, ...props } = this.settings;
13
19
  return {
14
- logger: (event, error) => this.injector.logger.info({
20
+ logger: (event, error) => logger().info({
15
21
  event: event.toUpperCase(),
16
22
  error_message: error.message
17
23
  }),
@@ -51,7 +57,9 @@ let TerminusModule = class TerminusModule {
51
57
  }
52
58
  }
53
59
  getAll(name) {
54
- return this.injector.getProviders().flatMap((provider) => {
60
+ return injector()
61
+ .providers.getMany()
62
+ .flatMap((provider) => {
55
63
  const metadata = provider.store.get(`terminus:${name}`);
56
64
  if (metadata) {
57
65
  return Object.entries(metadata).map(([propertyKey, options]) => {
@@ -67,7 +75,7 @@ let TerminusModule = class TerminusModule {
67
75
  }
68
76
  getHealths() {
69
77
  const subHealths = this.getAll("health").reduce((healths, { provider, propertyKey, options: { name } }) => {
70
- const instance = this.injector.get(provider.token);
78
+ const instance = inject(provider.token);
71
79
  const callback = async (...args) => {
72
80
  const result = await instance[propertyKey](...args);
73
81
  return { [name]: result };
@@ -93,31 +101,8 @@ let TerminusModule = class TerminusModule {
93
101
  }
94
102
  createEmitter(name) {
95
103
  return (...args) => {
96
- return this.injector.emit(name, ...args);
104
+ return $asyncEmit(name, args);
97
105
  };
98
106
  }
99
- };
100
- __decorate([
101
- Constant("terminus", {}),
102
- __metadata("design:type", Object)
103
- ], TerminusModule.prototype, "settings", void 0);
104
- __decorate([
105
- Constant("terminus.path", "/health"),
106
- __metadata("design:type", String)
107
- ], TerminusModule.prototype, "basePath", void 0);
108
- __decorate([
109
- Inject(),
110
- __metadata("design:type", InjectorService)
111
- ], TerminusModule.prototype, "injector", void 0);
112
- __decorate([
113
- Inject(Http.Server),
114
- __metadata("design:type", Object)
115
- ], TerminusModule.prototype, "httpServer", void 0);
116
- __decorate([
117
- Inject(Https.Server),
118
- __metadata("design:type", Object)
119
- ], TerminusModule.prototype, "httpsServer", void 0);
120
- TerminusModule = __decorate([
121
- Module()
122
- ], TerminusModule);
123
- export { TerminusModule };
107
+ }
108
+ injectable(TerminusModule);
@@ -1,11 +1,12 @@
1
1
  import { OnInit } from "@tsed/di";
2
+ import Http from "node:http";
3
+ import Https from "node:https";
2
4
  import type { PlatformRouteDetails } from "@tsed/platform-http";
3
5
  export declare class TerminusModule implements OnInit {
6
+ protected httpServer: Http.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse> | null;
7
+ protected httpsServer: Https.Server<typeof Http.IncomingMessage, typeof Http.ServerResponse> | null;
4
8
  private settings;
5
9
  private basePath;
6
- private injector;
7
- private httpServer;
8
- private httpsServer;
9
10
  $onInit(): void;
10
11
  getConfiguration(): {
11
12
  caseInsensitive?: boolean | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/terminus",
3
- "version": "8.37.0",
3
+ "version": "8.38.0-beta.1",
4
4
  "description": "Adds graceful shutdown and Kubernetes readiness / liveness checks for any HTTP applications.",
5
5
  "author": "Romain Lenzotti",
6
6
  "source": "./src/index.ts",
@@ -29,12 +29,12 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@godaddy/terminus": "^4.12.1",
32
- "@tsed/barrels": "8.37.0",
33
- "@tsed/core": "8.37.0",
34
- "@tsed/di": "8.37.0",
35
- "@tsed/platform-http": "8.37.0",
36
- "@tsed/schema": "8.37.0",
37
- "@tsed/typescript": "8.37.0",
32
+ "@tsed/barrels": "8.38.0-beta.1",
33
+ "@tsed/core": "8.38.0-beta.1",
34
+ "@tsed/di": "8.38.0-beta.1",
35
+ "@tsed/platform-http": "8.38.0-beta.1",
36
+ "@tsed/schema": "8.38.0-beta.1",
37
+ "@tsed/typescript": "8.38.0-beta.1",
38
38
  "typescript": "6.0.2",
39
39
  "vitest": "4.1.4"
40
40
  },
@@ -64,5 +64,8 @@
64
64
  "url": "https://github.com/tsedio/tsed/issues"
65
65
  },
66
66
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/third-parties/terminus",
67
- "license": "MIT"
67
+ "license": "MIT",
68
+ "publishConfig": {
69
+ "tag": "beta"
70
+ }
68
71
  }