itlab-internal-services 2.15.0 → 2.15.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/dist/controllers/liveness-probe.controller.d.ts +5 -4
- package/dist/controllers/liveness-probe.controller.js +11 -5
- package/dist/modules/comment/comment.service.js +1 -1
- package/dist/modules/content/content.service.js +1 -1
- package/dist/modules/database/database.liveness-controller.d.ts +9 -11
- package/dist/modules/database/database.liveness-controller.js +20 -17
- package/dist/modules/database/database.module.js +1 -1
- package/dist/modules/mail/mail.service.js +1 -1
- package/dist/modules/notification/notification.service.js +1 -1
- package/dist/modules/pass/pass.service.js +1 -1
- package/dist/modules/search/search.service.js +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { Response } from 'express';
|
|
1
2
|
/**
|
|
2
3
|
* Handles Kubernetes liveness probe requests to confirm service health.
|
|
3
4
|
* Kubernetes uses this endpoint to check if the application is alive and responsive.
|
|
4
5
|
*/
|
|
5
6
|
export declare class LivenessProbeController {
|
|
6
7
|
/**
|
|
8
|
+
*
|
|
7
9
|
* Returns a simple JSON response indicating the service is alive.
|
|
8
10
|
* This lightweight response is optimized for quick health checks by Kubernetes.
|
|
9
11
|
*
|
|
10
|
-
* @
|
|
12
|
+
* @param res {Response} - Express response object used to return HTTP status
|
|
13
|
+
* @returns {void} - Sends status response directly via Express
|
|
11
14
|
*/
|
|
12
|
-
getLivenessStatus():
|
|
13
|
-
ok: number;
|
|
14
|
-
};
|
|
15
|
+
getLivenessStatus(response: Response): void;
|
|
15
16
|
}
|
|
@@ -8,6 +8,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.LivenessProbeController = void 0;
|
|
13
16
|
const common_1 = require("@nestjs/common");
|
|
@@ -18,22 +21,25 @@ const swagger_1 = require("@nestjs/swagger");
|
|
|
18
21
|
*/
|
|
19
22
|
let LivenessProbeController = class LivenessProbeController {
|
|
20
23
|
/**
|
|
24
|
+
*
|
|
21
25
|
* Returns a simple JSON response indicating the service is alive.
|
|
22
26
|
* This lightweight response is optimized for quick health checks by Kubernetes.
|
|
23
27
|
*
|
|
24
|
-
* @
|
|
28
|
+
* @param res {Response} - Express response object used to return HTTP status
|
|
29
|
+
* @returns {void} - Sends status response directly via Express
|
|
25
30
|
*/
|
|
26
|
-
getLivenessStatus() {
|
|
31
|
+
getLivenessStatus(response) {
|
|
27
32
|
// Return a minimal positive response to signal the service is up
|
|
28
|
-
|
|
33
|
+
response.status(200).send({ ok: 1 });
|
|
29
34
|
}
|
|
30
35
|
};
|
|
31
36
|
exports.LivenessProbeController = LivenessProbeController;
|
|
32
37
|
__decorate([
|
|
33
38
|
(0, common_1.Get)('/alive'),
|
|
39
|
+
__param(0, (0, common_1.Res)()),
|
|
34
40
|
__metadata("design:type", Function),
|
|
35
|
-
__metadata("design:paramtypes", []),
|
|
36
|
-
__metadata("design:returntype",
|
|
41
|
+
__metadata("design:paramtypes", [Object]),
|
|
42
|
+
__metadata("design:returntype", void 0)
|
|
37
43
|
], LivenessProbeController.prototype, "getLivenessStatus", null);
|
|
38
44
|
exports.LivenessProbeController = LivenessProbeController = __decorate([
|
|
39
45
|
(0, swagger_1.ApiTags)('Kubernetes Liveness Probe'),
|
|
@@ -61,7 +61,7 @@ let CommentService = CommentService_1 = class CommentService {
|
|
|
61
61
|
const isProduction = this.configService.get('NODE_ENV') === 'production';
|
|
62
62
|
// Construct base URL conditionally based on environment.
|
|
63
63
|
const baseUrl = isProduction
|
|
64
|
-
? 'http://organisation-hub-comments-service.organisation-hub-services.svc.cluster.local:3000/internal'
|
|
64
|
+
? 'http://organisation-hub-comments-service.organisation-hub-services.svc.cluster.local:3000/internal/'
|
|
65
65
|
: 'https://services.svi-itlab.com/comments/internal/';
|
|
66
66
|
// Initialize axios instance with k8s token and appropriate URL.
|
|
67
67
|
this.axiosInstance = (0, create_internal_axios_client_function_1.createInternalAxiosClient)({
|
|
@@ -50,7 +50,7 @@ let ContentService = ContentService_1 = class ContentService {
|
|
|
50
50
|
const isProduction = this.configService.get('NODE_ENV') === 'production';
|
|
51
51
|
// Construct base URL conditionally based on environment.
|
|
52
52
|
const baseUrl = isProduction
|
|
53
|
-
? 'http://organisation-hub-content-service.organisation-hub-services.svc.cluster.local:3000/internal'
|
|
53
|
+
? 'http://organisation-hub-content-service.organisation-hub-services.svc.cluster.local:3000/internal/'
|
|
54
54
|
: 'https://services.svi-itlab.com/content/internal/';
|
|
55
55
|
// Initialize axios instance with k8s token and appropriate URL.
|
|
56
56
|
this.axiosInstance = (0, create_internal_axios_client_function_1.createInternalAxiosClient)({
|
|
@@ -5,7 +5,7 @@ import { Connection } from 'mongoose';
|
|
|
5
5
|
* the health of the MongoDB connection. Kubernetes uses this endpoint
|
|
6
6
|
* to determine if the application is alive and able to communicate with the database.
|
|
7
7
|
*/
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class DatabaseLivenessProbeController {
|
|
9
9
|
private readonly connection;
|
|
10
10
|
/**
|
|
11
11
|
* Receives an injected Mongoose connection instance for database health checks.
|
|
@@ -14,16 +14,14 @@ export declare class DatabaseLivenessProbe {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(connection: Connection);
|
|
16
16
|
/**
|
|
17
|
-
* GET /alive
|
|
18
|
-
* Returns HTTP 200 with a simple JSON payload if the database connection is active
|
|
19
|
-
* and responsive. Throws HTTP 500 errors if the connection is down or ping fails.
|
|
17
|
+
* GET /alive
|
|
20
18
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* Endpoint for Kubernetes liveness probe to determine MongoDB connection health.
|
|
20
|
+
* If the database is connected and responsive to a ping, a 200 response is returned.
|
|
21
|
+
* Otherwise, the application returns a 500 error to indicate failure.
|
|
22
|
+
*
|
|
23
|
+
* @param res {Response} - Express response object used to return HTTP status
|
|
24
|
+
* @returns {Promise<void>} - Sends status response directly via Express
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
ok: 1;
|
|
27
|
-
db: 1;
|
|
28
|
-
}>;
|
|
26
|
+
getLivenessStatus(response: Response): Promise<void>;
|
|
29
27
|
}
|
|
@@ -21,7 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.
|
|
24
|
+
exports.DatabaseLivenessProbeController = void 0;
|
|
25
25
|
const common_1 = require("@nestjs/common");
|
|
26
26
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
27
27
|
const swagger_1 = require("@nestjs/swagger");
|
|
@@ -31,7 +31,7 @@ const mongoose_2 = require("mongoose");
|
|
|
31
31
|
* the health of the MongoDB connection. Kubernetes uses this endpoint
|
|
32
32
|
* to determine if the application is alive and able to communicate with the database.
|
|
33
33
|
*/
|
|
34
|
-
let
|
|
34
|
+
let DatabaseLivenessProbeController = class DatabaseLivenessProbeController {
|
|
35
35
|
/**
|
|
36
36
|
* Receives an injected Mongoose connection instance for database health checks.
|
|
37
37
|
*
|
|
@@ -41,48 +41,51 @@ let DatabaseLivenessProbe = class DatabaseLivenessProbe {
|
|
|
41
41
|
this.connection = connection;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* GET /alive
|
|
45
|
-
* Returns HTTP 200 with a simple JSON payload if the database connection is active
|
|
46
|
-
* and responsive. Throws HTTP 500 errors if the connection is down or ping fails.
|
|
44
|
+
* GET /alive
|
|
47
45
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
46
|
+
* Endpoint for Kubernetes liveness probe to determine MongoDB connection health.
|
|
47
|
+
* If the database is connected and responsive to a ping, a 200 response is returned.
|
|
48
|
+
* Otherwise, the application returns a 500 error to indicate failure.
|
|
49
|
+
*
|
|
50
|
+
* @param res {Response} - Express response object used to return HTTP status
|
|
51
|
+
* @returns {Promise<void>} - Sends status response directly via Express
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
+
getLivenessStatus(response) {
|
|
53
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
55
|
// Confirm the Mongoose connection exists and is in a connected state (readyState = 1)
|
|
55
56
|
if (!this.connection || this.connection.readyState !== 1) {
|
|
56
|
-
|
|
57
|
+
response.status(500).send('MongoDB connection is not established');
|
|
58
|
+
return;
|
|
57
59
|
}
|
|
58
60
|
try {
|
|
59
61
|
// Ping the MongoDB admin interface to verify responsiveness
|
|
60
62
|
const pingResult = yield this.connection.db.admin().ping();
|
|
61
63
|
// Validate ping response; an 'ok' value of 1 indicates success
|
|
62
64
|
if ((pingResult === null || pingResult === void 0 ? void 0 : pingResult.ok) === 1) {
|
|
63
|
-
|
|
65
|
+
response.status(200).send({ ok: 1, db: 1 });
|
|
66
|
+
return;
|
|
64
67
|
}
|
|
65
68
|
// If ping did not return success, raise an error indicating DB connectivity issues
|
|
66
|
-
|
|
69
|
+
response.status(500).send('Failed to receive pong from MongoDB');
|
|
67
70
|
}
|
|
68
71
|
catch (_a) {
|
|
69
72
|
// General catch-all for any unexpected errors during the ping process
|
|
70
|
-
|
|
73
|
+
response.status(500).send('Error occurred while pinging MongoDB');
|
|
71
74
|
}
|
|
72
75
|
});
|
|
73
76
|
}
|
|
74
77
|
};
|
|
75
|
-
exports.
|
|
78
|
+
exports.DatabaseLivenessProbeController = DatabaseLivenessProbeController;
|
|
76
79
|
__decorate([
|
|
77
80
|
(0, common_1.Get)('/alive'),
|
|
78
81
|
__param(0, (0, common_1.Res)()),
|
|
79
82
|
__metadata("design:type", Function),
|
|
80
83
|
__metadata("design:paramtypes", [Object]),
|
|
81
84
|
__metadata("design:returntype", Promise)
|
|
82
|
-
],
|
|
83
|
-
exports.
|
|
85
|
+
], DatabaseLivenessProbeController.prototype, "getLivenessStatus", null);
|
|
86
|
+
exports.DatabaseLivenessProbeController = DatabaseLivenessProbeController = __decorate([
|
|
84
87
|
(0, swagger_1.ApiTags)('Kubernetes Liveness Probe'),
|
|
85
88
|
(0, common_1.Controller)(),
|
|
86
89
|
__param(0, (0, mongoose_1.InjectConnection)()),
|
|
87
90
|
__metadata("design:paramtypes", [mongoose_2.Connection])
|
|
88
|
-
],
|
|
91
|
+
], DatabaseLivenessProbeController);
|
|
@@ -100,6 +100,6 @@ exports.DatabaseModule = DatabaseModule = DatabaseModule_1 = __decorate([
|
|
|
100
100
|
(0, common_1.Module)({
|
|
101
101
|
providers: [model_service_1.ModelService, populate_service_1.PopulateService, service_mapper_service_1.ServiceMapperService, lock_service_1.LockService],
|
|
102
102
|
exports: [model_service_1.ModelService, populate_service_1.PopulateService, service_mapper_service_1.ServiceMapperService, lock_service_1.LockService],
|
|
103
|
-
controllers: [database_liveness_controller_1.
|
|
103
|
+
controllers: [database_liveness_controller_1.DatabaseLivenessProbeController],
|
|
104
104
|
})
|
|
105
105
|
], DatabaseModule);
|
|
@@ -60,7 +60,7 @@ let MailService = MailService_1 = class MailService {
|
|
|
60
60
|
const isProduction = this.configService.get('NODE_ENV') === 'production';
|
|
61
61
|
// Construct base URL conditionally based on environment.
|
|
62
62
|
const baseUrl = isProduction
|
|
63
|
-
? 'http://organisation-hub-email-service.organisation-hub-services.svc.cluster.local:3000/internal'
|
|
63
|
+
? 'http://organisation-hub-email-service.organisation-hub-services.svc.cluster.local:3000/internal/'
|
|
64
64
|
: 'https://services.svi-itlab.com/email/internal/';
|
|
65
65
|
// Initialize axios instance with k8s token and appropriate URL.
|
|
66
66
|
this.axiosInstance = (0, create_internal_axios_client_function_1.createInternalAxiosClient)({
|
|
@@ -42,7 +42,7 @@ let NotificationService = NotificationService_1 = class NotificationService {
|
|
|
42
42
|
const isProduction = this.configService.get('NODE_ENV') === 'production';
|
|
43
43
|
// Construct base URL conditionally based on environment.
|
|
44
44
|
const baseUrl = isProduction
|
|
45
|
-
? 'http://organisation-hub-notifications-service.organisation-hub-services.svc.cluster.local:3000/internal'
|
|
45
|
+
? 'http://organisation-hub-notifications-service.organisation-hub-services.svc.cluster.local:3000/internal/'
|
|
46
46
|
: 'https://services.svi-itlab.com/notifications/internal/';
|
|
47
47
|
// Initialize axios instance with k8s token and appropriate URL.
|
|
48
48
|
this.axiosInstance = (0, functions_1.createInternalAxiosClient)({
|
|
@@ -52,7 +52,7 @@ let PassService = PassService_1 = class PassService {
|
|
|
52
52
|
const isProduction = this.configService.get('NODE_ENV') === 'production';
|
|
53
53
|
// Construct base URL conditionally based on environment.
|
|
54
54
|
const baseUrl = isProduction
|
|
55
|
-
? 'http://organisation-hub-pass-service.organisation-hub-services.svc.cluster.local:3000/internal'
|
|
55
|
+
? 'http://organisation-hub-pass-service.organisation-hub-services.svc.cluster.local:3000/internal/'
|
|
56
56
|
: 'https://services.svi-itlab.com/pass/internal/';
|
|
57
57
|
// Initialize axios instance with k8s token and appropriate URL.
|
|
58
58
|
this.axiosInstance = (0, create_internal_axios_client_function_1.createInternalAxiosClient)({
|
|
@@ -51,7 +51,7 @@ let SearchService = SearchService_1 = class SearchService {
|
|
|
51
51
|
const isProduction = this.configService.get('NODE_ENV') === 'production';
|
|
52
52
|
// Construct base URL conditionally based on environment.
|
|
53
53
|
const baseUrl = isProduction
|
|
54
|
-
? 'http://organisation-hub-search-service.organisation-hub-services.svc.cluster.local:3000/internal'
|
|
54
|
+
? 'http://organisation-hub-search-service.organisation-hub-services.svc.cluster.local:3000/internal/'
|
|
55
55
|
: 'https://services.svi-itlab.com/search/internal/';
|
|
56
56
|
// Initialize axios instance with k8s token and appropriate URL.
|
|
57
57
|
this.axiosInstance = (0, create_internal_axios_client_function_1.createInternalAxiosClient)({
|