vortez 5.0.0-dev.18 → 5.0.0-dev.19

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.
Files changed (66) hide show
  1. package/.gitignore +9 -4
  2. package/README.md +681 -176
  3. package/build/Vortez.d.ts +1 -0
  4. package/build/Vortez.js +1 -0
  5. package/build/Vortez.js.map +1 -1
  6. package/build/server/Response.d.ts +1 -1
  7. package/build/server/Response.js +1 -1
  8. package/build/server/Response.js.map +1 -1
  9. package/build/server/Server.d.ts +4 -4
  10. package/build/server/Server.js +5 -5
  11. package/build/server/Server.js.map +1 -1
  12. package/build/server/ServerDebug.d.ts +10 -1
  13. package/build/server/ServerDebug.js +85 -17
  14. package/build/server/ServerDebug.js.map +1 -1
  15. package/build/server/config/Config.d.ts +274 -47
  16. package/build/server/config/Config.js +68 -47
  17. package/build/server/config/Config.js.map +1 -1
  18. package/build/server/config/{ConfigLoader.d.ts → Loader.d.ts} +4 -5
  19. package/build/server/config/{ConfigLoader.js → Loader.js} +7 -10
  20. package/build/server/config/Loader.js.map +1 -0
  21. package/build/server/router/Router.d.ts +87 -30
  22. package/build/server/router/Router.js +110 -48
  23. package/build/server/router/Router.js.map +1 -1
  24. package/build/server/router/algorithm/Algorithm.d.ts +39 -0
  25. package/build/server/router/algorithm/Algorithm.js +20 -0
  26. package/build/server/router/algorithm/Algorithm.js.map +1 -0
  27. package/build/server/router/algorithm/FIFO.d.ts +15 -0
  28. package/build/server/router/algorithm/FIFO.js +24 -0
  29. package/build/server/router/algorithm/FIFO.js.map +1 -0
  30. package/build/server/router/algorithm/Tree.d.ts +38 -0
  31. package/build/server/router/algorithm/Tree.js +126 -0
  32. package/build/server/router/algorithm/Tree.js.map +1 -0
  33. package/build/server/router/middleware/WsMiddleware.js +1 -1
  34. package/build/server/router/middleware/WsMiddleware.js.map +1 -1
  35. package/build/utilities/Flatten.d.ts +56 -0
  36. package/build/utilities/Flatten.js +59 -0
  37. package/build/utilities/Flatten.js.map +1 -0
  38. package/build/utilities/Utilities.d.ts +7 -58
  39. package/build/utilities/Utilities.js +8 -33
  40. package/build/utilities/Utilities.js.map +1 -1
  41. package/build/utilities/schema/Introspection.d.ts +24 -0
  42. package/build/utilities/schema/Introspection.js +87 -0
  43. package/build/utilities/schema/Introspection.js.map +1 -0
  44. package/build/utilities/schema/JSONSchema.d.ts +68 -0
  45. package/build/utilities/schema/JSONSchema.js +13 -0
  46. package/build/utilities/schema/JSONSchema.js.map +1 -0
  47. package/build/utilities/schema/Schema.d.ts +253 -0
  48. package/build/utilities/schema/Schema.js +241 -0
  49. package/build/utilities/schema/Schema.js.map +1 -0
  50. package/build/utilities/schema/SchemaError.d.ts +10 -0
  51. package/build/utilities/schema/SchemaError.js +13 -0
  52. package/build/utilities/schema/SchemaError.js.map +1 -0
  53. package/build/utilities/schema/Validator.d.ts +94 -0
  54. package/build/utilities/schema/Validator.js +246 -0
  55. package/build/utilities/schema/Validator.js.map +1 -0
  56. package/package.json +1 -1
  57. package/tests/config/config.js +233 -0
  58. package/tests/router.js +596 -0
  59. package/tests/schema/schema.js +368 -0
  60. package/tests/test.env +0 -0
  61. package/tests/test.js +3 -3
  62. package/build/server/config/ConfigLoader.js.map +0 -1
  63. package/build/server/config/ConfigValidator.d.ts +0 -71
  64. package/build/server/config/ConfigValidator.js +0 -131
  65. package/build/server/config/ConfigValidator.js.map +0 -1
  66. package/examples/in-docs.js +0 -96
@@ -1,55 +1,282 @@
1
- /**
2
- * @author NetFeez <netfeez.dev@gmail.com>
3
- * @description add the config manager to the Vortez.
4
- * @license Apache-2.0
5
- */
6
- import LoggerManager from "../LoggerManager.js";
7
- import _ConfigLoader from "./ConfigLoader.js";
8
- import _ConfigValidator from "./ConfigValidator.js";
9
- export { ConfigLoader } from "./ConfigLoader.js";
10
- export { ConfigValidator } from "./ConfigValidator.js";
11
- export declare class Config implements Config.Main {
12
- static readonly DEFAULT: Config.Main;
13
- templates: Config.Templates;
14
- host: string;
15
- port: number;
16
- logger: LoggerManager;
17
- ssl: Config.SSLOptions | null;
18
- constructor(options?: Config.options);
19
- get showAll(): boolean;
20
- set showAll(value: boolean);
1
+ import { Schema, Flatten } from "../../utilities/Utilities.js";
2
+ import _Loader from "./Loader.js";
3
+ export declare const SCHEMA_LOGGER_PROP: Schema<{
4
+ readonly show: {
5
+ readonly type: "boolean";
6
+ readonly default: true;
7
+ };
8
+ readonly save: {
9
+ readonly type: "boolean";
10
+ readonly default: true;
11
+ };
12
+ }>;
13
+ export declare const SCHEMA_LOGGER: Schema<{
14
+ readonly showAll: {
15
+ readonly type: "boolean";
16
+ readonly default: false;
17
+ };
18
+ readonly server: {
19
+ readonly type: "object";
20
+ readonly default: {};
21
+ readonly schema: {
22
+ readonly show: {
23
+ readonly type: "boolean";
24
+ readonly default: true;
25
+ };
26
+ readonly save: {
27
+ readonly type: "boolean";
28
+ readonly default: true;
29
+ };
30
+ };
31
+ };
32
+ readonly request: {
33
+ readonly type: "object";
34
+ readonly default: {};
35
+ readonly schema: {
36
+ readonly show: {
37
+ readonly type: "boolean";
38
+ readonly default: true;
39
+ };
40
+ readonly save: {
41
+ readonly type: "boolean";
42
+ readonly default: true;
43
+ };
44
+ };
45
+ };
46
+ readonly response: {
47
+ readonly type: "object";
48
+ readonly default: {};
49
+ readonly schema: {
50
+ readonly show: {
51
+ readonly type: "boolean";
52
+ readonly default: true;
53
+ };
54
+ readonly save: {
55
+ readonly type: "boolean";
56
+ readonly default: true;
57
+ };
58
+ };
59
+ };
60
+ readonly websocket: {
61
+ readonly type: "object";
62
+ readonly default: {};
63
+ readonly schema: {
64
+ readonly show: {
65
+ readonly type: "boolean";
66
+ readonly default: true;
67
+ };
68
+ readonly save: {
69
+ readonly type: "boolean";
70
+ readonly default: true;
71
+ };
72
+ };
73
+ };
74
+ }>;
75
+ export declare const SCHEMA_SSL: Schema<{
76
+ readonly cert: {
77
+ readonly type: "string";
78
+ readonly required: true;
79
+ };
80
+ readonly key: {
81
+ readonly type: "string";
82
+ readonly required: true;
83
+ };
84
+ readonly port: {
85
+ readonly type: "number";
86
+ readonly default: 443;
87
+ readonly minimum: 0;
88
+ readonly maximum: 65535;
89
+ };
90
+ }>;
91
+ export declare const SCHEMA_TEMPLATES: Schema<{
92
+ readonly folder: {
93
+ readonly type: "string";
94
+ readonly default: "./global/Template/Folder.vhtml";
95
+ };
96
+ readonly error: {
97
+ readonly type: "string";
98
+ readonly default: "./global/Template/Error.vhtml";
99
+ };
100
+ }>;
101
+ export declare const SCHEMA_ROUTING: Schema<{
102
+ readonly algorithm: {
103
+ readonly type: "string";
104
+ readonly enum: readonly ["FIFO", "Tree"];
105
+ readonly default: "FIFO";
106
+ };
107
+ }>;
108
+ export declare const SCHEMA_HANDLER: Schema<{
109
+ readonly host: {
110
+ readonly type: "string";
111
+ readonly default: "localhost";
112
+ };
113
+ readonly port: {
114
+ readonly type: "number";
115
+ readonly default: 80;
116
+ readonly minimum: 0;
117
+ readonly maximum: 65535;
118
+ };
119
+ readonly ssl: {
120
+ readonly type: "object";
121
+ readonly nullable: true;
122
+ readonly default: null;
123
+ readonly schema: {
124
+ readonly cert: {
125
+ readonly type: "string";
126
+ readonly required: true;
127
+ };
128
+ readonly key: {
129
+ readonly type: "string";
130
+ readonly required: true;
131
+ };
132
+ readonly port: {
133
+ readonly type: "number";
134
+ readonly default: 443;
135
+ readonly minimum: 0;
136
+ readonly maximum: 65535;
137
+ };
138
+ };
139
+ };
140
+ readonly routing: {
141
+ readonly type: "object";
142
+ readonly default: {
143
+ readonly algorithm: "FIFO";
144
+ };
145
+ readonly schema: {
146
+ readonly algorithm: {
147
+ readonly type: "string";
148
+ readonly enum: readonly ["FIFO", "Tree"];
149
+ readonly default: "FIFO";
150
+ };
151
+ };
152
+ };
153
+ readonly templates: {
154
+ readonly type: "object";
155
+ readonly default: {
156
+ readonly folder: "./global/Template/Folder.vhtml";
157
+ readonly error: "./global/Template/Error.vhtml";
158
+ };
159
+ readonly schema: {
160
+ readonly folder: {
161
+ readonly type: "string";
162
+ readonly default: "./global/Template/Folder.vhtml";
163
+ };
164
+ readonly error: {
165
+ readonly type: "string";
166
+ readonly default: "./global/Template/Error.vhtml";
167
+ };
168
+ };
169
+ };
170
+ readonly logger: {
171
+ readonly type: "object";
172
+ readonly default: {
173
+ readonly showAll: false;
174
+ readonly server: {
175
+ readonly show: true;
176
+ readonly save: true;
177
+ };
178
+ readonly request: {
179
+ readonly show: true;
180
+ readonly save: true;
181
+ };
182
+ readonly response: {
183
+ readonly show: true;
184
+ readonly save: true;
185
+ };
186
+ readonly websocket: {
187
+ readonly show: true;
188
+ readonly save: true;
189
+ };
190
+ };
191
+ readonly schema: {
192
+ readonly showAll: {
193
+ readonly type: "boolean";
194
+ readonly default: false;
195
+ };
196
+ readonly server: {
197
+ readonly type: "object";
198
+ readonly default: {};
199
+ readonly schema: {
200
+ readonly show: {
201
+ readonly type: "boolean";
202
+ readonly default: true;
203
+ };
204
+ readonly save: {
205
+ readonly type: "boolean";
206
+ readonly default: true;
207
+ };
208
+ };
209
+ };
210
+ readonly request: {
211
+ readonly type: "object";
212
+ readonly default: {};
213
+ readonly schema: {
214
+ readonly show: {
215
+ readonly type: "boolean";
216
+ readonly default: true;
217
+ };
218
+ readonly save: {
219
+ readonly type: "boolean";
220
+ readonly default: true;
221
+ };
222
+ };
223
+ };
224
+ readonly response: {
225
+ readonly type: "object";
226
+ readonly default: {};
227
+ readonly schema: {
228
+ readonly show: {
229
+ readonly type: "boolean";
230
+ readonly default: true;
231
+ };
232
+ readonly save: {
233
+ readonly type: "boolean";
234
+ readonly default: true;
235
+ };
236
+ };
237
+ };
238
+ readonly websocket: {
239
+ readonly type: "object";
240
+ readonly default: {};
241
+ readonly schema: {
242
+ readonly show: {
243
+ readonly type: "boolean";
244
+ readonly default: true;
245
+ };
246
+ readonly save: {
247
+ readonly type: "boolean";
248
+ readonly default: true;
249
+ };
250
+ };
251
+ };
252
+ };
253
+ };
254
+ }>;
255
+ export type SCHEMA_HANDLER = typeof SCHEMA_HANDLER;
256
+ export declare class Config {
257
+ data: Config.data;
258
+ protected props: Config.props;
259
+ constructor(data: Config.toProcess);
21
260
  /**
22
- * Converts the config to a JSON string.
23
- * @returns The JSON string.
261
+ * Gets a config property by its path.
262
+ * @param path - The path to the config property.
263
+ * @returns The value of the config property at the specified path.
24
264
  */
25
- toJson(): string;
265
+ get<T extends keyof Config.props>(path: T): Config.props[T];
266
+ set<T extends keyof Config.props>(path: T, value: Config.props[T]): void;
26
267
  /**
27
- * Get the default templates.
28
- * @returns The default templates.
268
+ * Saves the config to the specified path.
269
+ * @param path - The path to save the config file to.
270
+ * @returns A promise that resolves when the config is saved.
29
271
  */
30
- static defaultTemplates(): Config.Templates;
31
- }
32
- export declare namespace Config {
33
- interface Templates {
34
- folder?: string;
35
- error?: string;
36
- [key: string]: string | undefined;
37
- }
38
- type SSLOptions = {
39
- pubKey: string;
40
- privKey: string;
41
- port?: number;
42
- };
43
- interface Main {
44
- host: string;
45
- port: number;
46
- ssl: SSLOptions | null;
47
- templates: Templates;
48
- }
49
- type options = Partial<Main>;
272
+ save(path: string): Promise<void>;
273
+ /** Converts the config to a JSON string. */
274
+ toJson(): string;
50
275
  }
51
276
  export declare namespace Config {
52
- export import Loader = _ConfigLoader;
53
- export import Validator = _ConfigValidator;
277
+ export import Loader = _Loader;
278
+ type toProcess = typeof SCHEMA_HANDLER.inferToProcess;
279
+ type data = typeof SCHEMA_HANDLER.infer;
280
+ type props = Flatten.Object<Config.data>;
54
281
  }
55
282
  export default Config;
@@ -1,60 +1,81 @@
1
- /**
2
- * @author NetFeez <netfeez.dev@gmail.com>
3
- * @description add the config manager to the Vortez.
4
- * @license Apache-2.0
5
- */
6
- import Debug from "../../logger/Debug.js";
7
- import LoggerManager from "../LoggerManager.js";
8
- import Utilities from "../../utilities/Utilities.js";
9
- import _ConfigLoader from "./ConfigLoader.js";
10
- import _ConfigValidator from "./ConfigValidator.js";
11
- export { ConfigLoader } from "./ConfigLoader.js";
12
- export { ConfigValidator } from "./ConfigValidator.js";
1
+ import { Schema, Flatten } from "../../utilities/Utilities.js";
2
+ import _Loader from "./Loader.js";
3
+ export const SCHEMA_LOGGER_PROP = new Schema({
4
+ show: { type: 'boolean', default: true },
5
+ save: { type: 'boolean', default: true }
6
+ });
7
+ export const SCHEMA_LOGGER = new Schema({
8
+ showAll: { type: 'boolean', default: false },
9
+ server: { type: 'object', default: {}, schema: SCHEMA_LOGGER_PROP.schema },
10
+ request: { type: 'object', default: {}, schema: SCHEMA_LOGGER_PROP.schema },
11
+ response: { type: 'object', default: {}, schema: SCHEMA_LOGGER_PROP.schema },
12
+ websocket: { type: 'object', default: {}, schema: SCHEMA_LOGGER_PROP.schema }
13
+ });
14
+ export const SCHEMA_SSL = new Schema({
15
+ cert: { type: 'string', required: true },
16
+ key: { type: 'string', required: true },
17
+ port: { type: 'number', default: 443, minimum: 0, maximum: 65535 }
18
+ });
19
+ export const SCHEMA_TEMPLATES = new Schema({
20
+ folder: { type: 'string', default: './global/Template/Folder.vhtml' },
21
+ error: { type: 'string', default: './global/Template/Error.vhtml' }
22
+ });
23
+ export const SCHEMA_ROUTING = new Schema({
24
+ algorithm: { type: 'string', enum: ['FIFO', 'Tree'], default: 'FIFO' }
25
+ });
26
+ export const SCHEMA_HANDLER = new Schema({
27
+ host: { type: 'string', default: 'localhost' },
28
+ port: { type: 'number', default: 80, minimum: 0, maximum: 65535 },
29
+ ssl: { type: 'object', nullable: true, default: null, schema: SCHEMA_SSL.schema },
30
+ routing: { type: 'object', default: {
31
+ algorithm: 'FIFO'
32
+ }, schema: SCHEMA_ROUTING.schema },
33
+ templates: { type: 'object', default: {
34
+ folder: './global/Template/Folder.vhtml',
35
+ error: './global/Template/Error.vhtml'
36
+ }, schema: SCHEMA_TEMPLATES.schema
37
+ },
38
+ logger: { type: 'object', default: {
39
+ showAll: false,
40
+ server: { show: true, save: true },
41
+ request: { show: true, save: true },
42
+ response: { show: true, save: true },
43
+ websocket: { show: true, save: true }
44
+ }, schema: SCHEMA_LOGGER.schema }
45
+ });
13
46
  export class Config {
14
- static DEFAULT = {
15
- host: 'localhost',
16
- port: 80,
17
- ssl: null,
18
- templates: Config.defaultTemplates()
19
- };
20
- templates;
21
- host;
22
- port;
23
- logger;
24
- ssl;
25
- constructor(options = {}) {
26
- this.host = options.host ?? Config.DEFAULT.host;
27
- this.port = options.port ?? Config.DEFAULT.port;
28
- this.ssl = options.ssl ?? Config.DEFAULT.ssl;
29
- this.logger = LoggerManager.getInstance();
30
- this.templates = options.templates ?? Config.defaultTemplates();
47
+ data;
48
+ props;
49
+ constructor(data) {
50
+ this.data = SCHEMA_HANDLER.processData(data);
51
+ this.props = Flatten.object(this.data);
31
52
  }
32
- get showAll() { return Debug.showAll; }
33
- set showAll(value) { Debug.showAll = value; }
34
53
  /**
35
- * Converts the config to a JSON string.
36
- * @returns The JSON string.
54
+ * Gets a config property by its path.
55
+ * @param path - The path to the config property.
56
+ * @returns The value of the config property at the specified path.
37
57
  */
38
- toJson() {
39
- const { host, port, ssl, templates } = this;
40
- const config = { host, port, ssl, templates };
41
- const content = JSON.stringify(config, null, 4);
42
- return content;
58
+ get(path) {
59
+ return this.props[path];
60
+ }
61
+ set(path, value) {
62
+ this.props[path] = value;
63
+ this.props[path] = value;
43
64
  }
44
65
  /**
45
- * Get the default templates.
46
- * @returns The default templates.
66
+ * Saves the config to the specified path.
67
+ * @param path - The path to save the config file to.
68
+ * @returns A promise that resolves when the config is saved.
47
69
  */
48
- static defaultTemplates() {
49
- return {
50
- folder: Utilities.Path.relative('./global/Template/Folder.vhtml'),
51
- error: Utilities.Path.relative('./global/Template/Error.vhtml')
52
- };
70
+ save(path) {
71
+ this.data = Flatten.unObject(this.props);
72
+ return Config.Loader.save(path, this);
53
73
  }
74
+ /** Converts the config to a JSON string. */
75
+ toJson() { return JSON.stringify(this.data, null, 4); }
54
76
  }
55
77
  (function (Config) {
56
- Config.Loader = _ConfigLoader;
57
- Config.Validator = _ConfigValidator;
78
+ Config.Loader = _Loader;
58
79
  })(Config || (Config = {}));
59
80
  export default Config;
60
81
  //# sourceMappingURL=Config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Config.js","sourceRoot":"","sources":["../../../src/server/config/Config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,uBAAuB,CAAC;AAC1C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,OAAO,MAAM;IACR,MAAM,CAAU,OAAO,GAAgB;QAC1C,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,IAAI;QACT,SAAS,EAAE,MAAM,CAAC,gBAAgB,EAAE;KACvC,CAAC;IACK,SAAS,CAAmB;IAC5B,IAAI,CAAS;IACb,IAAI,CAAS;IACb,MAAM,CAAgB;IACtB,GAAG,CAA2B;IACrC,YAAmB,UAA0B,EAAE;QAC3C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QAChD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;IACpE,CAAC;IACD,IAAW,OAAO,KAAc,OAAO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MAAM,OAAO,MAAM;IACR,IAAI,CAAc;IACf,KAAK,CAAe;IAC9B,YAAmB,IAAsB;QACrC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACI,GAAG,CAA+B,IAAO;QAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACM,GAAG,CAA+B,IAAO,EAAE,KAAsB;QACpE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAC7B,CAAC;IACD;;;;OAIG;IACI,IAAI,CAAC,IAAY;QACpB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,4CAA4C;IACrC,MAAM,KAAa,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE;AACD,WAAiB,MAAM;IACL,aAAM,GAAG,OAAO,CAAC;AAKnC,CAAC,EANgB,MAAM,KAAN,MAAM,QAMtB;AACD,eAAe,MAAM,CAAC"}
@@ -4,14 +4,13 @@
4
4
  * @license Apache-2.0
5
5
  */
6
6
  import Config from "./Config.js";
7
- export declare class ConfigLoader {
7
+ export declare class Loader {
8
8
  /**
9
9
  * Loads the config from the given path.
10
10
  * @param path - The path to the config file.
11
- * @param defaultConfig - The default config to use if the config file does not exist.
12
11
  * @returns A promise that resolves with the loaded config.
13
12
  */
14
- static load(path: string, defaultConfig?: Config | Config.options): Promise<Config>;
13
+ static load(path: string): Promise<Config>;
15
14
  /**
16
15
  * Saves the config to the given path.
17
16
  * @param path - The path to the config file.
@@ -20,5 +19,5 @@ export declare class ConfigLoader {
20
19
  */
21
20
  static save(path: string, config: Config): Promise<void>;
22
21
  }
23
- export declare namespace ConfigLoader { }
24
- export default ConfigLoader;
22
+ export declare namespace Loader { }
23
+ export default Loader;
@@ -7,29 +7,26 @@ import { promises as FSP } from "fs";
7
7
  import Logger from "../../logger/Logger.js";
8
8
  import Config from "./Config.js";
9
9
  import Utilities from "../../utilities/Utilities.js";
10
- import { ConfigValidator } from "./ConfigValidator.js";
11
10
  const logger = new Logger({ prefix: 'Config' });
12
- export class ConfigLoader {
11
+ export class Loader {
13
12
  /**
14
13
  * Loads the config from the given path.
15
14
  * @param path - The path to the config file.
16
- * @param defaultConfig - The default config to use if the config file does not exist.
17
15
  * @returns A promise that resolves with the loaded config.
18
16
  */
19
- static async load(path, defaultConfig = {}) {
17
+ static async load(path) {
20
18
  logger.log(`loading config from &C6[${path}]`);
21
19
  if (!await Utilities.fileExists(path)) {
22
- const config = new Config(defaultConfig);
20
+ const config = new Config({});
23
21
  logger.log(`config file &C6[${path}]&R does not exist, creating it`);
24
- await ConfigLoader.save(path, config);
22
+ await Loader.save(path, config);
25
23
  logger.log(`config file &C6[${path}]&R &C2was created successfully`);
26
24
  return config;
27
25
  }
28
26
  try {
29
27
  const content = await FSP.readFile(path, 'utf8');
30
28
  const data = JSON.parse(content);
31
- const validatedConfig = ConfigValidator.validate(data);
32
- return new Config(validatedConfig);
29
+ return new Config(data);
33
30
  }
34
31
  catch (error) {
35
32
  logger.error(`config file &C6[${path}]&R &C1could not be loaded`);
@@ -49,5 +46,5 @@ export class ConfigLoader {
49
46
  await FSP.writeFile(path, content, 'utf8');
50
47
  }
51
48
  }
52
- export default ConfigLoader;
53
- //# sourceMappingURL=ConfigLoader.js.map
49
+ export default Loader;
50
+ //# sourceMappingURL=Loader.js.map
@@ -0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