@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.18.6",
4
+ "version": "3.18.8",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -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 rawConfigs = tmp?.configs || tmp?.configs || {};
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: rawConfigs.rootFolderPath || 'x',
29
+ rootFolderPath: tmp.configs.rootFolderPath || 'x',
23
30
  projectName: tmp.project.name,
24
- serviceName: rawConfigs.service,
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(rawConfigs.rootFolderPath, this.publicFolderName),
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 || rawConfigs.port || 3000,
40
+ port: Number(process.env.PORT),
34
41
  internalSecret: process.env.INTERNAL_SECRET,
35
42
  secret: process.env.SECRET,
36
- cwd: process.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 = {
@@ -1,6 +1,7 @@
1
1
  import { IService } from "../../utils";
2
2
  export default class SystemService implements IService {
3
3
  _tmp: Record<string, any>;
4
+ cwd: string;
4
5
  load: ({ tmp, }: {
5
6
  tmp: any;
6
7
  }) => Promise<void>;
@@ -1,5 +1,6 @@
1
1
  export default class SystemService {
2
2
  _tmp = {};
3
+ cwd = process.cwd();
3
4
  load = async ({ tmp, }) => {
4
5
  this._tmp = tmp;
5
6
  await this._systemLoader({});
@@ -0,0 +1 @@
1
+ export declare const configs: {};
@@ -0,0 +1 @@
1
+ export const configs = {};
package/x/tmp.yml CHANGED
@@ -7,7 +7,7 @@ configs:
7
7
 
8
8
  loaders:
9
9
  configs:
10
- envLoadPath: environments
10
+ loadPath: '@/source/utils/helpers/configs/index'
11
11
 
12
12
  loggers:
13
13
  loadPath: logs