@signageos/lib 23.20.0 → 23.20.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.
- package/dist/Config/config.d.ts +2 -79
- package/dist/Config/config.js +4 -102
- package/dist/Config/config.js.map +1 -1
- package/dist/Config/environment.d.ts +2 -6
- package/dist/Config/environment.js +16 -8
- package/dist/Config/environment.js.map +1 -1
- package/dist/Config/validation.d.ts +2 -59
- package/dist/Config/validation.js +16 -51
- package/dist/Config/validation.js.map +1 -1
- package/dist/DateTime/dateTimeFactory.d.ts +4 -4
- package/dist/DateTime/dateTimeFactory.js +17 -18
- package/dist/DateTime/dateTimeFactory.js.map +1 -1
- package/dist/HttpStatus/checks/amqpStatusCheck.d.ts +5 -3
- package/dist/HttpStatus/checks/amqpStatusCheck.js +22 -93
- package/dist/HttpStatus/checks/amqpStatusCheck.js.map +1 -1
- package/dist/HttpStatus/checks/mongoDBStatusCheck.d.ts +5 -3
- package/dist/HttpStatus/checks/mongoDBStatusCheck.js +22 -55
- package/dist/HttpStatus/checks/mongoDBStatusCheck.js.map +1 -1
- package/dist/HttpStatus/createHttpStatusMiddleware.d.ts +5 -9
- package/dist/HttpStatus/createHttpStatusMiddleware.js +11 -93
- package/dist/HttpStatus/createHttpStatusMiddleware.js.map +1 -1
- package/dist/HttpStatus/enrichHttpServerWithStatus.d.ts +5 -15
- package/dist/HttpStatus/enrichHttpServerWithStatus.js +11 -98
- package/dist/HttpStatus/enrichHttpServerWithStatus.js.map +1 -1
- package/dist/HttpStatus/sendStatusResponse.d.ts +4 -5
- package/dist/HttpStatus/sendStatusResponse.js +6 -56
- package/dist/HttpStatus/sendStatusResponse.js.map +1 -1
- package/dist/HttpStatus/status.d.ts +5 -19
- package/dist/HttpStatus/status.js +9 -114
- package/dist/HttpStatus/status.js.map +1 -1
- package/dist/HttpStatus/statuses/amqpStatus.d.ts +4 -3
- package/dist/HttpStatus/statuses/amqpStatus.js +6 -20
- package/dist/HttpStatus/statuses/amqpStatus.js.map +1 -1
- package/dist/HttpStatus/statuses/mongoStatus.d.ts +4 -3
- package/dist/HttpStatus/statuses/mongoStatus.js +6 -20
- package/dist/HttpStatus/statuses/mongoStatus.js.map +1 -1
- package/dist/HttpStatus/statuses/redisStatus.d.ts +4 -3
- package/dist/HttpStatus/statuses/redisStatus.js +6 -20
- package/dist/HttpStatus/statuses/redisStatus.js.map +1 -1
- package/dist/Logging/console.d.ts +2 -6
- package/dist/Logging/console.js +16 -42
- package/dist/Logging/console.js.map +1 -1
- package/dist/Logging/debug.d.ts +2 -8
- package/dist/Logging/debug.js +14 -54
- package/dist/Logging/debug.js.map +1 -1
- package/dist/Logging/format.d.ts +2 -8
- package/dist/Logging/format.js +4 -62
- package/dist/Logging/format.js.map +1 -1
- package/dist/Logging/logger.d.ts +3 -52
- package/dist/Logging/logger.js +17 -64
- package/dist/Logging/logger.js.map +1 -1
- package/dist/Logging/logging.d.ts +2 -10
- package/dist/Logging/logging.js +4 -96
- package/dist/Logging/logging.js.map +1 -1
- package/dist/Metrics/logMetrics.d.ts +4 -4
- package/dist/Metrics/logMetrics.js +18 -37
- package/dist/Metrics/logMetrics.js.map +1 -1
- package/dist/Metrics/mongoDBMetrics.d.ts +2 -33
- package/dist/Metrics/mongoDBMetrics.js +15 -156
- package/dist/Metrics/mongoDBMetrics.js.map +1 -1
- package/dist/MongoDB/MongoDBConnection.d.ts +4 -19
- package/dist/MongoDB/MongoDBConnection.js +16 -180
- package/dist/MongoDB/MongoDBConnection.js.map +1 -1
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/dynamicPriority.d.ts +4 -2
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/dynamicPriority.js +16 -101
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/dynamicPriority.js.map +1 -1
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/lowReadLatency.d.ts +4 -2
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/lowReadLatency.js +16 -89
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/lowReadLatency.js.map +1 -1
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/ordinary.d.ts +4 -2
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/ordinary.js +16 -75
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/ordinary.js.map +1 -1
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/random.d.ts +4 -2
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/random.js +16 -46
- package/dist/MongoDB/ProprietaryCluster/SelectionStrategy/random.js.map +1 -1
- package/dist/MongoDB/ProprietaryCluster/helper.d.ts +4 -13
- package/dist/MongoDB/ProprietaryCluster/helper.js +6 -132
- package/dist/MongoDB/ProprietaryCluster/helper.js.map +1 -1
- package/dist/MongoDB/cursorIterator.d.ts +4 -5
- package/dist/MongoDB/cursorIterator.js +16 -58
- package/dist/MongoDB/cursorIterator.js.map +1 -1
- package/dist/MongoDB/escape.d.ts +4 -4
- package/dist/MongoDB/escape.js +17 -50
- package/dist/MongoDB/escape.js.map +1 -1
- package/dist/MongoDB/mongoDBConnectionFactory.d.ts +2 -11
- package/dist/MongoDB/mongoDBConnectionFactory.js +16 -6
- package/dist/MongoDB/mongoDBConnectionFactory.js.map +1 -1
- package/dist/MongoDB/proprietaryCluster.d.ts +4 -1
- package/dist/MongoDB/proprietaryCluster.js +16 -71
- package/dist/MongoDB/proprietaryCluster.js.map +1 -1
- package/dist/Service/HTTP/express/app.d.ts +4 -33
- package/dist/Service/HTTP/express/app.js +6 -67
- package/dist/Service/HTTP/express/app.js.map +1 -1
- package/dist/Service/HTTP/express/expressFactory.d.ts +2 -2
- package/dist/Service/HTTP/express/expressFactory.js +15 -16
- package/dist/Service/HTTP/express/expressFactory.js.map +1 -1
- package/dist/Service/HTTP/express/monitoring.d.ts +4 -8
- package/dist/Service/HTTP/express/monitoring.js +17 -21
- package/dist/Service/HTTP/express/monitoring.js.map +1 -1
- package/dist/Service/HTTP/httpServerFactory.d.ts +2 -54
- package/dist/Service/HTTP/httpServerFactory.js +14 -97
- package/dist/Service/HTTP/httpServerFactory.js.map +1 -1
- package/dist/Service/HTTP/middleware/accessLogMiddleware.d.ts +4 -20
- package/dist/Service/HTTP/middleware/accessLogMiddleware.js +15 -84
- package/dist/Service/HTTP/middleware/accessLogMiddleware.js.map +1 -1
- package/dist/Service/HTTP/middleware/headersMiddleware.d.ts +4 -2
- package/dist/Service/HTTP/middleware/headersMiddleware.js +18 -15
- package/dist/Service/HTTP/middleware/headersMiddleware.js.map +1 -1
- package/dist/Service/HTTP/routes/app/indexPage.d.ts +2 -5
- package/dist/Service/HTTP/routes/app/indexPage.js +16 -7
- package/dist/Service/HTTP/routes/app/indexPage.js.map +1 -1
- package/dist/Service/HTTP/routes/app/router.d.ts +4 -14
- package/dist/Service/HTTP/routes/app/router.js +18 -9
- package/dist/Service/HTTP/routes/app/router.js.map +1 -1
- package/dist/Service/HTTP/routes/app/status.d.ts +2 -11
- package/dist/Service/HTTP/routes/app/status.js +14 -37
- package/dist/Service/HTTP/routes/app/status.js.map +1 -1
- package/dist/Service/HTTP/routes/monitoring/aliveness.d.ts +2 -18
- package/dist/Service/HTTP/routes/monitoring/aliveness.js +14 -68
- package/dist/Service/HTTP/routes/monitoring/aliveness.js.map +1 -1
- package/dist/Service/HTTP/routes/monitoring/metrics.d.ts +2 -7
- package/dist/Service/HTTP/routes/monitoring/metrics.js +14 -52
- package/dist/Service/HTTP/routes/monitoring/metrics.js.map +1 -1
- package/dist/Service/HTTP/routes/monitoring/readniness.d.ts +2 -16
- package/dist/Service/HTTP/routes/monitoring/readniness.js +14 -73
- package/dist/Service/HTTP/routes/monitoring/readniness.js.map +1 -1
- package/dist/Service/HTTP/routes/monitoring/router.d.ts +4 -10
- package/dist/Service/HTTP/routes/monitoring/router.js +18 -9
- package/dist/Service/HTTP/routes/monitoring/router.js.map +1 -1
- package/dist/Service/HTTP/server/serverFactory.d.ts +2 -17
- package/dist/Service/HTTP/server/serverFactory.js +4 -143
- package/dist/Service/HTTP/server/serverFactory.js.map +1 -1
- package/dist/Service/Service.d.ts +4 -17
- package/dist/Service/Service.js +16 -92
- package/dist/Service/Service.js.map +1 -1
- package/dist/Service/dbConnections.d.ts +4 -8
- package/dist/Service/dbConnections.js +18 -0
- package/dist/Service/dbConnections.js.map +1 -1
- package/dist/Service/metrics/connections.d.ts +4 -3
- package/dist/Service/metrics/connections.js +17 -43
- package/dist/Service/metrics/connections.js.map +1 -1
- package/dist/Service/metrics/mongodb.d.ts +4 -2
- package/dist/Service/metrics/mongodb.js +18 -10
- package/dist/Service/metrics/mongodb.js.map +1 -1
- package/dist/Service/metrics/redis.d.ts +4 -2
- package/dist/Service/metrics/redis.js +18 -8
- package/dist/Service/metrics/redis.js.map +1 -1
- package/dist/Service/process.d.ts +4 -11
- package/dist/Service/process.js +16 -83
- package/dist/Service/process.js.map +1 -1
- package/dist/Service/serviceFactory.d.ts +2 -115
- package/dist/Service/serviceFactory.js +16 -114
- package/dist/Service/serviceFactory.js.map +1 -1
- package/dist/Service/types.d.ts +4 -55
- package/dist/Service/types.js +18 -0
- package/dist/Service/types.js.map +1 -1
- package/dist/ThirdParty/connection.d.ts +4 -17
- package/dist/ThirdParty/connection.js +18 -6
- package/dist/ThirdParty/connection.js.map +1 -1
- package/package.json +5 -20
package/dist/Service/process.js
CHANGED
|
@@ -1,88 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
36
7
|
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
15
|
};
|
|
38
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
process.uid = (0, generator_1.generateUniqueHash)();
|
|
44
|
-
var stopService = function (service) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
return __generator(this, function (_a) {
|
|
46
|
-
switch (_a.label) {
|
|
47
|
-
case 0:
|
|
48
|
-
process.removeAllListeners('SIGTERM');
|
|
49
|
-
process.removeAllListeners('SIGINT');
|
|
50
|
-
return [4 /*yield*/, service.stop()];
|
|
51
|
-
case 1:
|
|
52
|
-
_a.sent();
|
|
53
|
-
process.exit(0);
|
|
54
|
-
return [2 /*return*/];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}); };
|
|
58
|
-
exports.stopService = stopService;
|
|
59
|
-
function handleSignals(service) {
|
|
60
|
-
var _this = this;
|
|
61
|
-
var onSignalLogAndExit = function (signal) {
|
|
62
|
-
process.on(signal, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
console.info("Received signal ".concat(signal));
|
|
67
|
-
return [4 /*yield*/, (0, exports.stopService)(service)];
|
|
68
|
-
case 1:
|
|
69
|
-
_a.sent();
|
|
70
|
-
return [2 /*return*/];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}); });
|
|
74
|
-
};
|
|
75
|
-
onSignalLogAndExit('SIGTERM');
|
|
76
|
-
onSignalLogAndExit('SIGINT');
|
|
77
|
-
}
|
|
78
|
-
function suppressUncaughtExceptionsAndUnhandledRejections() {
|
|
79
|
-
process.removeAllListeners('uncaughtException');
|
|
80
|
-
process.removeAllListeners('unhandledRejection');
|
|
81
|
-
process.on('uncaughtException', function (error) {
|
|
82
|
-
console.error(error && error.stack ? error.stack : error);
|
|
83
|
-
});
|
|
84
|
-
process.on('unhandledRejection', function (error) {
|
|
85
|
-
console.error(error && error.stack ? error.stack : error);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `@signageos/service` instead.
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("@signageos/service/dist/Service/process"), exports);
|
|
88
21
|
//# sourceMappingURL=process.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/Service/process.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/Service/process.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,0EAAwD"}
|
|
@@ -1,117 +1,4 @@
|
|
|
1
|
-
import { DBConnections } from './dbConnections';
|
|
2
|
-
import { ServiceConfig } from '../Config/config';
|
|
3
|
-
import { IsReadyCallback } from './HTTP/routes/monitoring/readniness';
|
|
4
|
-
import { IsAliveCallback } from './HTTP/routes/monitoring/aliveness';
|
|
5
|
-
import { IService } from './types';
|
|
6
|
-
import { AccessLogCallback } from './HTTP/express/app';
|
|
7
|
-
import { TAdditionalStatusDataCallback } from '../HttpStatus/sendStatusResponse';
|
|
8
|
-
import { CreateServerOptions } from './HTTP/server/serverFactory';
|
|
9
1
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Service implements all functionality that is common for all services
|
|
13
|
-
* This functionality is the same in every service.
|
|
14
|
-
*
|
|
15
|
-
* We had a problem of writing it from scratch each time for every service.
|
|
16
|
-
* Sometimes there was a drift, where some new ideas were implemented in one or more services
|
|
17
|
-
* but not in all services.
|
|
18
|
-
*
|
|
19
|
-
* This single common implementation aims to prevent that and provide a common implementation
|
|
20
|
-
* that all services can use as a library.
|
|
21
|
-
*
|
|
22
|
-
* @param config - It's recommended to use the direct output of `parseServiceConfig()`. The format is deliberately the same.
|
|
23
|
-
* @param connections - Database connections
|
|
24
|
-
* @param isReady - Custom readiness check for Kubernetes
|
|
25
|
-
* @param isAlive - Custom aliveness check for Kubernetes
|
|
26
|
-
* @param accessLogCallback - Custom callback to modify the access log before it is logged
|
|
27
|
-
*
|
|
28
|
-
* -------
|
|
29
|
-
*
|
|
30
|
-
* Adding application-specific HTTP routes:
|
|
31
|
-
*
|
|
32
|
-
* This factory returns express app, that can be used to add more routes.
|
|
33
|
-
*
|
|
34
|
-
* For example:
|
|
35
|
-
*
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const service = createService({ ... });
|
|
38
|
-
* service.httpServer.express.get('/my-route', (req, res) => {
|
|
39
|
-
* res.send('Hello World!');
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* -------
|
|
44
|
-
*
|
|
45
|
-
* Adding application-specific metrics:
|
|
46
|
-
*
|
|
47
|
-
* By default, the service serves some basic Node.js metrics.
|
|
48
|
-
* This factory returns a metrics client, that can be used to add more metrics.
|
|
49
|
-
*
|
|
50
|
-
* For example:
|
|
51
|
-
*
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const service = createService({ ... });
|
|
54
|
-
* const client = service.metricsClient.getClient();
|
|
55
|
-
* const myCounter = new client.Counter({
|
|
56
|
-
* name: 'my_counter',
|
|
57
|
-
* help: 'This is my counter',
|
|
58
|
-
* });
|
|
59
|
-
*
|
|
60
|
-
* // now you can independently increment the counter in your code
|
|
61
|
-
* // and the value will automatically be exposed when serving metrics
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* -------
|
|
65
|
-
*
|
|
66
|
-
* Custom readiness and aliveness checks:
|
|
67
|
-
*
|
|
68
|
-
* By default, the service serves `/ready` and `/alive` routes, that are used by Kubernetes readiness/aliveness probes.
|
|
69
|
-
* You can provide custom callbacks if the default checks are not enough:
|
|
70
|
-
*
|
|
71
|
-
* ```typescript
|
|
72
|
-
* const service = createService({
|
|
73
|
-
* // ...
|
|
74
|
-
*
|
|
75
|
-
* isReady: async () => {
|
|
76
|
-
* // your custom readiness check
|
|
77
|
-
* // either return true/false if service is/isn't ready to receive traffic
|
|
78
|
-
* // or return an object { ready: boolean, response: any } to provide a custom response
|
|
79
|
-
* return true;
|
|
80
|
-
* },
|
|
81
|
-
*
|
|
82
|
-
* isAlive: async () => {
|
|
83
|
-
* // your custom aliveness check
|
|
84
|
-
* // return true/false if service is/isn't alive
|
|
85
|
-
* return true;
|
|
86
|
-
* },
|
|
87
|
-
* });
|
|
88
|
-
* ```
|
|
2
|
+
* @deprecated Use `@signageos/service` instead.
|
|
89
3
|
*/
|
|
90
|
-
export
|
|
91
|
-
config: Pick<ServiceConfig, 'app'>;
|
|
92
|
-
connections?: DBConnections;
|
|
93
|
-
isReady?: IsReadyCallback;
|
|
94
|
-
isAlive?: IsAliveCallback;
|
|
95
|
-
/**
|
|
96
|
-
* Custom callback to modify the access log before it is logged
|
|
97
|
-
*
|
|
98
|
-
* Use it to add custom fields to the access log.
|
|
99
|
-
* It's not possible to modify the access log directly, only to add additional fields.
|
|
100
|
-
*
|
|
101
|
-
* @returns metadata object that will be merged with the access log
|
|
102
|
-
*/
|
|
103
|
-
accessLogCallback?: AccessLogCallback;
|
|
104
|
-
/**
|
|
105
|
-
* Prevent serving the index page on / path
|
|
106
|
-
*/
|
|
107
|
-
noRouteIndex?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* PEN TESTS Remediation https://app.clickup.com/t/86c140zgd
|
|
110
|
-
*/
|
|
111
|
-
setDefaultPenTestHeaders?: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* additional data displayed under `/status` path
|
|
114
|
-
*/
|
|
115
|
-
additionalStatusDataCallback?: TAdditionalStatusDataCallback;
|
|
116
|
-
serverOptions?: CreateServerOptions;
|
|
117
|
-
}): IService;
|
|
4
|
+
export * from '@signageos/service/dist/Service/serviceFactory';
|
|
@@ -1,119 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createService = createService;
|
|
4
|
-
var httpServerFactory_1 = require("./HTTP/httpServerFactory");
|
|
5
|
-
var MetricsClient_1 = require("../Metrics/MetricsClient");
|
|
6
|
-
var connections_1 = require("./metrics/connections");
|
|
7
|
-
var Service_1 = require("./Service");
|
|
8
17
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Service implements all functionality that is common for all services
|
|
12
|
-
* This functionality is the same in every service.
|
|
13
|
-
*
|
|
14
|
-
* We had a problem of writing it from scratch each time for every service.
|
|
15
|
-
* Sometimes there was a drift, where some new ideas were implemented in one or more services
|
|
16
|
-
* but not in all services.
|
|
17
|
-
*
|
|
18
|
-
* This single common implementation aims to prevent that and provide a common implementation
|
|
19
|
-
* that all services can use as a library.
|
|
20
|
-
*
|
|
21
|
-
* @param config - It's recommended to use the direct output of `parseServiceConfig()`. The format is deliberately the same.
|
|
22
|
-
* @param connections - Database connections
|
|
23
|
-
* @param isReady - Custom readiness check for Kubernetes
|
|
24
|
-
* @param isAlive - Custom aliveness check for Kubernetes
|
|
25
|
-
* @param accessLogCallback - Custom callback to modify the access log before it is logged
|
|
26
|
-
*
|
|
27
|
-
* -------
|
|
28
|
-
*
|
|
29
|
-
* Adding application-specific HTTP routes:
|
|
30
|
-
*
|
|
31
|
-
* This factory returns express app, that can be used to add more routes.
|
|
32
|
-
*
|
|
33
|
-
* For example:
|
|
34
|
-
*
|
|
35
|
-
* ```typescript
|
|
36
|
-
* const service = createService({ ... });
|
|
37
|
-
* service.httpServer.express.get('/my-route', (req, res) => {
|
|
38
|
-
* res.send('Hello World!');
|
|
39
|
-
* });
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* -------
|
|
43
|
-
*
|
|
44
|
-
* Adding application-specific metrics:
|
|
45
|
-
*
|
|
46
|
-
* By default, the service serves some basic Node.js metrics.
|
|
47
|
-
* This factory returns a metrics client, that can be used to add more metrics.
|
|
48
|
-
*
|
|
49
|
-
* For example:
|
|
50
|
-
*
|
|
51
|
-
* ```typescript
|
|
52
|
-
* const service = createService({ ... });
|
|
53
|
-
* const client = service.metricsClient.getClient();
|
|
54
|
-
* const myCounter = new client.Counter({
|
|
55
|
-
* name: 'my_counter',
|
|
56
|
-
* help: 'This is my counter',
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* // now you can independently increment the counter in your code
|
|
60
|
-
* // and the value will automatically be exposed when serving metrics
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* -------
|
|
64
|
-
*
|
|
65
|
-
* Custom readiness and aliveness checks:
|
|
66
|
-
*
|
|
67
|
-
* By default, the service serves `/ready` and `/alive` routes, that are used by Kubernetes readiness/aliveness probes.
|
|
68
|
-
* You can provide custom callbacks if the default checks are not enough:
|
|
69
|
-
*
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const service = createService({
|
|
72
|
-
* // ...
|
|
73
|
-
*
|
|
74
|
-
* isReady: async () => {
|
|
75
|
-
* // your custom readiness check
|
|
76
|
-
* // either return true/false if service is/isn't ready to receive traffic
|
|
77
|
-
* // or return an object { ready: boolean, response: any } to provide a custom response
|
|
78
|
-
* return true;
|
|
79
|
-
* },
|
|
80
|
-
*
|
|
81
|
-
* isAlive: async () => {
|
|
82
|
-
* // your custom aliveness check
|
|
83
|
-
* // return true/false if service is/isn't alive
|
|
84
|
-
* return true;
|
|
85
|
-
* },
|
|
86
|
-
* });
|
|
87
|
-
* ```
|
|
18
|
+
* @deprecated Use `@signageos/service` instead.
|
|
88
19
|
*/
|
|
89
|
-
|
|
90
|
-
var config = _a.config, connections = _a.connections, isReady = _a.isReady, isAlive = _a.isAlive, accessLogCallback = _a.accessLogCallback, noRouteIndex = _a.noRouteIndex, setDefaultPenTestHeaders = _a.setDefaultPenTestHeaders, additionalStatusDataCallback = _a.additionalStatusDataCallback, serverOptions = _a.serverOptions;
|
|
91
|
-
var metricsClient = new MetricsClient_1.MetricsClient();
|
|
92
|
-
var serviceInfo = {
|
|
93
|
-
name: config.app.name,
|
|
94
|
-
version: config.app.version,
|
|
95
|
-
uid: process.uid,
|
|
96
|
-
};
|
|
97
|
-
var httpServer = (0, httpServerFactory_1.createHttpServer)({
|
|
98
|
-
service: serviceInfo,
|
|
99
|
-
port: config.app.port,
|
|
100
|
-
monitoringPort: config.app.monitoringPort,
|
|
101
|
-
metricsClient: metricsClient,
|
|
102
|
-
connections: connections,
|
|
103
|
-
isReady: isReady,
|
|
104
|
-
isAlive: isAlive,
|
|
105
|
-
accessLogCallback: accessLogCallback,
|
|
106
|
-
noRouteIndex: noRouteIndex,
|
|
107
|
-
setDefaultPenTestHeaders: setDefaultPenTestHeaders,
|
|
108
|
-
additionalStatusDataCallback: additionalStatusDataCallback,
|
|
109
|
-
serverOptions: serverOptions,
|
|
110
|
-
});
|
|
111
|
-
if (connections) {
|
|
112
|
-
(0, connections_1.initDbConnectionsMetrics)(connections, metricsClient);
|
|
113
|
-
}
|
|
114
|
-
return new Service_1.Service({
|
|
115
|
-
httpServer: httpServer,
|
|
116
|
-
metricsClient: metricsClient,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
20
|
+
__exportStar(require("@signageos/service/dist/Service/serviceFactory"), exports);
|
|
119
21
|
//# sourceMappingURL=serviceFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceFactory.js","sourceRoot":"","sources":["../../src/Service/serviceFactory.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"serviceFactory.js","sourceRoot":"","sources":["../../src/Service/serviceFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,iFAA+D"}
|
package/dist/Service/types.d.ts
CHANGED
|
@@ -1,55 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
/** Main HTTP server */
|
|
6
|
-
server: HttpServer;
|
|
7
|
-
/** Use this to extend application HTTP routes */
|
|
8
|
-
express: Application;
|
|
9
|
-
/** Monitoring runs on a separate port for security reasons */
|
|
10
|
-
monitoringServer: HttpServer;
|
|
11
|
-
/** Use this to extend monitoring HTTP routes */
|
|
12
|
-
monitoringExpress: Application;
|
|
13
|
-
listen(): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Waits for the server to finish serving all requests, then closes it
|
|
16
|
-
*/
|
|
17
|
-
close(): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
export type OnServiceStopCallback = () => Promise<void>;
|
|
20
|
-
export interface IService {
|
|
21
|
-
httpServer: IHttpServer;
|
|
22
|
-
metricsClient: IMetricsClient;
|
|
23
|
-
/**
|
|
24
|
-
* Returns true if the service has been started
|
|
25
|
-
*/
|
|
26
|
-
isStarted(): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Starts the service and all its sub-services, i.e. the HTTP server
|
|
29
|
-
*/
|
|
30
|
-
start(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Stops the service and all the sub-services managed by it, i.e. the HTTP server
|
|
33
|
-
*
|
|
34
|
-
* It will block until HTTP server finishes serving all requests
|
|
35
|
-
*/
|
|
36
|
-
stop(): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Add a custom listener for when the service is stopped
|
|
39
|
-
*
|
|
40
|
-
* This callback is called when the service receives a stop signal or when the service method stop() is called.
|
|
41
|
-
*
|
|
42
|
-
* This callback should perform any necessary cleanup before the service and the entire process is stopped.
|
|
43
|
-
* Typically that would include:
|
|
44
|
-
* - draining connections
|
|
45
|
-
* - waiting for all pending requests to finish
|
|
46
|
-
* - calling external services to notify them about the shutdown
|
|
47
|
-
*
|
|
48
|
-
* @note database connections are automatically closed when the service is stopped.
|
|
49
|
-
*/
|
|
50
|
-
on(event: 'stop', callback: OnServiceStopCallback): this;
|
|
51
|
-
/**
|
|
52
|
-
* Remove a custom listener previously added with on()
|
|
53
|
-
*/
|
|
54
|
-
off(event: 'stop', callback: OnServiceStopCallback): this;
|
|
55
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use `@signageos/service` instead.
|
|
3
|
+
*/
|
|
4
|
+
export * from '@signageos/service/dist/Service/types';
|
package/dist/Service/types.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `@signageos/service` instead.
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("@signageos/service/dist/Service/types"), exports);
|
|
3
21
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Service/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/Service/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,wEAAsD"}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export interface IConnection<TExporter = {}> {
|
|
7
|
-
connect: () => Promise<void>;
|
|
8
|
-
close: () => Promise<void>;
|
|
9
|
-
connection: EventEmitter | null;
|
|
10
|
-
/**
|
|
11
|
-
* Start monitoring the connection and report metrics to the metricsClient
|
|
12
|
-
*
|
|
13
|
-
* @exporter - metrics exporter
|
|
14
|
-
* @connectionName - name of the connection that will be used as a label to distinguish between different connections
|
|
15
|
-
*/
|
|
16
|
-
monitor: (connectionName: string, exporter?: TExporter) => void;
|
|
17
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use `@signageos/service` instead.
|
|
3
|
+
*/
|
|
4
|
+
export * from '@signageos/service/dist/ThirdParty/connection';
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ThirdPartyConnectionEvent["ConnectionClosed"] = "connection_closed";
|
|
8
|
-
})(ThirdPartyConnectionEvent || (exports.ThirdPartyConnectionEvent = ThirdPartyConnectionEvent = {}));
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `@signageos/service` instead.
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("@signageos/service/dist/ThirdParty/connection"), exports);
|
|
9
21
|
//# sourceMappingURL=connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/ThirdParty/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/ThirdParty/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,gFAA8D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signageos/lib",
|
|
3
|
-
"version": "23.20.
|
|
3
|
+
"version": "23.20.1",
|
|
4
4
|
"main": "./dist",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -39,37 +39,29 @@
|
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@signageos/amqp": "^0.2.1",
|
|
42
|
-
"@signageos/core": "^1.
|
|
43
|
-
"@signageos/lib-ci": "23.20.
|
|
42
|
+
"@signageos/core": "^1.5.0",
|
|
43
|
+
"@signageos/lib-ci": "23.20.1",
|
|
44
44
|
"@signageos/metrics": "^1.0.0",
|
|
45
45
|
"@signageos/redis": "^3.1.0",
|
|
46
|
+
"@signageos/service": "^1.1.1",
|
|
46
47
|
"async-lock": "1.4.0",
|
|
47
48
|
"auth0": "4.4.1",
|
|
48
|
-
"basic-auth": "2.0.1",
|
|
49
49
|
"co": "4.6.0",
|
|
50
|
-
"connection-string-parser": "1.0.2",
|
|
51
50
|
"debug": "^4.3.4",
|
|
52
|
-
"dotenv": "16.4.5",
|
|
53
51
|
"express": "^4.21.2",
|
|
54
|
-
"express-prom-bundle": "8.0.0",
|
|
55
52
|
"file-type": "16.5.4",
|
|
56
53
|
"fs-extra": "11.2.0",
|
|
57
|
-
"http-status": "2.0.0",
|
|
58
54
|
"isomorphic-ws": "4.0.1",
|
|
59
55
|
"lodash": "4.17.21",
|
|
60
56
|
"lru-cache": "11.0.2",
|
|
61
57
|
"moment-timezone": "0.5.45",
|
|
62
58
|
"node-fetch": "2.7.0",
|
|
63
|
-
"on-finished": "2.4.1",
|
|
64
|
-
"prom-client": "^15.1.0",
|
|
65
|
-
"qs": "6.11.2",
|
|
66
59
|
"remove-accents": "0.4.2",
|
|
67
60
|
"rsync": "0.6.1",
|
|
68
61
|
"semver": "7.7.1",
|
|
69
62
|
"tar": "7.0.1",
|
|
70
63
|
"tmp": "0.2.1",
|
|
71
64
|
"ts-brand": "0.0.2",
|
|
72
|
-
"winston": "3.11.0",
|
|
73
65
|
"zod": "^3.24.1"
|
|
74
66
|
},
|
|
75
67
|
"optionalPeerDependencies": {
|
|
@@ -100,27 +92,22 @@
|
|
|
100
92
|
"@faker-js/faker": "8.3.1",
|
|
101
93
|
"@istanbuljs/nyc-config-typescript": "1.0.2",
|
|
102
94
|
"@types/async-lock": "1.4.2",
|
|
103
|
-
"@types/basic-auth": "1.1.8",
|
|
104
95
|
"@types/css-tree": "2.3.5",
|
|
105
96
|
"@types/debug": "0.0.29",
|
|
106
97
|
"@types/express": "4.17.21",
|
|
107
98
|
"@types/fs-extra": "11.0.4",
|
|
108
99
|
"@types/glob": "8.1.0",
|
|
109
|
-
"@types/http-status": "0.2.30",
|
|
110
100
|
"@types/lodash": "4.14.158",
|
|
111
101
|
"@types/mocha": "10.0.6",
|
|
112
102
|
"@types/node": "24.10.13",
|
|
113
103
|
"@types/node-fetch": "2.6.4",
|
|
114
|
-
"@types/on-finished": "2.3.4",
|
|
115
104
|
"@types/path-browserify": "1.0.2",
|
|
116
|
-
"@types/qs": "6.9.14",
|
|
117
105
|
"@types/rsync": "0.4.30",
|
|
118
106
|
"@types/semver": "7.5.6",
|
|
119
107
|
"@types/should": "8.3.0",
|
|
120
108
|
"@types/sinon": "10.0.16",
|
|
121
109
|
"@types/socket.io": "1.4.38",
|
|
122
110
|
"@types/socket.io-client": "1.4.32",
|
|
123
|
-
"@types/supertest": "2.0.7",
|
|
124
111
|
"@types/tar": "6.1.10",
|
|
125
112
|
"@types/tmp": "0.0.33",
|
|
126
113
|
"@types/webpack": "5.28.1",
|
|
@@ -133,14 +120,12 @@
|
|
|
133
120
|
"eslint-plugin-prettier": "5.1.3",
|
|
134
121
|
"minio": "7.1.3",
|
|
135
122
|
"mocha": "10.2.0",
|
|
136
|
-
"
|
|
137
|
-
"mongoose": "8.8.4",
|
|
123
|
+
"mongoose": "8.0.0",
|
|
138
124
|
"should": "11.2.1",
|
|
139
125
|
"should-sinon": "0.0.6",
|
|
140
126
|
"sinon": "15.2.0",
|
|
141
127
|
"socket.io": "2.5.0",
|
|
142
128
|
"socket.io-client": "4.7.2",
|
|
143
|
-
"supertest": "3.4.2",
|
|
144
129
|
"ts-node": "10.9.2",
|
|
145
130
|
"util": "0.12.5",
|
|
146
131
|
"verdaccio": "5.29.0",
|