@haku-sci/utils 2.3.6 → 2.4.0
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/dist/microservice/microservice.service.d.ts +1 -1
- package/dist/microservice/microservice.service.js +7 -4
- package/dist/microservice/microservice.service.js.map +1 -1
- package/dist/minimal-app/http-health.module.d.ts +2 -0
- package/dist/minimal-app/http-health.module.js +45 -0
- package/dist/minimal-app/http-health.module.js.map +1 -0
- package/package.json +1 -1
|
@@ -5,6 +5,6 @@ export declare class Microservice {
|
|
|
5
5
|
static bootstrapMicroservice(appModule: any): Promise<void>;
|
|
6
6
|
private static isPortFree;
|
|
7
7
|
private static setServerAddress;
|
|
8
|
-
private static
|
|
8
|
+
private static startTCPMicroService;
|
|
9
9
|
static get host(): string;
|
|
10
10
|
}
|
|
@@ -10,6 +10,7 @@ const exceptionFilter_1 = require("./exceptionFilter");
|
|
|
10
10
|
const os = require("os");
|
|
11
11
|
const consul_1 = require("./consul");
|
|
12
12
|
const tcp_service_1 = require("../TCP/tcp.service");
|
|
13
|
+
const http_health_module_1 = require("../minimal-app/http-health.module");
|
|
13
14
|
class Microservice {
|
|
14
15
|
static async bootstrapMicroservice(appModule) {
|
|
15
16
|
this.logger = new common_1.Logger(await utils.microServiceName());
|
|
@@ -18,7 +19,9 @@ class Microservice {
|
|
|
18
19
|
const postGresService = require('./postgres.service');
|
|
19
20
|
postGresService.createDatabaseIfNotExists();
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
if (process.env.CLOUD_PORT)
|
|
23
|
+
await (await core_1.NestFactory.create(http_health_module_1.HttpHealthAppModule)).listen(process.env.CLOUD_PORT, '0.0.0.0');
|
|
24
|
+
const app = await this.startTCPMicroService(appModule);
|
|
22
25
|
await tcp_service_1.TCPService.registerHakuSciMessageHandlers(app, this.logger);
|
|
23
26
|
consul_1.Consul.registerService(this.serverAddress, this.logger);
|
|
24
27
|
}
|
|
@@ -49,10 +52,10 @@ class Microservice {
|
|
|
49
52
|
else
|
|
50
53
|
while (!await this.isPortFree(this.serverAddress.port))
|
|
51
54
|
this.serverAddress.port++;
|
|
52
|
-
this.logger.log("address to be listened to:"
|
|
53
|
-
this.logger.log("port to be listened to:"
|
|
55
|
+
this.logger.log("address to be listened to: " + this.serverAddress.address);
|
|
56
|
+
this.logger.log("port to be listened to: " + this.serverAddress.port);
|
|
54
57
|
}
|
|
55
|
-
static async
|
|
58
|
+
static async startTCPMicroService(appModule) {
|
|
56
59
|
const app = await core_1.NestFactory.createMicroservice(appModule, {
|
|
57
60
|
transport: microservices_1.Transport.TCP,
|
|
58
61
|
options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"microservice.service.js","sourceRoot":"","sources":["../../src/microservice/microservice.service.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAC3D,uCAA2C;AAC3C,yDAAuE;AACvE,2BAA2B;AAC3B,kCAAiC;AAEjC,uDAAwD;AACxD,yBAAyB;AACzB,qCAAkC;AAClC,oDAAgD;
|
|
1
|
+
{"version":3,"file":"microservice.service.js","sourceRoot":"","sources":["../../src/microservice/microservice.service.ts"],"names":[],"mappings":";;;AAAA,2CAA2D;AAC3D,uCAA2C;AAC3C,yDAAuE;AACvE,2BAA2B;AAC3B,kCAAiC;AAEjC,uDAAwD;AACxD,yBAAyB;AACzB,qCAAkC;AAClC,oDAAgD;AAChD,0EAAwE;AAExE,MAAa,YAAY;IAIvB,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,SAAS;QAC1C,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,MAAM,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAA;QACxD,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAE9B,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACpE,MAAM,eAAe,GAAG,O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C;SACF,CAEF,CAAC;QACF,GAAG,CAAC,gBAAgB,CAAC,IAAI,qCAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3D,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,KAAK,IAAI;QACb,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAA;IACnE,CAAC;;AA7EH,oCA8EC;AA7EgB,0BAAa,GAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.HttpHealthAppModule = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
let HealthController = class HealthController {
|
|
15
|
+
root() {
|
|
16
|
+
return 'OK';
|
|
17
|
+
}
|
|
18
|
+
health() {
|
|
19
|
+
return { status: 'ok' };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, common_1.Get)(),
|
|
24
|
+
__metadata("design:type", Function),
|
|
25
|
+
__metadata("design:paramtypes", []),
|
|
26
|
+
__metadata("design:returntype", void 0)
|
|
27
|
+
], HealthController.prototype, "root", null);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, common_1.Get)('health'),
|
|
30
|
+
__metadata("design:type", Function),
|
|
31
|
+
__metadata("design:paramtypes", []),
|
|
32
|
+
__metadata("design:returntype", void 0)
|
|
33
|
+
], HealthController.prototype, "health", null);
|
|
34
|
+
HealthController = __decorate([
|
|
35
|
+
(0, common_1.Controller)()
|
|
36
|
+
], HealthController);
|
|
37
|
+
let HttpHealthAppModule = class HttpHealthAppModule {
|
|
38
|
+
};
|
|
39
|
+
exports.HttpHealthAppModule = HttpHealthAppModule;
|
|
40
|
+
exports.HttpHealthAppModule = HttpHealthAppModule = __decorate([
|
|
41
|
+
(0, common_1.Module)({
|
|
42
|
+
controllers: [HealthController],
|
|
43
|
+
})
|
|
44
|
+
], HttpHealthAppModule);
|
|
45
|
+
//# sourceMappingURL=http-health.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-health.module.js","sourceRoot":"","sources":["../../src/minimal-app/http-health.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyD;AAGzD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEpB,IAAI;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,MAAM;QACJ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;CACF,CAAA;AARC;IADC,IAAA,YAAG,GAAE;;;;4CAGL;AAGD;IADC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;8CAGb;AATG,gBAAgB;IADrB,IAAA,mBAAU,GAAE;GACP,gBAAgB,CAUrB;AAKM,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,kDAAmB;8BAAnB,mBAAmB;IAH/B,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,gBAAgB,CAAC;KAChC,CAAC;GACW,mBAAmB,CAAG"}
|