@onlineapps/service-wrapper 2.1.44 → 2.1.45
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/package.json +3 -2
- package/src/ConfigLoader.js +3 -1
- package/src/ServiceWrapper.js +2 -1
- package/src/config.js +25 -0
- package/src/defaults.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/service-wrapper",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.45",
|
|
4
4
|
"description": "Thin orchestration layer for microservices - delegates all infrastructure concerns to specialized connectors",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"@onlineapps/conn-orch-registry": "1.1.26",
|
|
35
35
|
"@onlineapps/conn-orch-validator": "2.0.14",
|
|
36
36
|
"@onlineapps/monitoring-core": "1.0.9",
|
|
37
|
-
"@onlineapps/service-common": "1.0.6"
|
|
37
|
+
"@onlineapps/service-common": "1.0.6",
|
|
38
|
+
"@onlineapps/runtime-config": "1.0.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"express": "^5.1.0",
|
package/src/ConfigLoader.js
CHANGED
|
@@ -23,6 +23,7 @@ const fs = require('fs');
|
|
|
23
23
|
const path = require('path');
|
|
24
24
|
|
|
25
25
|
const RUNTIME_DEFAULTS = require('../config/runtime-defaults.json');
|
|
26
|
+
const runtimeCfg = require('./config');
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* CENTRAL REGISTRY: All configuration files used by business services
|
|
@@ -302,6 +303,7 @@ class ConfigLoader {
|
|
|
302
303
|
const serviceConfig = this.loadServiceConfig(basePath);
|
|
303
304
|
const operations = this.loadOperations(basePath);
|
|
304
305
|
const validationProof = this.loadValidationProof(basePath);
|
|
306
|
+
const nodeEnv = runtimeCfg.get('nodeEnv');
|
|
305
307
|
|
|
306
308
|
// Include any custom top-level sections from config.json (e.g., storage, smtp, etc.)
|
|
307
309
|
// Keep service-wrapper owned sections (service, wrapper) explicit and stable.
|
|
@@ -319,7 +321,7 @@ class ConfigLoader {
|
|
|
319
321
|
version: serviceConfig.service.version,
|
|
320
322
|
port: parseInt(serviceConfig.service.port, 10),
|
|
321
323
|
url: serviceConfig.service.url,
|
|
322
|
-
env:
|
|
324
|
+
env: nodeEnv
|
|
323
325
|
},
|
|
324
326
|
wrapper: serviceConfig.wrapper || {},
|
|
325
327
|
operations,
|
package/src/ServiceWrapper.js
CHANGED
|
@@ -22,6 +22,7 @@ const CookbookConnector = require('@onlineapps/conn-orch-cookbook');
|
|
|
22
22
|
const CacheConnector = require('@onlineapps/conn-base-cache');
|
|
23
23
|
const ErrorHandlerConnector = require('@onlineapps/conn-infra-error-handler');
|
|
24
24
|
const { ValidationOrchestrator } = require('@onlineapps/conn-orch-validator');
|
|
25
|
+
const runtimeCfg = require('./config');
|
|
25
26
|
|
|
26
27
|
const INFRA_QUEUE_OWNERS = {
|
|
27
28
|
'workflow.init': 'Gateway (api_gateway)',
|
|
@@ -1359,7 +1360,7 @@ class ServiceWrapper {
|
|
|
1359
1360
|
}
|
|
1360
1361
|
|
|
1361
1362
|
// DEBUG MODE: Run health check before workflow step
|
|
1362
|
-
if (
|
|
1363
|
+
if (runtimeCfg.get('debug') || runtimeCfg.get('nodeEnv') === 'development') {
|
|
1363
1364
|
await this._runHealthCheckBeforeWorkflowStep(message);
|
|
1364
1365
|
}
|
|
1365
1366
|
|
package/src/config.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runtime configuration schema for @onlineapps/service-wrapper.
|
|
5
|
+
*
|
|
6
|
+
* Uses @onlineapps/runtime-config for unified priority:
|
|
7
|
+
* 1. Explicit config (passed to APIs that need it)
|
|
8
|
+
* 2. Environment variable
|
|
9
|
+
* 3. Module-owned defaults (from ./defaults.js)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { createRuntimeConfig } = require('@onlineapps/runtime-config');
|
|
13
|
+
const DEFAULTS = require('./defaults');
|
|
14
|
+
|
|
15
|
+
const runtimeCfg = createRuntimeConfig({
|
|
16
|
+
defaults: DEFAULTS,
|
|
17
|
+
schema: {
|
|
18
|
+
nodeEnv: { env: 'NODE_ENV', defaultKey: 'nodeEnv' },
|
|
19
|
+
debug: { env: 'DEBUG', defaultKey: 'debug', type: 'boolean' },
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
module.exports = runtimeCfg;
|
|
24
|
+
|
|
25
|
+
|
package/src/defaults.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Module-owned defaults for @onlineapps/service-wrapper (runtime config).
|
|
5
|
+
*
|
|
6
|
+
* NOTE: This is RuntimeConfig (ENV/explicit overrides), not biz ServiceConfig (conn-config/*.json).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
nodeEnv: 'development',
|
|
11
|
+
debug: false,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|