@xrystal/core 3.19.1 → 3.19.2

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.19.1",
4
+ "version": "3.19.2",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -25,9 +25,10 @@ export interface IConfig {
25
25
  cwd: string;
26
26
  env: string;
27
27
  }
28
+ export interface IConfigsService extends IConfig {
29
+ }
28
30
  export default class ConfigsService implements IService {
29
31
  #private;
30
- private config;
31
32
  readonly publicFolderName: string;
32
33
  readonly kafkaLogsTopic: string;
33
34
  constructor({ systemService }: {
@@ -2,19 +2,18 @@ import path from 'node:path';
2
2
  import { Constants } from '../../utils';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  export default class ConfigsService {
5
- config;
6
5
  publicFolderName = Constants.publicFolderName;
7
6
  kafkaLogsTopic = Constants.kafkaLogsTopic;
8
7
  #systemService;
8
+ #config;
9
9
  constructor({ systemService }) {
10
10
  this.#systemService = systemService;
11
- return new Proxy(this, {
11
+ const proxy = new Proxy(this, {
12
12
  get: (target, prop) => {
13
- if (prop in target)
14
- return target[prop];
15
- return target.config[prop];
13
+ return target[prop] || target.config?.[prop];
16
14
  }
17
15
  });
16
+ return proxy;
18
17
  }
19
18
  load = async ({}) => {
20
19
  const cwd = process.cwd();
@@ -25,7 +24,7 @@ export default class ConfigsService {
25
24
  : path.resolve(tmp.configs.rootFolderPath, extendConfigs);
26
25
  const fileUrl = pathToFileURL(fullPath).href;
27
26
  const modulePromise = import(fileUrl);
28
- this.config = {
27
+ this.#config = {
29
28
  worker: process.env.WORKER === 'true' ? true : false || false,
30
29
  nodeEnv: process.env.NODE_ENV,
31
30
  debug: process.env.SYSTEM_LOGGER_LAYER,
@@ -53,8 +52,8 @@ export default class ConfigsService {
53
52
  try {
54
53
  const moduleData = await modulePromise;
55
54
  const importedConfigs = moduleData?.default || moduleData?.configs || moduleData || {};
56
- this.config = {
57
- ...this.config,
55
+ this.#config = {
56
+ ...this.#config,
58
57
  ...(typeof importedConfigs === 'object' ? importedConfigs : {})
59
58
  };
60
59
  }
@@ -64,15 +63,15 @@ export default class ConfigsService {
64
63
  };
65
64
  setConfig(newConfigs) {
66
65
  const mergedData = {
67
- ...this.config,
66
+ ...this.#config,
68
67
  ...newConfigs
69
68
  };
70
- this.config = Object.freeze(mergedData);
69
+ this.#config = Object.freeze(mergedData);
71
70
  }
72
71
  _(key) {
73
- return this.config[key];
72
+ return this.#config[key];
74
73
  }
75
74
  get all() {
76
- return this.config;
75
+ return this.#config;
77
76
  }
78
77
  }