@xrystal/core 3.18.6 → 3.18.8
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 +1 -1
- package/source/loader/configs/index.d.ts +1 -1
- package/source/loader/configs/index.js +26 -8
- package/source/loader/system/index.d.ts +1 -0
- package/source/loader/system/index.js +1 -0
- package/source/utils/helpers/configs/index.d.ts +1 -0
- package/source/utils/helpers/configs/index.js +1 -0
- package/x/tmp.yml +1 -1
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@ export default class ConfigsService implements IService {
|
|
|
33
33
|
constructor({ systemService }: {
|
|
34
34
|
systemService: SystemService;
|
|
35
35
|
});
|
|
36
|
-
load: ({}: {}) => void
|
|
36
|
+
load: ({}: {}) => Promise<void>;
|
|
37
37
|
setConfig(newConfigs: any): void;
|
|
38
38
|
get all(): IConfig;
|
|
39
39
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { Constants } from '../../utils';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
3
4
|
export default class ConfigsService {
|
|
4
5
|
config;
|
|
5
6
|
publicFolderName = Constants.publicFolderName;
|
|
@@ -8,9 +9,15 @@ export default class ConfigsService {
|
|
|
8
9
|
constructor({ systemService }) {
|
|
9
10
|
this.#systemService = systemService;
|
|
10
11
|
}
|
|
11
|
-
load = ({}) => {
|
|
12
|
+
load = async ({}) => {
|
|
13
|
+
const cwd = process.cwd();
|
|
12
14
|
const tmp = this.#systemService.tmp;
|
|
13
|
-
const
|
|
15
|
+
const extendConfigs = tmp.configs.loaders.configs.loadPath;
|
|
16
|
+
const fullPath = extendConfigs.startsWith('@/')
|
|
17
|
+
? path.join(process.cwd(), extendConfigs.slice(2))
|
|
18
|
+
: path.resolve(tmp.configs.rootFolderPath, extendConfigs);
|
|
19
|
+
const fileUrl = pathToFileURL(fullPath).href;
|
|
20
|
+
const modulePromise = import(fileUrl);
|
|
14
21
|
this.config = {
|
|
15
22
|
worker: process.env.WORKER === 'true' ? true : false || false,
|
|
16
23
|
nodeEnv: process.env.NODE_ENV,
|
|
@@ -19,23 +26,34 @@ export default class ConfigsService {
|
|
|
19
26
|
httpsfileEncoding: process.env.ENCODING || 'utf8',
|
|
20
27
|
httpsCertfile: process.env.HTTPS_CERT_FILE,
|
|
21
28
|
httpsKeyfile: process.env.HTTPS_KEY_FILE,
|
|
22
|
-
rootFolderPath:
|
|
29
|
+
rootFolderPath: tmp.configs.rootFolderPath || 'x',
|
|
23
30
|
projectName: tmp.project.name,
|
|
24
|
-
serviceName:
|
|
31
|
+
serviceName: tmp.configs.service,
|
|
25
32
|
projectNamePrefixEnv: process.env.PROJECT_NAME_PREFIX || '',
|
|
26
33
|
projectNameEnv: process.env.PROJECT_NAME || '',
|
|
27
34
|
projectNameSuffixEnv: process.env.PROJECT_NAME_SUFFIX || '',
|
|
28
|
-
systemStaticFolderPath: path.resolve(
|
|
35
|
+
systemStaticFolderPath: path.resolve(tmp.configs.rootFolderPath, this.publicFolderName),
|
|
29
36
|
systemLoggerLayer: process.env.SYSTEM_LOGGER_LAYER,
|
|
30
37
|
kafkaBrokers: process.env?.KAFKA_BROKERS,
|
|
31
38
|
kafkaLogsTopic: this.kafkaLogsTopic,
|
|
32
39
|
baseApiUri: process.env.HTTPS === 'true' ? process.env.SYSTEM_HTTPS_BASE_API_URI : process.env.SYSTEM_BASE_API_URI,
|
|
33
|
-
port: process.env.PORT
|
|
40
|
+
port: Number(process.env.PORT),
|
|
34
41
|
internalSecret: process.env.INTERNAL_SECRET,
|
|
35
42
|
secret: process.env.SECRET,
|
|
36
|
-
cwd
|
|
37
|
-
env: process.env.NODE_ENV
|
|
43
|
+
cwd,
|
|
44
|
+
env: process.env.NODE_ENV,
|
|
38
45
|
};
|
|
46
|
+
try {
|
|
47
|
+
const moduleData = await modulePromise;
|
|
48
|
+
const importedConfigs = moduleData?.default || moduleData?.configs || moduleData || {};
|
|
49
|
+
this.config = {
|
|
50
|
+
...this.config,
|
|
51
|
+
...(typeof importedConfigs === 'object' ? importedConfigs : {})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
// error
|
|
56
|
+
}
|
|
39
57
|
};
|
|
40
58
|
setConfig(newConfigs) {
|
|
41
59
|
const mergedData = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const configs: {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const configs = {};
|