@xrystal/core 3.18.8 → 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.18.8",
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 }: {
@@ -35,5 +36,6 @@ export default class ConfigsService implements IService {
35
36
  });
36
37
  load: ({}: {}) => Promise<void>;
37
38
  setConfig(newConfigs: any): void;
39
+ _<K extends keyof IConfig>(key: K): IConfig[K];
38
40
  get all(): IConfig;
39
41
  }
@@ -2,12 +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
+ const proxy = new Proxy(this, {
12
+ get: (target, prop) => {
13
+ return target[prop] || target.config?.[prop];
14
+ }
15
+ });
16
+ return proxy;
11
17
  }
12
18
  load = async ({}) => {
13
19
  const cwd = process.cwd();
@@ -18,7 +24,7 @@ export default class ConfigsService {
18
24
  : path.resolve(tmp.configs.rootFolderPath, extendConfigs);
19
25
  const fileUrl = pathToFileURL(fullPath).href;
20
26
  const modulePromise = import(fileUrl);
21
- this.config = {
27
+ this.#config = {
22
28
  worker: process.env.WORKER === 'true' ? true : false || false,
23
29
  nodeEnv: process.env.NODE_ENV,
24
30
  debug: process.env.SYSTEM_LOGGER_LAYER,
@@ -46,8 +52,8 @@ export default class ConfigsService {
46
52
  try {
47
53
  const moduleData = await modulePromise;
48
54
  const importedConfigs = moduleData?.default || moduleData?.configs || moduleData || {};
49
- this.config = {
50
- ...this.config,
55
+ this.#config = {
56
+ ...this.#config,
51
57
  ...(typeof importedConfigs === 'object' ? importedConfigs : {})
52
58
  };
53
59
  }
@@ -57,12 +63,15 @@ export default class ConfigsService {
57
63
  };
58
64
  setConfig(newConfigs) {
59
65
  const mergedData = {
60
- ...this.config,
66
+ ...this.#config,
61
67
  ...newConfigs
62
68
  };
63
- this.config = Object.freeze(mergedData);
69
+ this.#config = Object.freeze(mergedData);
70
+ }
71
+ _(key) {
72
+ return this.#config[key];
64
73
  }
65
74
  get all() {
66
- return this.config;
75
+ return this.#config;
67
76
  }
68
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,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;