@xrystal/core 3.18.7 → 3.19.1

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.7",
4
+ "version": "3.19.1",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -35,5 +35,6 @@ export default class ConfigsService implements IService {
35
35
  });
36
36
  load: ({}: {}) => Promise<void>;
37
37
  setConfig(newConfigs: any): void;
38
+ _<K extends keyof IConfig>(key: K): IConfig[K];
38
39
  get all(): IConfig;
39
40
  }
@@ -8,20 +8,23 @@ export default class ConfigsService {
8
8
  #systemService;
9
9
  constructor({ systemService }) {
10
10
  this.#systemService = systemService;
11
+ return new Proxy(this, {
12
+ get: (target, prop) => {
13
+ if (prop in target)
14
+ return target[prop];
15
+ return target.config[prop];
16
+ }
17
+ });
11
18
  }
12
19
  load = async ({}) => {
20
+ const cwd = process.cwd();
13
21
  const tmp = this.#systemService.tmp;
14
22
  const extendConfigs = tmp.configs.loaders.configs.loadPath;
15
- let importedModule;
16
- const cwd = process.cwd();
17
- if (extendConfigs.startsWith('@/')) {
18
- const fullPath = path.join(cwd, extendConfigs.slice(2));
19
- importedModule = await import(pathToFileURL(fullPath).href);
20
- }
21
- else {
22
- const fullPath = path.resolve(tmp.configs.rootFolderPath, extendConfigs);
23
- importedModule = await import(pathToFileURL(fullPath).href);
24
- }
23
+ const fullPath = extendConfigs.startsWith('@/')
24
+ ? path.join(process.cwd(), extendConfigs.slice(2))
25
+ : path.resolve(tmp.configs.rootFolderPath, extendConfigs);
26
+ const fileUrl = pathToFileURL(fullPath).href;
27
+ const modulePromise = import(fileUrl);
25
28
  this.config = {
26
29
  worker: process.env.WORKER === 'true' ? true : false || false,
27
30
  nodeEnv: process.env.NODE_ENV,
@@ -46,8 +49,18 @@ export default class ConfigsService {
46
49
  secret: process.env.SECRET,
47
50
  cwd,
48
51
  env: process.env.NODE_ENV,
49
- ...importedModule.configs,
50
52
  };
53
+ try {
54
+ const moduleData = await modulePromise;
55
+ const importedConfigs = moduleData?.default || moduleData?.configs || moduleData || {};
56
+ this.config = {
57
+ ...this.config,
58
+ ...(typeof importedConfigs === 'object' ? importedConfigs : {})
59
+ };
60
+ }
61
+ catch (e) {
62
+ // error
63
+ }
51
64
  };
52
65
  setConfig(newConfigs) {
53
66
  const mergedData = {
@@ -56,6 +69,9 @@ export default class ConfigsService {
56
69
  };
57
70
  this.config = Object.freeze(mergedData);
58
71
  }
72
+ _(key) {
73
+ return this.config[key];
74
+ }
59
75
  get all() {
60
76
  return this.config;
61
77
  }
@@ -155,8 +155,8 @@ export default class LoggerService {
155
155
  topic: this.kafkaLogsTopic,
156
156
  messages: [{
157
157
  value: JSON.stringify({
158
- service: this.serviceName,
159
158
  level,
159
+ service: this.serviceName,
160
160
  message,
161
161
  payload,
162
162
  code,
@@ -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({});
@@ -1,5 +1,5 @@
1
1
  import { LifetimeType } from 'awilix';
2
- declare class X {
2
+ declare class X<T = {}> {
3
3
  private container;
4
4
  private initializedNames;
5
5
  constructor();
@@ -23,5 +23,5 @@ declare class X {
23
23
  get cradle(): any;
24
24
  private isRegistered;
25
25
  }
26
- declare const _default: X;
26
+ declare const _default: X<{}>;
27
27
  export default _default;
package/x/tmp.yml CHANGED
@@ -7,7 +7,7 @@ configs:
7
7
 
8
8
  loaders:
9
9
  configs:
10
- loadPath: '@/source/utils/models/classes/configs.project.ts'
10
+ loadPath: '@/source/utils/helpers/configs/index'
11
11
 
12
12
  loggers:
13
13
  loadPath: logs