@sme.up/kokos-sdk-node 3.0.0-SNAPSHOT.20251013105830.781 → 3.0.0-SNAPSHOT.20251013124235.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/docs/assets/hierarchy.js +1 -1
- package/docs/classes/App.html +2 -2
- package/docs/classes/BatchContext.html +2 -2
- package/docs/classes/EntityOav.html +2 -2
- package/docs/classes/EntitySlice.html +2 -2
- package/docs/classes/ErrorWithStatus.html +4 -6
- package/docs/classes/ExecuteFunPayload.html +2 -2
- package/docs/classes/ExecutionContext.html +2 -2
- package/docs/classes/Fun.html +2 -2
- package/docs/classes/FunObject.html +2 -2
- package/docs/classes/KokosEntityDAOService.html +8 -8
- package/docs/classes/Registry.html +2 -2
- package/docs/classes/SmeupDataStructureWriter.html +5 -5
- package/docs/classes/SourceLibrary.html +2 -2
- package/docs/classes/User.html +2 -2
- package/docs/enums/ApiVersion.html +2 -2
- package/docs/enums/DynamismEvents.html +2 -2
- package/docs/enums/Format.html +2 -2
- package/docs/enums/FunStatus.html +2 -2
- package/docs/enums/Level.html +2 -2
- package/docs/enums/LoadType.html +2 -2
- package/docs/enums/SectionTypes.html +2 -2
- package/docs/enums/Shapes.html +2 -2
- package/docs/enums/SmeupDataStructureType.html +5 -5
- package/docs/enums/SmeupLayoutSectionType.html +2 -2
- package/docs/enums/ToolbarState.html +2 -2
- package/docs/enums/YesNo.html +2 -2
- package/docs/functions/clearLoggerContext.html +1 -1
- package/docs/functions/closeEventUtils.html +1 -1
- package/docs/functions/configureLogger.html +1 -1
- package/docs/functions/createLoggerContext.html +1 -1
- package/docs/functions/executeFun.html +1 -1
- package/docs/functions/funObjectToString.html +1 -1
- package/docs/functions/funToString.html +1 -1
- package/docs/functions/getSmeupDataStructureType.html +1 -1
- package/docs/functions/parseArrayString.html +4 -4
- package/docs/functions/parseFieldValues.html +1 -1
- package/docs/functions/parseKeyValueBetweenBrackets.html +1 -1
- package/docs/functions/parseUpdatePayload.html +1 -1
- package/docs/functions/parseUpdatePayloadMultipleRows.html +1 -1
- package/docs/functions/startServer.html +1 -1
- package/docs/functions/startServerWithCustomConfig.html +1 -1
- package/docs/functions/stringToFun.html +1 -1
- package/docs/functions/submitBusinessEvent.html +1 -1
- package/docs/functions/toDateCell.html +1 -1
- package/docs/functions/toIconButtonCell.html +1 -1
- package/docs/functions/toNumberCell.html +1 -1
- package/docs/functions/toSingleChipCell.html +1 -1
- package/docs/functions/toStringCell.html +1 -1
- package/docs/functions/toTextButtonCell.html +1 -1
- package/docs/functions/toTimeCell.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/interfaces/ComponentOptions.html +2 -2
- package/docs/interfaces/DebugInfo.html +2 -2
- package/docs/interfaces/DocumentDatabaseDataSource.html +2 -2
- package/docs/interfaces/IKokosEntityDAOService.html +2 -2
- package/docs/interfaces/IKokosInputPanelService.html +2 -2
- package/docs/interfaces/KokosEntityDAOServiceMethods.html +7 -7
- package/docs/interfaces/KokosInputPanelServiceMethods.html +6 -6
- package/docs/interfaces/KokosService.html +2 -2
- package/docs/interfaces/KokosServiceMethods.html +1 -1
- package/docs/interfaces/KokosServiceModule.html +2 -2
- package/docs/interfaces/LoggerContext.html +2 -2
- package/docs/interfaces/MicroExecutorConfiguration.html +2 -2
- package/docs/interfaces/RawDynamism.html +7 -7
- package/docs/interfaces/SmeupAction.html +2 -2
- package/docs/interfaces/SmeupBusinessEvent.html +2 -2
- package/docs/interfaces/SmeupDataCell.html +2 -2
- package/docs/interfaces/SmeupDataColumn.html +2 -2
- package/docs/interfaces/SmeupDataNode.html +2 -2
- package/docs/interfaces/SmeupDataRow.html +2 -2
- package/docs/interfaces/SmeupDataStructure.html +2 -2
- package/docs/interfaces/SmeupDataTable.html +2 -2
- package/docs/interfaces/SmeupDataTree.html +2 -2
- package/docs/interfaces/SmeupFeedback.html +2 -2
- package/docs/interfaces/SmeupLayout.html +2 -2
- package/docs/interfaces/SmeupLayoutField.html +2 -2
- package/docs/interfaces/SmeupLayoutSection.html +2 -2
- package/docs/interfaces/SmeupMessage.html +2 -2
- package/docs/interfaces/SmeupSch.html +3 -3
- package/docs/interfaces/SmeupSchComponent.html +2 -2
- package/docs/interfaces/SmeupSchSection.html +2 -2
- package/docs/interfaces/SmeupSetup.html +2 -2
- package/docs/interfaces/SmeupStyle.html +2 -2
- package/docs/interfaces/SmeupStyleOptions.html +2 -2
- package/docs/interfaces/SmeupVariable.html +2 -2
- package/docs/interfaces/UpdateResult.html +2 -2
- package/docs/types/SmeupDataCellInputSettingsKeys.html +1 -1
- package/docs/types/SmeupDataCellInputSettingsValue.html +1 -1
- package/docs/types/SmeupDataCellShapes.html +1 -1
- package/docs/types/SmeupMessageGravity.html +1 -1
- package/docs/types/SmeupSetupBase.html +1 -1
- package/docs/types/SmeupVariableType.html +1 -1
- package/docs/variables/DEFAULT_TTL.html +1 -1
- package/docs/variables/LOGGER.html +1 -1
- package/docs/variables/SMEUP_ACTION_TYPE.html +1 -1
- package/docs/variables/SMEUP_DATA_CELL_INPUT_SETTINGS_KEYS.html +1 -1
- package/docs/variables/SMEUP_MESSAGE_GRAVITY.html +1 -1
- package/docs/variables/SMEUP_MESSAGE_MODE.html +1 -1
- package/docs/variables/SMEUP_VARIABLE_TYPE.html +1 -1
- package/docs/variables/SmeupDataCellShapes.html +1 -1
- package/lib/caller/executeFun.d.ts +3 -2
- package/lib/caller/executeFun.d.ts.map +1 -0
- package/lib/caller/executeFun.js +9 -6
- package/lib/caller/executeFun.js.map +1 -1
- package/lib/caller/microExecutorServiceCaller.d.ts +2 -1
- package/lib/caller/microExecutorServiceCaller.d.ts.map +1 -0
- package/lib/caller/microExecutorServiceCaller.js +13 -7
- package/lib/caller/microExecutorServiceCaller.js.map +1 -1
- package/lib/caller/serviceCaller.d.ts +3 -28
- package/lib/caller/serviceCaller.d.ts.map +1 -0
- package/lib/caller/serviceCaller.js +74 -84
- package/lib/caller/serviceCaller.js.map +1 -1
- package/lib/configuration/configuration.d.ts +2 -1
- package/lib/configuration/configuration.d.ts.map +1 -0
- package/lib/configuration/configuration.js +28 -20
- package/lib/configuration/configuration.js.map +1 -1
- package/lib/entrypoint/restapi/executeFunPayloadValidator.d.ts +1 -0
- package/lib/entrypoint/restapi/executeFunPayloadValidator.d.ts.map +1 -0
- package/lib/entrypoint/restapi/executeFunPayloadValidator.js +5 -3
- package/lib/entrypoint/restapi/executeFunPayloadValidator.js.map +1 -1
- package/lib/entrypoint/restapi/index.d.ts +1 -0
- package/lib/entrypoint/restapi/index.d.ts.map +1 -0
- package/lib/entrypoint/restapi/index.js +4 -2
- package/lib/entrypoint/restapi/index.js.map +1 -1
- package/lib/entrypoint/restapi/restapi.d.ts +2 -1
- package/lib/entrypoint/restapi/restapi.d.ts.map +1 -0
- package/lib/entrypoint/restapi/restapi.js +66 -47
- package/lib/entrypoint/restapi/restapi.js.map +1 -1
- package/lib/events/eventUtils.d.ts +1 -0
- package/lib/events/eventUtils.d.ts.map +1 -0
- package/lib/events/eventUtils.js +16 -11
- package/lib/events/eventUtils.js.map +1 -1
- package/lib/events/rabbitmq.d.ts +1 -0
- package/lib/events/rabbitmq.d.ts.map +1 -0
- package/lib/events/rabbitmq.js +26 -16
- package/lib/events/rabbitmq.js.map +1 -1
- package/lib/index.d.ts +17 -16
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +32 -16
- package/lib/index.js.map +1 -1
- package/lib/logger/logger.d.ts +1 -0
- package/lib/logger/logger.d.ts.map +1 -0
- package/lib/logger/logger.js +21 -12
- package/lib/logger/logger.js.map +1 -1
- package/lib/services/JS_00_01.d.ts +2 -1
- package/lib/services/JS_00_01.d.ts.map +1 -0
- package/lib/services/JS_00_01.js +17 -15
- package/lib/services/JS_00_01.js.map +1 -1
- package/lib/services/JS_00_02.d.ts +1 -0
- package/lib/services/JS_00_02.d.ts.map +1 -0
- package/lib/services/JS_00_02.js +3 -1
- package/lib/services/JS_00_02.js.map +1 -1
- package/lib/types/component.d.ts +1 -0
- package/lib/types/component.d.ts.map +1 -0
- package/lib/types/component.js +7 -4
- package/lib/types/component.js.map +1 -1
- package/lib/types/data-structures/smeupDataStructure.d.ts +5 -4
- package/lib/types/data-structures/smeupDataStructure.d.ts.map +1 -0
- package/lib/types/data-structures/smeupDataStructure.js +16 -12
- package/lib/types/data-structures/smeupDataStructure.js.map +1 -1
- package/lib/types/data-structures/smeupDataTable.d.ts +2 -1
- package/lib/types/data-structures/smeupDataTable.d.ts.map +1 -0
- package/lib/types/data-structures/smeupDataTable.js +4 -1
- package/lib/types/data-structures/smeupDataTable.js.map +1 -1
- package/lib/types/data-structures/smeupDataTree.d.ts +3 -2
- package/lib/types/data-structures/smeupDataTree.d.ts.map +1 -0
- package/lib/types/data-structures/smeupDataTree.js +2 -1
- package/lib/types/data-structures/smeupSch.d.ts +7 -6
- package/lib/types/data-structures/smeupSch.d.ts.map +1 -0
- package/lib/types/data-structures/smeupSch.js +5 -2
- package/lib/types/data-structures/smeupSch.js.map +1 -1
- package/lib/types/dynamism.d.ts +2 -1
- package/lib/types/dynamism.d.ts.map +1 -0
- package/lib/types/dynamism.js +7 -4
- package/lib/types/dynamism.js.map +1 -1
- package/lib/types/exceptions/application.d.ts +1 -0
- package/lib/types/exceptions/application.d.ts.map +1 -0
- package/lib/types/exceptions/application.js +5 -1
- package/lib/types/exceptions/application.js.map +1 -1
- package/lib/types/exceptions/validation.d.ts +2 -1
- package/lib/types/exceptions/validation.d.ts.map +1 -0
- package/lib/types/exceptions/validation.js +6 -2
- package/lib/types/exceptions/validation.js.map +1 -1
- package/lib/types/general.d.ts +3 -2
- package/lib/types/general.d.ts.map +1 -0
- package/lib/types/general.js +31 -15
- package/lib/types/general.js.map +1 -1
- package/lib/types/helpers.d.ts +1 -0
- package/lib/types/helpers.d.ts.map +1 -0
- package/lib/types/helpers.js +7 -4
- package/lib/types/helpers.js.map +1 -1
- package/lib/utils/batchUtils.d.ts +3 -2
- package/lib/utils/batchUtils.d.ts.map +1 -0
- package/lib/utils/batchUtils.js +23 -17
- package/lib/utils/batchUtils.js.map +1 -1
- package/lib/utils/cells.d.ts +2 -1
- package/lib/utils/cells.d.ts.map +1 -0
- package/lib/utils/cells.js +16 -7
- package/lib/utils/cells.js.map +1 -1
- package/lib/utils/dataStructureStream.d.ts +2 -1
- package/lib/utils/dataStructureStream.d.ts.map +1 -0
- package/lib/utils/dataStructureStream.js +6 -2
- package/lib/utils/dataStructureStream.js.map +1 -1
- package/lib/utils/fun.d.ts +2 -1
- package/lib/utils/fun.d.ts.map +1 -0
- package/lib/utils/fun.js +10 -5
- package/lib/utils/fun.js.map +1 -1
- package/lib/utils/path.d.ts +1 -0
- package/lib/utils/path.d.ts.map +1 -0
- package/lib/utils/path.js +12 -6
- package/lib/utils/path.js.map +1 -1
- package/lib/utils/regex.d.ts +6 -3
- package/lib/utils/regex.d.ts.map +1 -0
- package/lib/utils/regex.js +22 -18
- package/lib/utils/regex.js.map +1 -1
- package/lib/utils/smeupDataStructureWriter.d.ts +6 -5
- package/lib/utils/smeupDataStructureWriter.d.ts.map +1 -0
- package/lib/utils/smeupDataStructureWriter.js +11 -7
- package/lib/utils/smeupDataStructureWriter.js.map +1 -1
- package/package.json +8 -12
- package/tsconfig.json +18 -27
|
@@ -1,54 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* kokos-template-node
|
|
20
|
-
* lib
|
|
21
|
-
* caller
|
|
22
|
-
* serviceCaller.js
|
|
23
|
-
*
|
|
24
|
-
* src
|
|
25
|
-
* services
|
|
26
|
-
* [SOURCES_SERVICES (.ts)]
|
|
27
|
-
*
|
|
28
|
-
* dist
|
|
29
|
-
* services
|
|
30
|
-
* [COMPILED_SERVICES (.js)]
|
|
31
|
-
*/
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.serviceCaller = serviceCaller;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const ts_node_1 = require("ts-node");
|
|
10
|
+
const path_2 = require("../utils/path");
|
|
11
|
+
const smeupDataStructureWriter_1 = require("../utils/smeupDataStructureWriter");
|
|
12
|
+
const smeupDataStructure_1 = require("../types/data-structures/smeupDataStructure");
|
|
13
|
+
const logger_1 = require("../logger/logger");
|
|
14
|
+
const fun_1 = require("../utils/fun");
|
|
15
|
+
const microExecutorServiceCaller_1 = require("./microExecutorServiceCaller");
|
|
16
|
+
const configuration_1 = require("../configuration/configuration");
|
|
17
|
+
const batchUtils_1 = require("../utils/batchUtils");
|
|
18
|
+
const helpers_1 = require("../types/helpers");
|
|
32
19
|
/**
|
|
33
20
|
* Service Caller
|
|
34
|
-
* Thows ExecutionException if
|
|
35
|
-
* - service not found
|
|
36
|
-
* - method not found
|
|
37
|
-
* @param fun
|
|
38
|
-
* @param context
|
|
39
|
-
* @returns
|
|
40
|
-
* @throws ExecutionException
|
|
41
21
|
*/
|
|
42
|
-
|
|
22
|
+
async function serviceCaller(fun, context, out, version = smeupDataStructure_1.ApiVersion.V2, async = false) {
|
|
43
23
|
// setup logger context
|
|
44
24
|
const loggerContext = {
|
|
45
|
-
fun: funToString(fun),
|
|
46
|
-
sessionId: context?.user?.sessionId
|
|
47
|
-
user: context?.user?.username
|
|
48
|
-
app: context?.user?.app
|
|
25
|
+
fun: (0, fun_1.funToString)(fun),
|
|
26
|
+
sessionId: context?.user?.sessionId ?? "",
|
|
27
|
+
user: context?.user?.username ?? "",
|
|
28
|
+
app: context?.user?.app ?? "",
|
|
49
29
|
};
|
|
50
|
-
createLoggerContext(loggerContext);
|
|
51
|
-
LOGGER.info(`Execute FUN ${loggerContext.fun}`);
|
|
30
|
+
(0, logger_1.createLoggerContext)(loggerContext);
|
|
31
|
+
logger_1.LOGGER.info(`Execute FUN ${loggerContext.fun}`);
|
|
52
32
|
// check alias
|
|
53
33
|
if (context?.app?.registry?.aliases?.[fun.service]) {
|
|
54
34
|
fun.service = context.app.registry.aliases[fun.service];
|
|
@@ -57,75 +37,85 @@ export async function serviceCaller(fun, context, out, version = ApiVersion.V2,
|
|
|
57
37
|
let handler = context?.app?.registry?.services?.[fun.service];
|
|
58
38
|
const defaultHandler = context?.app?.registry?.defaultHandler;
|
|
59
39
|
if (!handler) {
|
|
60
|
-
handler = defaultHandler ?? globalConfiguration.microExecutorId;
|
|
40
|
+
handler = defaultHandler ?? configuration_1.globalConfiguration.microExecutorId;
|
|
61
41
|
}
|
|
62
|
-
if (handler && handler !== globalConfiguration.microExecutorId) {
|
|
42
|
+
if (handler && handler !== configuration_1.globalConfiguration.microExecutorId) {
|
|
63
43
|
// dispatch to external service
|
|
64
|
-
await dispatch(handler, fun, context, out, async);
|
|
44
|
+
await (0, microExecutorServiceCaller_1.dispatch)(handler, fun, context, out, async);
|
|
65
45
|
}
|
|
66
46
|
else {
|
|
67
47
|
// handle internally
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
servicePath =
|
|
48
|
+
let servicePath;
|
|
49
|
+
if (process.env.NODE_ENV && process.env.NODE_ENV === "PRODUCTION") {
|
|
50
|
+
// production: load compiled JS
|
|
51
|
+
servicePath = path_1.default.join((0, path_2.getProjectRoot)(), "lib", "services", `${fun.service}.js`);
|
|
72
52
|
}
|
|
73
|
-
else
|
|
74
|
-
|
|
75
|
-
|
|
53
|
+
else {
|
|
54
|
+
// development/test: load TS source
|
|
55
|
+
// register ts-node so require() can load .ts files
|
|
56
|
+
(0, ts_node_1.register)({ transpileOnly: true });
|
|
57
|
+
servicePath = path_1.default.join((0, path_2.getProjectRoot)(), "src", "services", `${fun.service}.ts`);
|
|
76
58
|
}
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
// normalize path
|
|
60
|
+
servicePath = path_1.default.resolve(servicePath);
|
|
61
|
+
if (!(0, fs_1.existsSync)(servicePath)) {
|
|
62
|
+
const msg = `Service file not found: ${servicePath}`;
|
|
63
|
+
const writer = new smeupDataStructureWriter_1.SmeupDataStructureWriter(out, version);
|
|
64
|
+
writer.writeDataStructureInitialization(fun);
|
|
65
|
+
writer.writeMessage({
|
|
66
|
+
gravity: smeupDataStructure_1.SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
67
|
+
mode: smeupDataStructure_1.SMEUP_MESSAGE_MODE.PN,
|
|
68
|
+
message: msg,
|
|
69
|
+
});
|
|
70
|
+
writer.writeDataStructureFinalization(fun);
|
|
71
|
+
(0, logger_1.clearLoggerContext)();
|
|
72
|
+
return;
|
|
79
73
|
}
|
|
80
|
-
|
|
81
|
-
let serviceModule;
|
|
82
|
-
const writer = new SmeupDataStructureWriter(out, version);
|
|
74
|
+
const writer = new smeupDataStructureWriter_1.SmeupDataStructureWriter(out, version);
|
|
83
75
|
writer.writeDataStructureInitialization(fun);
|
|
84
76
|
try {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
77
|
+
const serviceModule = require(servicePath);
|
|
78
|
+
const method = serviceModule.default.methods[fun.function ?? ""];
|
|
79
|
+
if (!method) {
|
|
80
|
+
writer.writeMessage({
|
|
81
|
+
gravity: smeupDataStructure_1.SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
82
|
+
mode: smeupDataStructure_1.SMEUP_MESSAGE_MODE.PN,
|
|
83
|
+
message: `Method "${fun.function ?? ""}" not found for service "${fun.service}"`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
90
87
|
try {
|
|
91
88
|
if (async) {
|
|
92
|
-
trackFun(globalConfiguration.microExecutorId, context, fun, FunStatus.RUNNING);
|
|
89
|
+
(0, batchUtils_1.trackFun)(configuration_1.globalConfiguration.microExecutorId, context, fun, helpers_1.FunStatus.RUNNING);
|
|
93
90
|
}
|
|
94
|
-
await
|
|
91
|
+
await method(fun, context, writer);
|
|
95
92
|
if (async) {
|
|
96
|
-
trackFun(globalConfiguration.microExecutorId, context, fun, FunStatus.COMPLETED);
|
|
93
|
+
(0, batchUtils_1.trackFun)(configuration_1.globalConfiguration.microExecutorId, context, fun, helpers_1.FunStatus.COMPLETED);
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
96
|
catch (error) {
|
|
100
|
-
LOGGER.error(error);
|
|
97
|
+
logger_1.LOGGER.error(error);
|
|
101
98
|
if (async) {
|
|
102
|
-
trackFun(globalConfiguration.microExecutorId, context, fun, FunStatus.FAILED, error);
|
|
99
|
+
(0, batchUtils_1.trackFun)(configuration_1.globalConfiguration.microExecutorId, context, fun, helpers_1.FunStatus.FAILED, error);
|
|
103
100
|
}
|
|
104
101
|
writer.writeMessage({
|
|
105
|
-
gravity: SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
106
|
-
mode: SMEUP_MESSAGE_MODE.PN,
|
|
102
|
+
gravity: smeupDataStructure_1.SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
103
|
+
mode: smeupDataStructure_1.SMEUP_MESSAGE_MODE.PN,
|
|
107
104
|
message: error.message,
|
|
108
105
|
});
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
|
-
else {
|
|
112
|
-
writer.writeMessage({
|
|
113
|
-
gravity: SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
114
|
-
mode: SMEUP_MESSAGE_MODE.PN,
|
|
115
|
-
message: `Method "${fun.function ? fun.function : ""}" not found for service "${fun.service}"`,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
108
|
}
|
|
119
109
|
catch (error) {
|
|
120
|
-
LOGGER.error(error);
|
|
110
|
+
logger_1.LOGGER.error(error);
|
|
121
111
|
writer.writeMessage({
|
|
122
|
-
gravity: SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
123
|
-
mode: SMEUP_MESSAGE_MODE.PN,
|
|
124
|
-
message: `
|
|
112
|
+
gravity: smeupDataStructure_1.SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
113
|
+
mode: smeupDataStructure_1.SMEUP_MESSAGE_MODE.PN,
|
|
114
|
+
message: `Failed to load service "${fun.service}": ${error.message}`,
|
|
125
115
|
});
|
|
126
116
|
}
|
|
127
117
|
writer.writeDataStructureFinalization(fun);
|
|
128
118
|
}
|
|
129
|
-
clearLoggerContext();
|
|
119
|
+
(0, logger_1.clearLoggerContext)();
|
|
130
120
|
}
|
|
131
121
|
//# sourceMappingURL=serviceCaller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceCaller.js","sourceRoot":"","sources":["../../src/caller/serviceCaller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serviceCaller.js","sourceRoot":"","sources":["../../src/caller/serviceCaller.ts"],"names":[],"mappings":";;;;;AA2BA,sCA8IC;AAzKD,gDAAwB;AACxB,2BAAgC;AAChC,qCAAmC;AAEnC,wCAA+C;AAC/C,gFAA6E;AAE7E,oFAIqD;AACrD,6CAK0B;AAC1B,sCAA2C;AAC3C,6EAAwD;AACxD,kEAAqE;AACrE,oDAA+C;AAC/C,8CAA6C;AAE7C;;GAEG;AACI,KAAK,UAAU,aAAa,CACjC,GAAQ,EACR,OAAyB,EACzB,GAAoB,EACpB,UAAsB,+BAAU,CAAC,EAAE,EACnC,QAAiB,KAAK;IAEtB,uBAAuB;IACvB,MAAM,aAAa,GAAkB;QACnC,GAAG,EAAE,IAAA,iBAAW,EAAC,GAAG,CAAC;QACrB,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE;QACzC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,EAAE;QACnC,GAAG,EAAE,OAAO,EAAE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K,CAAC,OAAO,EAAE;aACrE,CAAC,CAAC;QACL,CAAC;QAED,MAAM,CAAC,8BAA8B,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED,IAAA,2BAAkB,GAAE,CAAC;AACvB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentDatabaseDataSource, MicroExecutorConfiguration } from "../types/general
|
|
1
|
+
import { DocumentDatabaseDataSource, MicroExecutorConfiguration } from "../types/general";
|
|
2
2
|
export declare const globalConfiguration: {
|
|
3
3
|
microExecutorId: string;
|
|
4
4
|
documentDBDataSource: DocumentDatabaseDataSource;
|
|
@@ -11,3 +11,4 @@ export declare const globalConfiguration: {
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function init<T extends MicroExecutorConfiguration>(microExecutorId: string, defatultConfigurationClass: T): T;
|
|
13
13
|
export declare function getStandardDocumentDBDataSource(): DocumentDatabaseDataSource;
|
|
14
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAQ1F,eAAO,MAAM,mBAAmB,EAAE;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,0BAA0B,CAAC;CAIlD,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,0BAA0B,EACvD,eAAe,EAAE,MAAM,EACvB,0BAA0B,EAAE,CAAC,GAC5B,CAAC,CAsBH;AAED,wBAAgB,+BAA+B,IAAI,0BAA0B,CAS5E"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.globalConfiguration = void 0;
|
|
7
|
+
exports.init = init;
|
|
8
|
+
exports.getStandardDocumentDBDataSource = getStandardDocumentDBDataSource;
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
13
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
14
|
+
dotenv_1.default.config();
|
|
15
|
+
const baseDir = path_1.default.join(os_1.default.homedir(), "etc", "kokos");
|
|
8
16
|
const DATA_DOCUMENT_DB_DATASOURCE_ID = '_data_document_db';
|
|
9
|
-
|
|
17
|
+
exports.globalConfiguration = {
|
|
10
18
|
microExecutorId: "me-node-example",
|
|
11
19
|
documentDBDataSource: getStandardDocumentDBDataSource(),
|
|
12
20
|
};
|
|
@@ -16,27 +24,27 @@ export const globalConfiguration = {
|
|
|
16
24
|
* @param defatultConfigurationClass
|
|
17
25
|
* @returns
|
|
18
26
|
*/
|
|
19
|
-
|
|
20
|
-
const microExecutorBaseDir =
|
|
21
|
-
const microExecutorConfigFilePath =
|
|
27
|
+
function init(microExecutorId, defatultConfigurationClass) {
|
|
28
|
+
const microExecutorBaseDir = path_1.default.join(baseDir, microExecutorId);
|
|
29
|
+
const microExecutorConfigFilePath = path_1.default.join(microExecutorBaseDir, microExecutorId + ".yaml");
|
|
22
30
|
// create dir if not exists
|
|
23
|
-
if (!
|
|
24
|
-
|
|
31
|
+
if (!fs_1.default.existsSync(microExecutorBaseDir)) {
|
|
32
|
+
fs_1.default.mkdirSync(microExecutorBaseDir, { recursive: true });
|
|
25
33
|
}
|
|
26
34
|
// create config file if not exists
|
|
27
|
-
if (!
|
|
28
|
-
const yamlData =
|
|
29
|
-
|
|
35
|
+
if (!fs_1.default.existsSync(microExecutorConfigFilePath)) {
|
|
36
|
+
const yamlData = js_yaml_1.default.dump(defatultConfigurationClass);
|
|
37
|
+
fs_1.default.writeFileSync(microExecutorConfigFilePath, yamlData, "utf8");
|
|
30
38
|
}
|
|
31
39
|
// load configuration
|
|
32
|
-
const yamlData =
|
|
33
|
-
const yamlObject =
|
|
40
|
+
const yamlData = fs_1.default.readFileSync(microExecutorConfigFilePath, "utf8");
|
|
41
|
+
const yamlObject = js_yaml_1.default.load(yamlData);
|
|
34
42
|
const configuration = { ...defatultConfigurationClass, ...yamlObject };
|
|
35
43
|
// set global configuration
|
|
36
|
-
globalConfiguration.microExecutorId = microExecutorId;
|
|
44
|
+
exports.globalConfiguration.microExecutorId = microExecutorId;
|
|
37
45
|
return configuration;
|
|
38
46
|
}
|
|
39
|
-
|
|
47
|
+
function getStandardDocumentDBDataSource() {
|
|
40
48
|
const ds = {
|
|
41
49
|
id: DATA_DOCUMENT_DB_DATASOURCE_ID,
|
|
42
50
|
description: 'Data standard document database',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../src/configuration/configuration.ts"],"names":[],"mappings":";;;;;;AA0BA,oBAyBC;AAED,0EASC;AA9DD,gDAAwB;AACxB,4CAAoB;AACpB,4CAAoB;AACpB,sDAA2B;AAE3B,oDAA4B;AAE5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,OAAO,GAAW,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAChE,MAAM,8BAA8B,GAAG,mBAAmB,CAAC;AAE9C,QAAA,mBAAmB,GAG5B;IACF,eAAe,EAAE,iBAAiB;IAClC,oBAAoB,EAAE,+BAA+B,EAAE;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AE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeFunPayloadValidator.d.ts","sourceRoot":"","sources":["../../../src/entrypoint/restapi/executeFunPayloadValidator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,0HA+HrC,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeFunPayloadValidator = void 0;
|
|
4
|
+
const express_validator_1 = require("express-validator");
|
|
5
|
+
exports.executeFunPayloadValidator = (0, express_validator_1.checkSchema)({
|
|
4
6
|
fun: {
|
|
5
7
|
in: ["body"],
|
|
6
8
|
isObject: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeFunPayloadValidator.js","sourceRoot":"","sources":["../../../src/entrypoint/restapi/executeFunPayloadValidator.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"executeFunPayloadValidator.js","sourceRoot":"","sources":["../../../src/entrypoint/restapi/executeFunPayloadValidator.ts"],"names":[],"mappings":";;;AAAA,yDAAgD;AAEnC,QAAA,0BAA0B,GAAG,IAAA,+BAAW,EAAC;IACpD,GAAG,EAAE;QACH,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,uBAAuB;KACtC;IACD,eAAe,EAAE;QACf,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,4BAA4B;KAC3C;IACD,aAAa,EAAE;QACb,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,0BAA0B;KACzC;IACD,cAAc,EAAE;QACd,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,QAAQ,EAAE,IAAI;QACd,YAAY,EAA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C;IACD,sBAAsB,EAAE;QACtB,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,4BAA4B;KAC3C;IACD,uBAAuB,EAAE;QACvB,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,6BAA6B;KAC5C;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entrypoint/restapi/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const restapi_1 = require("./restapi");
|
|
4
|
+
(0, restapi_1.startServer)("me-node-example");
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entrypoint/restapi/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entrypoint/restapi/index.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AAExC,IAAA,qBAAW,EAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { MicroExecutorConfiguration } from "../../types/general
|
|
1
|
+
import { MicroExecutorConfiguration } from "../../types/general";
|
|
2
2
|
export declare function startServer(microExecutorId: string): void;
|
|
3
3
|
export declare function startServerWithCustomConfig<T extends MicroExecutorConfiguration>(microExecutorId: string, defaultConfigurationClass: T, callback?: (configuration: T) => void): void;
|
|
4
|
+
//# sourceMappingURL=restapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restapi.d.ts","sourceRoot":"","sources":["../../../src/entrypoint/restapi/restapi.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC;AAwB7B,wBAAgB,WAAW,CAAC,eAAe,EAAE,MAAM,QAUlD;AAED,wBAAgB,2BAA2B,CACzC,CAAC,SAAS,0BAA0B,EAEpC,eAAe,EAAE,MAAM,EACvB,yBAAyB,EAAE,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,KAAK,IAAI,QA6MtC"}
|
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.startServer = startServer;
|
|
7
|
+
exports.startServerWithCustomConfig = startServerWithCustomConfig;
|
|
8
|
+
const express_1 = __importDefault(require("express"));
|
|
9
|
+
const body_parser_1 = __importDefault(require("body-parser"));
|
|
10
|
+
const serviceCaller_1 = require("../../caller/serviceCaller");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
const stream_1 = __importDefault(require("stream"));
|
|
13
|
+
const smeupDataStructure_1 = require("../../types/data-structures/smeupDataStructure");
|
|
14
|
+
const configuration_1 = require("../../configuration/configuration");
|
|
15
|
+
const logger_1 = require("../../logger/logger");
|
|
16
|
+
const express_validator_1 = require("express-validator");
|
|
17
|
+
const executeFunPayloadValidator_1 = require("./executeFunPayloadValidator");
|
|
18
|
+
const validation_1 = require("../../types/exceptions/validation");
|
|
19
|
+
const smeupDataStructureWriter_1 = require("../../utils/smeupDataStructureWriter");
|
|
20
|
+
const crypto_1 = require("crypto");
|
|
21
|
+
function startServer(microExecutorId) {
|
|
19
22
|
startServerWithCustomConfig(microExecutorId, {
|
|
20
23
|
server: {
|
|
21
24
|
port: 8011,
|
|
22
25
|
},
|
|
23
26
|
logger: {
|
|
24
|
-
format: Format.TXT,
|
|
25
|
-
level: Level.DEBUG,
|
|
27
|
+
format: logger_1.Format.TXT,
|
|
28
|
+
level: logger_1.Level.DEBUG,
|
|
26
29
|
},
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
function startServerWithCustomConfig(microExecutorId, defaultConfigurationClass, callback) {
|
|
30
33
|
// load config
|
|
31
|
-
const configuration = init(microExecutorId, defaultConfigurationClass);
|
|
34
|
+
const configuration = (0, configuration_1.init)(microExecutorId, defaultConfigurationClass);
|
|
32
35
|
if (callback) {
|
|
33
36
|
// call callback
|
|
34
37
|
callback(configuration);
|
|
35
38
|
}
|
|
36
|
-
configureLogger(configuration.logger?.level, configuration.logger?.format);
|
|
39
|
+
(0, logger_1.configureLogger)(configuration.logger?.level, configuration.logger?.format);
|
|
37
40
|
// create server
|
|
38
|
-
const app =
|
|
41
|
+
const app = (0, express_1.default)();
|
|
39
42
|
// body parse middleware
|
|
40
|
-
app.use(
|
|
43
|
+
app.use(body_parser_1.default.json());
|
|
41
44
|
// swagger
|
|
42
|
-
const swaggerPath = normalize(`${__dirname}/../../../swagger`);
|
|
43
|
-
app.use("/swagger",
|
|
45
|
+
const swaggerPath = (0, path_1.normalize)(`${__dirname}/../../../swagger`);
|
|
46
|
+
app.use("/swagger", express_1.default.static(swaggerPath));
|
|
44
47
|
// docs
|
|
45
|
-
const docsPath = normalize(`${__dirname}/../../../docs`);
|
|
46
|
-
app.use("/docs",
|
|
48
|
+
const docsPath = (0, path_1.normalize)(`${__dirname}/../../../docs`);
|
|
49
|
+
app.use("/docs", express_1.default.static(docsPath));
|
|
47
50
|
/**
|
|
48
51
|
* REST API Entrypoint
|
|
49
52
|
*/
|
|
@@ -53,23 +56,23 @@ export function startServerWithCustomConfig(microExecutorId, defaultConfiguratio
|
|
|
53
56
|
/**
|
|
54
57
|
* /executeFun API
|
|
55
58
|
*/
|
|
56
|
-
app.use("/api/:version/executeFun", validationMiddleware(executeFunPayloadValidator), (req, res, next) => {
|
|
59
|
+
app.use("/api/:version/executeFun", validationMiddleware(executeFunPayloadValidator_1.executeFunPayloadValidator), (req, res, next) => {
|
|
57
60
|
// get version
|
|
58
|
-
const version = ApiVersion.V2;
|
|
61
|
+
const version = smeupDataStructure_1.ApiVersion.V2;
|
|
59
62
|
// get body
|
|
60
63
|
const { fun, context } = req.body;
|
|
61
64
|
// set status
|
|
62
65
|
res.status(200);
|
|
63
66
|
res.setHeader("Content-Type", "application/json");
|
|
64
67
|
// create stream
|
|
65
|
-
const out = new
|
|
68
|
+
const out = new stream_1.default.Writable({
|
|
66
69
|
write(chunk, encoding, callback) {
|
|
67
70
|
res.write(chunk, encoding);
|
|
68
71
|
callback();
|
|
69
72
|
},
|
|
70
73
|
});
|
|
71
74
|
// call service caller
|
|
72
|
-
serviceCaller(fun, context, out, version)
|
|
75
|
+
(0, serviceCaller_1.serviceCaller)(fun, context, out, version)
|
|
73
76
|
.then(() => {
|
|
74
77
|
res.end();
|
|
75
78
|
})
|
|
@@ -80,22 +83,22 @@ export function startServerWithCustomConfig(microExecutorId, defaultConfiguratio
|
|
|
80
83
|
/**
|
|
81
84
|
* /executeBatchFun API
|
|
82
85
|
*/
|
|
83
|
-
app.use("/api/:version/executeBatchFun", validationMiddleware(executeFunPayloadValidator), (req, res, next) => {
|
|
86
|
+
app.use("/api/:version/executeBatchFun", validationMiddleware(executeFunPayloadValidator_1.executeFunPayloadValidator), (req, res, next) => {
|
|
84
87
|
// get version
|
|
85
|
-
const version = ApiVersion.V2;
|
|
88
|
+
const version = smeupDataStructure_1.ApiVersion.V2;
|
|
86
89
|
// get body
|
|
87
90
|
const { fun, context } = req.body;
|
|
88
91
|
// set status
|
|
89
92
|
res.status(200);
|
|
90
93
|
res.setHeader("Content-Type", "application/json");
|
|
91
94
|
// create stream
|
|
92
|
-
const out = new
|
|
95
|
+
const out = new stream_1.default.Writable({
|
|
93
96
|
write(chunk, encoding, callback) {
|
|
94
97
|
res.write(chunk, encoding);
|
|
95
98
|
callback();
|
|
96
99
|
},
|
|
97
100
|
});
|
|
98
|
-
const batchJobId = context?.batchContext?.batchJobId ?? randomUUID();
|
|
101
|
+
const batchJobId = context?.batchContext?.batchJobId ?? (0, crypto_1.randomUUID)();
|
|
99
102
|
const scheduledJobId = context?.batchContext?.scheduledJobId ?? undefined;
|
|
100
103
|
const progress = context?.batchContext?.progress ?? 0;
|
|
101
104
|
context.batchContext = {
|
|
@@ -104,11 +107,11 @@ export function startServerWithCustomConfig(microExecutorId, defaultConfiguratio
|
|
|
104
107
|
progress: progress,
|
|
105
108
|
};
|
|
106
109
|
// fire and forget
|
|
107
|
-
serviceCaller(fun, context, out, version, true);
|
|
108
|
-
const writer = new SmeupDataStructureWriter(out, version);
|
|
110
|
+
(0, serviceCaller_1.serviceCaller)(fun, context, out, version, true);
|
|
111
|
+
const writer = new smeupDataStructureWriter_1.SmeupDataStructureWriter(out, version);
|
|
109
112
|
writer.writeMessage({
|
|
110
|
-
gravity: SMEUP_MESSAGE_GRAVITY.INFO,
|
|
111
|
-
mode: SMEUP_MESSAGE_MODE.TN,
|
|
113
|
+
gravity: smeupDataStructure_1.SMEUP_MESSAGE_GRAVITY.INFO,
|
|
114
|
+
mode: smeupDataStructure_1.SMEUP_MESSAGE_MODE.TN,
|
|
112
115
|
message: `Batch job started with id: ` + batchJobId,
|
|
113
116
|
});
|
|
114
117
|
writer.writeDataStructureFinalization(fun);
|
|
@@ -133,12 +136,28 @@ export function startServerWithCustomConfig(microExecutorId, defaultConfiguratio
|
|
|
133
136
|
status: "ok",
|
|
134
137
|
});
|
|
135
138
|
});
|
|
139
|
+
/**
|
|
140
|
+
* /livez API
|
|
141
|
+
*/
|
|
142
|
+
app.use("/api/v1/livez", async (req, res) => {
|
|
143
|
+
res.status(200).send({
|
|
144
|
+
status: "ok",
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* /readyz API
|
|
149
|
+
*/
|
|
150
|
+
app.use("/api/v1/readyz", async (req, res) => {
|
|
151
|
+
res.status(200).send({
|
|
152
|
+
status: "ok",
|
|
153
|
+
});
|
|
154
|
+
});
|
|
136
155
|
// error middleware
|
|
137
156
|
app.use(errorMiddleware);
|
|
138
157
|
// start server
|
|
139
158
|
const PORT = configuration.server.port || 3000;
|
|
140
159
|
app.listen(PORT, () => {
|
|
141
|
-
LOGGER.info(`App listening on the port ${PORT}`);
|
|
160
|
+
logger_1.LOGGER.info(`App listening on the port ${PORT}`);
|
|
142
161
|
});
|
|
143
162
|
/**
|
|
144
163
|
* MIDDLEWARES
|
|
@@ -148,13 +167,13 @@ export function startServerWithCustomConfig(microExecutorId, defaultConfiguratio
|
|
|
148
167
|
for (const validator of validators) {
|
|
149
168
|
await validator.run(req);
|
|
150
169
|
}
|
|
151
|
-
const errors = validationResult(req);
|
|
170
|
+
const errors = (0, express_validator_1.validationResult)(req);
|
|
152
171
|
if (!errors.isEmpty()) {
|
|
153
172
|
const message = errors
|
|
154
173
|
.array()
|
|
155
174
|
.map((error) => error.msg)
|
|
156
175
|
.join(", ");
|
|
157
|
-
next(new ValidationException(message));
|
|
176
|
+
next(new validation_1.ValidationException(message));
|
|
158
177
|
}
|
|
159
178
|
next();
|
|
160
179
|
};
|
|
@@ -169,13 +188,13 @@ export function startServerWithCustomConfig(microExecutorId, defaultConfiguratio
|
|
|
169
188
|
function errorMiddleware(error, _request, response, _next) {
|
|
170
189
|
const status = error.status || 500;
|
|
171
190
|
const message = error.message || "Something went wrong";
|
|
172
|
-
LOGGER.error(error);
|
|
191
|
+
logger_1.LOGGER.error(error);
|
|
173
192
|
response.status(status).json({
|
|
174
193
|
messages: [
|
|
175
194
|
{
|
|
176
|
-
gravity: SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
195
|
+
gravity: smeupDataStructure_1.SMEUP_MESSAGE_GRAVITY.ERROR,
|
|
177
196
|
message: message,
|
|
178
|
-
mode: SMEUP_MESSAGE_MODE.PN,
|
|
197
|
+
mode: smeupDataStructure_1.SMEUP_MESSAGE_MODE.PN,
|
|
179
198
|
},
|
|
180
199
|
],
|
|
181
200
|
});
|