@h3ravel/shared 0.17.3 → 0.17.4

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/dist/index.cjs CHANGED
@@ -1,271 +1,241 @@
1
- "use strict";
1
+ //#region rolldown:runtime
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
8
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
20
17
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
30
22
 
31
- // src/index.ts
32
- var index_exports = {};
33
- __export(index_exports, {
34
- EnvParser: () => EnvParser,
35
- HttpContext: () => HttpContext,
36
- Logger: () => Logger,
37
- PathLoader: () => PathLoader
38
- });
39
- module.exports = __toCommonJS(index_exports);
23
+ //#endregion
24
+ let chalk = require("chalk");
25
+ chalk = __toESM(chalk);
26
+ let path = require("path");
27
+ path = __toESM(path);
40
28
 
41
- // src/Contracts/IHttp.ts
42
- var HttpContext = class _HttpContext {
43
- static {
44
- __name(this, "HttpContext");
45
- }
46
- app;
47
- request;
48
- response;
49
- constructor(app, request, response) {
50
- this.app = app;
51
- this.request = request;
52
- this.response = response;
53
- }
54
- /**
55
- * Factory method to create a new HttpContext instance from a context object.
56
- * @param ctx - Object containing app, request, and response
57
- * @returns A new HttpContext instance
58
- */
59
- static init(ctx) {
60
- return new _HttpContext(ctx.app, ctx.request, ctx.response);
61
- }
29
+ //#region src/Contracts/IHttp.ts
30
+ /**
31
+ * Represents the HTTP context for a single request lifecycle.
32
+ * Encapsulates the application instance, request, and response objects.
33
+ */
34
+ var HttpContext = class HttpContext {
35
+ constructor(app, request, response) {
36
+ this.app = app;
37
+ this.request = request;
38
+ this.response = response;
39
+ }
40
+ /**
41
+ * Factory method to create a new HttpContext instance from a context object.
42
+ * @param ctx - Object containing app, request, and response
43
+ * @returns A new HttpContext instance
44
+ */
45
+ static init(ctx) {
46
+ /**
47
+ * Return a new instance
48
+ */
49
+ return new HttpContext(ctx.app, ctx.request, ctx.response);
50
+ }
62
51
  };
63
52
 
64
- // src/Utils/EnvParser.ts
53
+ //#endregion
54
+ //#region src/Utils/EnvParser.ts
65
55
  var EnvParser = class {
66
- static {
67
- __name(this, "EnvParser");
68
- }
69
- static parse(initial) {
70
- const parsed = {
71
- ...initial
72
- };
73
- for (const key in parsed) {
74
- let value = parsed[key];
75
- parsed[key] = this.parseValue(value);
76
- }
77
- return parsed;
78
- }
79
- static parseValue(value) {
80
- if (value === null || value === void 0) return value;
81
- if (value === "true") return true;
82
- if (value === "false") return false;
83
- if (!isNaN(value) && value.trim() !== "") {
84
- return Number(value);
85
- }
86
- if (value === "null") return null;
87
- if (value === "undefined") return void 0;
88
- return value;
89
- }
56
+ static parse(initial) {
57
+ const parsed = { ...initial };
58
+ for (const key in parsed) {
59
+ let value = parsed[key];
60
+ parsed[key] = this.parseValue(value);
61
+ }
62
+ return parsed;
63
+ }
64
+ static parseValue(value) {
65
+ /**
66
+ * Null/undefined stay untouched
67
+ */
68
+ if (value === null || value === void 0) return value;
69
+ /**
70
+ * Convert string "true"/"false" to boolean
71
+ */
72
+ if (value === "true") return true;
73
+ if (value === "false") return false;
74
+ /**
75
+ * Convert string numbers to number
76
+ */
77
+ if (!isNaN(value) && value.trim() !== "") return Number(value);
78
+ /**
79
+ * Convert string "null" and "undefined"
80
+ */
81
+ if (value === "null") return null;
82
+ if (value === "undefined") return void 0;
83
+ /**
84
+ * Otherwise return as-is (string)
85
+ */
86
+ return value;
87
+ }
90
88
  };
91
89
 
92
- // src/Utils/Logger.ts
93
- var import_chalk = __toESM(require("chalk"), 1);
90
+ //#endregion
91
+ //#region src/Utils/Logger.ts
94
92
  var Logger = class {
95
- static {
96
- __name(this, "Logger");
97
- }
98
- /**
99
- * Logs the message in two columns
100
- * @param name
101
- * @param value
102
- * @returns
103
- */
104
- static twoColumnLog(name, value) {
105
- const regex = /\x1b\[\d+m/g;
106
- const width = Math.min(process.stdout.columns, 100);
107
- const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
108
- return console.log(name, import_chalk.default.gray(".".repeat(dots)), value);
109
- }
110
- /**
111
- * Wraps text with chalk
112
- *
113
- * @param txt
114
- * @param color
115
- * @returns
116
- */
117
- static textFormat(txt, color) {
118
- return String(txt).split(":").map((e, i, a) => i == 0 && a.length > 1 ? color(" " + e + ": ") : e).join("");
119
- }
120
- /**
121
- * Logs a success message
122
- *
123
- * @param msg
124
- * @param exit
125
- */
126
- static success(msg, exit = false) {
127
- console.log(import_chalk.default.green("\u2713"), this.textFormat(msg, import_chalk.default.bgGreen), "\n");
128
- if (exit) process.exit(0);
129
- }
130
- /**
131
- * Logs an informational message
132
- *
133
- * @param msg
134
- * @param exit
135
- */
136
- static info(msg, exit = false) {
137
- console.log(import_chalk.default.blue("\u2139"), this.textFormat(msg, import_chalk.default.bgBlue), "\n");
138
- if (exit) process.exit(0);
139
- }
140
- /**
141
- * Logs an error message
142
- *
143
- * @param msg
144
- * @param exit
145
- */
146
- static error(msg, exit = true) {
147
- if (msg instanceof Error) {
148
- if (msg.message) {
149
- console.error(import_chalk.default.red("\u2716"), this.textFormat("ERROR:" + msg.message, import_chalk.default.bgRed));
150
- }
151
- console.error(import_chalk.default.red(`${msg.detail ? `${msg.detail}
152
- ` : ""}${msg.stack}`), "\n");
153
- } else {
154
- console.error(import_chalk.default.red("\u2716"), this.textFormat(msg, import_chalk.default.bgRed), "\n");
155
- }
156
- if (exit) process.exit(1);
157
- }
158
- /**
159
- * Logs a success message
160
- *
161
- * @param name
162
- * @param value
163
- * @param status
164
- * @param exit
165
- */
166
- static split(name, value, status, exit = false) {
167
- status ??= "info";
168
- const color = {
169
- success: import_chalk.default.bgGreen,
170
- info: import_chalk.default.bgBlue,
171
- error: import_chalk.default.bgRed
172
- };
173
- const regex = /\x1b\[\d+m/g;
174
- const width = Math.min(process.stdout.columns, 100);
175
- const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
176
- console.log(this.textFormat(name, color[status]), import_chalk.default.gray(".".repeat(dots)), value);
177
- if (exit) process.exit(0);
178
- }
179
- /**
180
- * Terminates the process
181
- */
182
- static quiet() {
183
- process.exit(0);
184
- }
185
- /**
186
- * Parse an array formated message and logs it
187
- *
188
- * @param config
189
- * @param joiner
190
- */
191
- static parse(config, joiner = " ") {
192
- const string = config.map(([str, opt]) => {
193
- return typeof import_chalk.default[opt] === "function" ? import_chalk.default[opt](str) : str;
194
- }).join(joiner);
195
- console.log(string);
196
- }
197
- static log(config, joiner) {
198
- if (typeof config === "string") {
199
- const conf = [
200
- [
201
- config,
202
- joiner
203
- ]
204
- ];
205
- return this.parse(conf);
206
- } else if (config) {
207
- return this.parse(config, joiner);
208
- }
209
- return this;
210
- }
93
+ static twoColumnLog(name, value, log = true) {
94
+ const regex = /\x1b\[\d+m/g;
95
+ const width = Math.min(process.stdout.columns, 100);
96
+ const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
97
+ if (log) return console.log(name, chalk.default.gray(".".repeat(dots)), value);
98
+ else return [
99
+ name,
100
+ chalk.default.gray(".".repeat(dots)),
101
+ value
102
+ ];
103
+ }
104
+ /**
105
+ * Logs the message in two columns but allways passing status
106
+ *
107
+ * @param name
108
+ * @param value
109
+ * @param status
110
+ * @param exit
111
+ * @param preserveCol
112
+ */
113
+ static split(name, value, status, exit = false, preserveCol = false) {
114
+ status ??= "info";
115
+ const color = {
116
+ success: chalk.default.bgGreen,
117
+ info: chalk.default.bgBlue,
118
+ error: chalk.default.bgRed
119
+ };
120
+ const [_name, dots, val] = this.twoColumnLog(name, value, false);
121
+ console.log(this.textFormat(_name, color[status], preserveCol), dots, val);
122
+ if (exit) process.exit(0);
123
+ }
124
+ /**
125
+ * Wraps text with chalk
126
+ *
127
+ * @param txt
128
+ * @param color
129
+ * @param preserveCol
130
+ * @returns
131
+ */
132
+ static textFormat(txt, color, preserveCol = false) {
133
+ if (preserveCol) return String(txt);
134
+ return String(txt).split(":").map((e, i, a) => i == 0 && a.length > 1 ? color(" " + e + ": ") : e).join("");
135
+ }
136
+ /**
137
+ * Logs a success message
138
+ *
139
+ * @param msg
140
+ * @param exit
141
+ * @param preserveCol
142
+ */
143
+ static success(msg, exit = false, preserveCol = false) {
144
+ console.log(chalk.default.green("✓"), this.textFormat(msg, chalk.default.bgGreen, preserveCol), "\n");
145
+ if (exit) process.exit(0);
146
+ }
147
+ /**
148
+ * Logs an informational message
149
+ *
150
+ * @param msg
151
+ * @param exit
152
+ * @param preserveCol
153
+ */
154
+ static info(msg, exit = false, preserveCol = false) {
155
+ console.log(chalk.default.blue("ℹ"), this.textFormat(msg, chalk.default.bgBlue, preserveCol), "\n");
156
+ if (exit) process.exit(0);
157
+ }
158
+ /**
159
+ * Logs an error message
160
+ *
161
+ * @param msg
162
+ * @param exit
163
+ * @param preserveCol
164
+ */
165
+ static error(msg, exit = true, preserveCol = false) {
166
+ if (msg instanceof Error) {
167
+ if (msg.message) console.error(chalk.default.red("✖"), this.textFormat("ERROR:" + msg.message, chalk.default.bgRed, preserveCol));
168
+ console.error(chalk.default.red(`${msg.detail ? `${msg.detail}\n` : ""}${msg.stack}`), "\n");
169
+ } else console.error(chalk.default.red("✖"), this.textFormat(msg, chalk.default.bgRed, preserveCol), "\n");
170
+ if (exit) process.exit(1);
171
+ }
172
+ /**
173
+ * Terminates the process
174
+ */
175
+ static quiet() {
176
+ process.exit(0);
177
+ }
178
+ static parse(config, joiner = " ", log = true) {
179
+ const string = config.map(([str, opt]) => {
180
+ return typeof chalk.default[opt] === "function" ? chalk.default[opt](str) : str;
181
+ }).join(joiner);
182
+ if (log) console.log(string);
183
+ else return string;
184
+ }
185
+ static log(config, joiner) {
186
+ if (typeof config === "string") {
187
+ const conf = [[config, joiner]];
188
+ return this.parse(conf);
189
+ } else if (config) return this.parse(config, joiner);
190
+ return this;
191
+ }
211
192
  };
212
193
 
213
- // src/Utils/PathLoader.ts
214
- var import_path = __toESM(require("path"), 1);
194
+ //#endregion
195
+ //#region src/Utils/PathLoader.ts
215
196
  var PathLoader = class {
216
- static {
217
- __name(this, "PathLoader");
218
- }
219
- paths = {
220
- base: "",
221
- views: "/src/resources/views",
222
- assets: "/public/assets",
223
- routes: "/src/routes",
224
- config: "/src/config",
225
- public: "/public",
226
- storage: "/storage",
227
- database: "/src/database"
228
- };
229
- /**
230
- * Dynamically retrieves a path property from the class.
231
- * Any property ending with "Path" is accessible automatically.
232
- *
233
- * @param name - The base name of the path property
234
- * @param prefix - The base path to prefix to the path
235
- * @returns
236
- */
237
- getPath(name, prefix) {
238
- let path;
239
- if (prefix && name !== "base") {
240
- path = import_path.default.join(prefix, this.paths[name]);
241
- } else {
242
- path = this.paths[name];
243
- }
244
- path = path.replace("/src/", `/${process.env.SRC_PATH ?? "src"}/`.replace(/([^:]\/)\/+/g, "$1"));
245
- if (name === "database" && process.env.SRC_PATH && !"/src/".includes(process.env.SRC_PATH)) {
246
- return import_path.default.resolve(path.replace(process.env.SRC_PATH, ""));
247
- }
248
- return path;
249
- }
250
- /**
251
- * Programatically set the paths.
252
- *
253
- * @param name - The base name of the path property
254
- * @param path - The new path
255
- * @param base - The base path to include to the path
256
- */
257
- setPath(name, path, base) {
258
- if (base && name !== "base") {
259
- this.paths[name] = import_path.default.join(base, path);
260
- }
261
- this.paths[name] = path;
262
- }
197
+ paths = {
198
+ base: "",
199
+ views: "/src/resources/views",
200
+ assets: "/public/assets",
201
+ routes: "/src/routes",
202
+ config: "/src/config",
203
+ public: "/public",
204
+ storage: "/storage",
205
+ database: "/src/database"
206
+ };
207
+ /**
208
+ * Dynamically retrieves a path property from the class.
209
+ * Any property ending with "Path" is accessible automatically.
210
+ *
211
+ * @param name - The base name of the path property
212
+ * @param prefix - The base path to prefix to the path
213
+ * @returns
214
+ */
215
+ getPath(name, prefix) {
216
+ let path$1;
217
+ if (prefix && name !== "base") path$1 = path.default.join(prefix, this.paths[name]);
218
+ else path$1 = this.paths[name];
219
+ path$1 = path$1.replace("/src/", `/${process.env.SRC_PATH ?? "src"}/`.replace(/([^:]\/)\/+/g, "$1"));
220
+ if (name === "database" && process.env.SRC_PATH && !"/src/".includes(process.env.SRC_PATH)) return path.default.resolve(path$1.replace(process.env.SRC_PATH, ""));
221
+ return path$1;
222
+ }
223
+ /**
224
+ * Programatically set the paths.
225
+ *
226
+ * @param name - The base name of the path property
227
+ * @param path - The new path
228
+ * @param base - The base path to include to the path
229
+ */
230
+ setPath(name, path$1, base) {
231
+ if (base && name !== "base") this.paths[name] = path.default.join(base, path$1);
232
+ this.paths[name] = path$1;
233
+ }
263
234
  };
264
- // Annotate the CommonJS export names for ESM import in node:
265
- 0 && (module.exports = {
266
- EnvParser,
267
- HttpContext,
268
- Logger,
269
- PathLoader
270
- });
235
+
236
+ //#endregion
237
+ exports.EnvParser = EnvParser;
238
+ exports.HttpContext = HttpContext;
239
+ exports.Logger = Logger;
240
+ exports.PathLoader = PathLoader;
271
241
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/Contracts/IHttp.ts","../src/Utils/EnvParser.ts","../src/Utils/Logger.ts","../src/Utils/PathLoader.ts"],"sourcesContent":["export * from './Contracts/BindingsContract'\nexport * from './Contracts/IApplication'\nexport * from './Contracts/IContainer'\nexport * from './Contracts/IHttp'\nexport * from './Contracts/IRequest'\nexport * from './Contracts/IResponse'\nexport * from './Contracts/IServiceProvider'\nexport * from './Contracts/ObjContract'\nexport * from './Utils/EnvParser'\nexport * from './Utils/Logger'\nexport * from './Utils/PathLoader'\n","import type { Middleware, MiddlewareOptions } from 'h3'\n\nimport { IApplication } from './IApplication'\nimport { IRequest } from './IRequest'\nimport { IResponse } from './IResponse'\n\nexport type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'patch' | 'apiResource' | 'group' | 'route';\n\n/**\n * Interface for the Router contract, defining methods for HTTP routing.\n */\nexport interface IRouter {\n /**\n * Registers a GET route.\n * @param path - The route path.\n * @param definition - The handler function or [controller class, method] array.\n * @param name - Optional route name.\n * @param middleware - Optional middleware array.\n */\n get (\n path: string,\n definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],\n name?: string,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd>;\n\n /**\n * Registers a POST route.\n * @param path - The route path.\n * @param definition - The handler function or [controller class, method] array.\n * @param name - Optional route name.\n * @param middleware - Optional middleware array.\n */\n post (\n path: string,\n definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],\n name?: string,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd>;\n\n /**\n * Registers a PUT route.\n * @param path - The route path.\n * @param definition - The handler function or [controller class, method] array.\n * @param name - Optional route name.\n * @param middleware - Optional middleware array.\n */\n put (\n path: string,\n definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],\n name?: string,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd>;\n\n /**\n * Registers a DELETE route.\n * @param path - The route path.\n * @param definition - The handler function or [controller class, method] array.\n * @param name - Optional route name.\n * @param middleware - Optional middleware array.\n */\n delete (\n path: string,\n definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],\n name?: string,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd>;\n\n /**\n * Registers an API resource with standard CRUD routes.\n * @param path - The base path for the resource.\n * @param controller - The controller class handling the resource.\n * @param middleware - Optional middleware array.\n */\n apiResource (\n path: string,\n controller: new (app: IApplication) => IController,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd | 'name'>;\n\n /**\n * Generates a URL for a named route.\n * @param name - The name of the route.\n * @param params - Optional parameters to replace in the route path.\n * @returns The generated URL or undefined if the route is not found.\n */\n route (name: string, params?: Record<string, string>): string | undefined;\n\n\n /**\n * Set the name of the current route\n * \n * @param name \n */\n name (name: string): this\n\n /**\n * Groups routes with shared prefix or middleware.\n * @param options - Configuration for prefix or middleware.\n * @param callback - Callback function defining grouped routes.\n */\n group (options: { prefix?: string; middleware?: EventHandler[] }, callback: () => this): this;\n\n /**\n * Registers middleware for a specific path.\n * @param path - The path to apply the middleware.\n * @param handler - The middleware handler.\n * @param opts - Optional middleware options.\n */\n middleware (path: string | IMiddleware[], handler: Middleware, opts?: MiddlewareOptions): this;\n}\n\n/**\n * Represents the HTTP context for a single request lifecycle.\n * Encapsulates the application instance, request, and response objects.\n */\nexport class HttpContext {\n constructor(\n public app: IApplication,\n public request: IRequest,\n public response: IResponse\n ) { }\n\n /**\n * Factory method to create a new HttpContext instance from a context object.\n * @param ctx - Object containing app, request, and response\n * @returns A new HttpContext instance\n */\n static init (ctx: { app: IApplication; request: IRequest; response: IResponse }): HttpContext {\n /**\n * Return a new instance\n */\n return new HttpContext(ctx.app, ctx.request, ctx.response);\n }\n}\n\n\n/**\n * Type for EventHandler, representing a function that handles an H3 event.\n */\nexport type EventHandler = (ctx: HttpContext) => any\nexport type RouteEventHandler = (...args: any[]) => any\n\n/**\n * Defines the contract for all controllers.\n * Any controller implementing this must define these methods.\n */\nexport interface IController {\n show (...ctx: any[]): any\n index (...ctx: any[]): any\n store (...ctx: any[]): any\n update (...ctx: any[]): any\n destroy (...ctx: any[]): any\n}\n\n/**\n * Defines the contract for all middlewares.\n * Any middleware implementing this must define these methods.\n */\nexport interface IMiddleware {\n handle (context: HttpContext, next: () => Promise<any>): Promise<any>\n} \n","import { GenericWithNullableStringValues } from '../Contracts/ObjContract';\n\nexport class EnvParser {\n\n static parse (initial: GenericWithNullableStringValues) {\n const parsed = { ...initial }\n\n for (const key in parsed) {\n let value: any = parsed[key]\n parsed[key] = this.parseValue(value)\n }\n\n return parsed\n }\n\n static parseValue (value: any) {\n /**\n * Null/undefined stay untouched \n */\n if (value === null || value === undefined) return value;\n\n /**\n * Convert string \"true\"/\"false\" to boolean \n */\n if (value === 'true') return true;\n if (value === 'false') return false;\n\n /**\n * Convert string numbers to number \n */\n if (!isNaN(value) && value.trim() !== '') {\n return Number(value);\n }\n\n /**\n * Convert string \"null\" and \"undefined\"\n */\n if (value === 'null') return null;\n if (value === 'undefined') return undefined;\n\n /**\n * Otherwise return as-is (string)\n */\n return value;\n }\n}\n","import chalk, { type ChalkInstance } from 'chalk'\n\nexport class Logger {\n /**\n * Logs the message in two columns\n * @param name \n * @param value \n * @returns \n */\n static twoColumnLog (name: string, value: string) {\n // eslint-disable-next-line no-control-regex\n const regex = /\\x1b\\[\\d+m/g\n const width = Math.min(process.stdout.columns, 100)\n const dots = Math.max(width - name.replace(regex, '').length - value.replace(regex, '').length - 10, 0)\n return console.log(name, chalk.gray('.'.repeat(dots)), value)\n }\n\n /**\n * Wraps text with chalk\n * \n * @param txt \n * @param color \n * @returns \n */\n static textFormat (txt: any, color: (txt: string) => string) {\n return String(txt).split(':').map((e, i, a) => i == 0 && a.length > 1 ? color(' ' + e + ': ') : e).join('')\n }\n\n /**\n * Logs a success message\n * \n * @param msg \n * @param exit \n */\n static success (msg: any, exit = false) {\n console.log(chalk.green('✓'), this.textFormat(msg, chalk.bgGreen), '\\n')\n if (exit) process.exit(0)\n }\n\n /**\n * Logs an informational message\n * \n * @param msg \n * @param exit \n */\n static info (msg: any, exit = false) {\n console.log(chalk.blue('ℹ'), this.textFormat(msg, chalk.bgBlue), '\\n')\n if (exit) process.exit(0)\n }\n\n /**\n * Logs an error message\n * \n * @param msg \n * @param exit \n */\n static error (msg: string | string[] | Error & { detail?: string }, exit = true) {\n if (msg instanceof Error) {\n if (msg.message) {\n console.error(chalk.red('✖'), this.textFormat('ERROR:' + msg.message, chalk.bgRed))\n }\n console.error(chalk.red(`${msg.detail ? `${msg.detail}\\n` : ''}${msg.stack}`), '\\n')\n }\n else {\n console.error(chalk.red('✖'), this.textFormat(msg, chalk.bgRed), '\\n')\n }\n if (exit) process.exit(1)\n }\n\n /**\n * Logs a success message\n * \n * @param name \n * @param value \n * @param status \n * @param exit \n */\n static split (name: string, value: string, status?: 'success' | 'info' | 'error', exit = false) {\n status ??= 'info'\n const color = { success: chalk.bgGreen, info: chalk.bgBlue, error: chalk.bgRed }\n const regex = /\\x1b\\[\\d+m/g\n const width = Math.min(process.stdout.columns, 100)\n const dots = Math.max(width - name.replace(regex, '').length - value.replace(regex, '').length - 10, 0)\n\n console.log(this.textFormat(name, color[status]), chalk.gray('.'.repeat(dots)), value)\n if (exit) process.exit(0)\n }\n\n /**\n * Terminates the process\n */\n static quiet () {\n process.exit(0)\n }\n\n /**\n * Parse an array formated message and logs it\n * \n * @param config \n * @param joiner \n */\n static parse (config: [string, keyof ChalkInstance][], joiner = ' ') {\n const string = config.map(([str, opt]) => {\n return typeof chalk[opt] === 'function' ? (chalk as any)[opt](str) : str\n }).join(joiner)\n\n console.log(string)\n }\n\n /**\n * Ouput formater object or format the output\n * \n * @returns \n */\n static log (): typeof Logger\n static log (config: string, joiner: keyof ChalkInstance): void\n static log (config: [string, keyof ChalkInstance][], joiner?: string): void\n static log (config?: string | [string, keyof ChalkInstance][], joiner?: string): void | Logger {\n if (typeof config === 'string') {\n const conf = [[config, joiner]] as [string, keyof ChalkInstance][]\n return this.parse(conf)\n } else if (config) {\n return this.parse(config, joiner)\n }\n return this\n }\n}\n","import { IPathName } from '../Contracts/IApplication'\nimport nodepath from 'path'\n\nexport class PathLoader {\n private paths = {\n base: '',\n views: '/src/resources/views',\n assets: '/public/assets',\n routes: '/src/routes',\n config: '/src/config',\n public: '/public',\n storage: '/storage',\n database: '/src/database',\n }\n\n /**\n * Dynamically retrieves a path property from the class.\n * Any property ending with \"Path\" is accessible automatically.\n *\n * @param name - The base name of the path property\n * @param prefix - The base path to prefix to the path\n * @returns \n */\n getPath (name: IPathName, prefix?: string): string {\n let path: string;\n\n if (prefix && name !== 'base') {\n path = nodepath.join(prefix, this.paths[name])\n } else {\n path = this.paths[name]\n }\n\n path = path.replace('/src/', `/${process.env.SRC_PATH ?? 'src'}/`.replace(/([^:]\\/)\\/+/g, \"$1\"))\n\n if (name === 'database' && process.env.SRC_PATH && !'/src/'.includes(process.env.SRC_PATH)) {\n return nodepath.resolve(path.replace(process.env.SRC_PATH, ''))\n }\n\n return path\n }\n\n /**\n * Programatically set the paths.\n *\n * @param name - The base name of the path property\n * @param path - The new path\n * @param base - The base path to include to the path\n */\n setPath (name: IPathName, path: string, base?: string) {\n if (base && name !== 'base') {\n this.paths[name] = nodepath.join(base, path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C,MAAAA;IAC9B;AACA,WAAO;EACX;AACJ;;;AC7HA,kBAAqB;AAEd,IAAMK,aAAN,MAAMA;EAFb,OAEaA;;;EACDC,QAAQ;IACZC,MAAM;IACNC,OAAO;IACPC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,SAAS;IACTC,UAAU;EACd;;;;;;;;;EAUAC,QAASC,MAAiBC,QAAyB;AAC/C,QAAIC;AAEJ,QAAID,UAAUD,SAAS,QAAQ;AAC3BE,aAAOC,YAAAA,QAASC,KAAKH,QAAQ,KAAKX,MAAMU,IAAAA,CAAK;IACjD,OAAO;AACHE,aAAO,KAAKZ,MAAMU,IAAAA;IACtB;AAEAE,WAAOA,KAAKG,QAAQ,SAAS,IAAIC,QAAQC,IAAIC,YAAY,KAAA,IAASH,QAAQ,gBAAgB,IAAA,CAAA;AAE1F,QAAIL,SAAS,cAAcM,QAAQC,IAAIC,YAAY,CAAC,QAAQC,SAASH,QAAQC,IAAIC,QAAQ,GAAG;AACxF,aAAOL,YAAAA,QAASO,QAAQR,KAAKG,QAAQC,QAAQC,IAAIC,UAAU,EAAA,CAAA;IAC/D;AAEA,WAAON;EACX;;;;;;;;EASAS,QAASX,MAAiBE,MAAcX,MAAe;AACnD,QAAIA,QAAQS,SAAS,QAAQ;AACzB,WAAKV,MAAMU,IAAAA,IAAQG,YAAAA,QAASC,KAAKb,MAAMW,IAAAA;IAC3C;AAEA,SAAKZ,MAAMU,IAAAA,IAAQE;EACvB;AACJ;","names":["HttpContext","app","request","response","init","ctx","EnvParser","parse","initial","parsed","key","value","parseValue","undefined","isNaN","trim","Number","Logger","twoColumnLog","name","value","regex","width","Math","min","process","stdout","columns","dots","max","replace","length","console","log","chalk","gray","repeat","textFormat","txt","color","String","split","map","e","i","a","join","success","msg","exit","green","bgGreen","info","blue","bgBlue","error","Error","message","red","bgRed","detail","stack","status","quiet","parse","config","joiner","string","str","opt","conf","PathLoader","paths","base","views","assets","routes","config","public","storage","database","getPath","name","prefix","path","nodepath","join","replace","process","env","SRC_PATH","includes","resolve","setPath"]}
1
+ {"version":3,"file":"index.cjs","names":["app: IApplication","request: IRequest","response: IResponse","value: any","path: string","nodepath","path"],"sources":["../src/Contracts/IHttp.ts","../src/Utils/EnvParser.ts","../src/Utils/Logger.ts","../src/Utils/PathLoader.ts"],"sourcesContent":["import type { Middleware, MiddlewareOptions } from 'h3'\n\nimport { IApplication } from './IApplication'\nimport { IRequest } from './IRequest'\nimport { IResponse } from './IResponse'\n\nexport type RouterEnd = 'get' | 'delete' | 'put' | 'post' | 'patch' | 'apiResource' | 'group' | 'route';\n\n/**\n * Interface for the Router contract, defining methods for HTTP routing.\n */\nexport interface IRouter {\n /**\n * Registers a GET route.\n * @param path - The route path.\n * @param definition - The handler function or [controller class, method] array.\n * @param name - Optional route name.\n * @param middleware - Optional middleware array.\n */\n get (\n path: string,\n definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],\n name?: string,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd>;\n\n /**\n * Registers a POST route.\n * @param path - The route path.\n * @param definition - The handler function or [controller class, method] array.\n * @param name - Optional route name.\n * @param middleware - Optional middleware array.\n */\n post (\n path: string,\n definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],\n name?: string,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd>;\n\n /**\n * Registers a PUT route.\n * @param path - The route path.\n * @param definition - The handler function or [controller class, method] array.\n * @param name - Optional route name.\n * @param middleware - Optional middleware array.\n */\n put (\n path: string,\n definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],\n name?: string,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd>;\n\n /**\n * Registers a DELETE route.\n * @param path - The route path.\n * @param definition - The handler function or [controller class, method] array.\n * @param name - Optional route name.\n * @param middleware - Optional middleware array.\n */\n delete (\n path: string,\n definition: EventHandler | [(new (...args: any[]) => IController), methodName: string],\n name?: string,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd>;\n\n /**\n * Registers an API resource with standard CRUD routes.\n * @param path - The base path for the resource.\n * @param controller - The controller class handling the resource.\n * @param middleware - Optional middleware array.\n */\n apiResource (\n path: string,\n controller: new (app: IApplication) => IController,\n middleware?: IMiddleware[]\n ): Omit<this, RouterEnd | 'name'>;\n\n /**\n * Generates a URL for a named route.\n * @param name - The name of the route.\n * @param params - Optional parameters to replace in the route path.\n * @returns The generated URL or undefined if the route is not found.\n */\n route (name: string, params?: Record<string, string>): string | undefined;\n\n\n /**\n * Set the name of the current route\n * \n * @param name \n */\n name (name: string): this\n\n /**\n * Groups routes with shared prefix or middleware.\n * @param options - Configuration for prefix or middleware.\n * @param callback - Callback function defining grouped routes.\n */\n group (options: { prefix?: string; middleware?: EventHandler[] }, callback: () => this): this;\n\n /**\n * Registers middleware for a specific path.\n * @param path - The path to apply the middleware.\n * @param handler - The middleware handler.\n * @param opts - Optional middleware options.\n */\n middleware (path: string | IMiddleware[], handler: Middleware, opts?: MiddlewareOptions): this;\n}\n\n/**\n * Represents the HTTP context for a single request lifecycle.\n * Encapsulates the application instance, request, and response objects.\n */\nexport class HttpContext {\n constructor(\n public app: IApplication,\n public request: IRequest,\n public response: IResponse\n ) { }\n\n /**\n * Factory method to create a new HttpContext instance from a context object.\n * @param ctx - Object containing app, request, and response\n * @returns A new HttpContext instance\n */\n static init (ctx: { app: IApplication; request: IRequest; response: IResponse }): HttpContext {\n /**\n * Return a new instance\n */\n return new HttpContext(ctx.app, ctx.request, ctx.response);\n }\n}\n\n\n/**\n * Type for EventHandler, representing a function that handles an H3 event.\n */\nexport type EventHandler = (ctx: HttpContext) => any\nexport type RouteEventHandler = (...args: any[]) => any\n\n/**\n * Defines the contract for all controllers.\n * Any controller implementing this must define these methods.\n */\nexport interface IController {\n show (...ctx: any[]): any\n index (...ctx: any[]): any\n store (...ctx: any[]): any\n update (...ctx: any[]): any\n destroy (...ctx: any[]): any\n}\n\n/**\n * Defines the contract for all middlewares.\n * Any middleware implementing this must define these methods.\n */\nexport interface IMiddleware {\n handle (context: HttpContext, next: () => Promise<any>): Promise<any>\n} \n","import { GenericWithNullableStringValues } from '../Contracts/ObjContract';\n\nexport class EnvParser {\n\n static parse (initial: GenericWithNullableStringValues) {\n const parsed = { ...initial }\n\n for (const key in parsed) {\n let value: any = parsed[key]\n parsed[key] = this.parseValue(value)\n }\n\n return parsed\n }\n\n static parseValue (value: any) {\n /**\n * Null/undefined stay untouched \n */\n if (value === null || value === undefined) return value;\n\n /**\n * Convert string \"true\"/\"false\" to boolean \n */\n if (value === 'true') return true;\n if (value === 'false') return false;\n\n /**\n * Convert string numbers to number \n */\n if (!isNaN(value) && value.trim() !== '') {\n return Number(value);\n }\n\n /**\n * Convert string \"null\" and \"undefined\"\n */\n if (value === 'null') return null;\n if (value === 'undefined') return undefined;\n\n /**\n * Otherwise return as-is (string)\n */\n return value;\n }\n}\n","import chalk, { type ChalkInstance } from 'chalk'\n\nexport class Logger {\n /**\n * Logs the message in two columns\n * @param name \n * @param value \n * @param log If set to false, array of [name, dots, value] output will be returned and not logged \n * @returns \n */\n static twoColumnLog (name: string, value: string, log?: true): void\n static twoColumnLog (name: string, value: string, log?: false): [string, string, string]\n static twoColumnLog (name: string, value: string, log = true): [string, string, string] | void {\n // eslint-disable-next-line no-control-regex\n const regex = /\\x1b\\[\\d+m/g\n const width = Math.min(process.stdout.columns, 100)\n const dots = Math.max(width - name.replace(regex, '').length - value.replace(regex, '').length - 10, 0)\n\n if (log) return console.log(name, chalk.gray('.'.repeat(dots)), value)\n else return [name, chalk.gray('.'.repeat(dots)), value]\n }\n\n /**\n * Logs the message in two columns but allways passing status\n * \n * @param name \n * @param value \n * @param status \n * @param exit \n * @param preserveCol \n */\n static split (name: string, value: string, status?: 'success' | 'info' | 'error', exit = false, preserveCol = false) {\n status ??= 'info'\n const color = { success: chalk.bgGreen, info: chalk.bgBlue, error: chalk.bgRed }\n\n const [_name, dots, val] = this.twoColumnLog(name, value, false)\n\n console.log(this.textFormat(_name, color[status], preserveCol), dots, val)\n\n if (exit) process.exit(0)\n }\n\n /**\n * Wraps text with chalk\n * \n * @param txt \n * @param color \n * @param preserveCol \n * @returns \n */\n static textFormat (txt: any, color: (txt: string) => string, preserveCol = false) {\n if (preserveCol) return String(txt)\n return String(txt).split(':').map((e, i, a) => i == 0 && a.length > 1 ? color(' ' + e + ': ') : e).join('')\n }\n\n /**\n * Logs a success message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static success (msg: any, exit = false, preserveCol = false) {\n console.log(chalk.green('✓'), this.textFormat(msg, chalk.bgGreen, preserveCol), '\\n')\n if (exit) process.exit(0)\n }\n\n /**\n * Logs an informational message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static info (msg: any, exit = false, preserveCol = false) {\n console.log(chalk.blue('ℹ'), this.textFormat(msg, chalk.bgBlue, preserveCol), '\\n')\n if (exit) process.exit(0)\n }\n\n /**\n * Logs an error message\n * \n * @param msg \n * @param exit \n * @param preserveCol \n */\n static error (msg: string | string[] | Error & { detail?: string }, exit = true, preserveCol = false) {\n if (msg instanceof Error) {\n if (msg.message) {\n console.error(chalk.red('✖'), this.textFormat('ERROR:' + msg.message, chalk.bgRed, preserveCol))\n }\n console.error(chalk.red(`${msg.detail ? `${msg.detail}\\n` : ''}${msg.stack}`), '\\n')\n }\n else {\n console.error(chalk.red('✖'), this.textFormat(msg, chalk.bgRed, preserveCol), '\\n')\n }\n if (exit) process.exit(1)\n }\n\n /**\n * Terminates the process\n */\n static quiet () {\n process.exit(0)\n }\n\n /**\n * Parse an array formated message and logs it\n * \n * @param config \n * @param joiner \n * @param log If set to false, string output will be returned and not logged \n */\n static parse (config: [string, keyof ChalkInstance][], joiner?: string, log?: true): void\n static parse (config: [string, keyof ChalkInstance][], joiner?: string, log?: false): string\n static parse (config: [string, keyof ChalkInstance][], joiner = ' ', log = true): string | void {\n const string = config.map(([str, opt]) => {\n return typeof chalk[opt] === 'function' ? (chalk as any)[opt](str) : str\n }).join(joiner)\n\n if (log) console.log(string)\n else return string\n }\n\n /**\n * Ouput formater object or format the output\n * \n * @returns \n */\n static log (): typeof Logger\n static log (config: string, joiner: keyof ChalkInstance): void\n static log (config: [string, keyof ChalkInstance][], joiner?: string): void\n static log (config?: string | [string, keyof ChalkInstance][], joiner?: string): void | Logger {\n if (typeof config === 'string') {\n const conf = [[config, joiner]] as [string, keyof ChalkInstance][]\n return this.parse(conf)\n } else if (config) {\n return this.parse(config, joiner)\n }\n return this\n }\n}\n","import { IPathName } from '../Contracts/IApplication'\nimport nodepath from 'path'\n\nexport class PathLoader {\n private paths = {\n base: '',\n views: '/src/resources/views',\n assets: '/public/assets',\n routes: '/src/routes',\n config: '/src/config',\n public: '/public',\n storage: '/storage',\n database: '/src/database',\n }\n\n /**\n * Dynamically retrieves a path property from the class.\n * Any property ending with \"Path\" is accessible automatically.\n *\n * @param name - The base name of the path property\n * @param prefix - The base path to prefix to the path\n * @returns \n */\n getPath (name: IPathName, prefix?: string): string {\n let path: string;\n\n if (prefix && name !== 'base') {\n path = nodepath.join(prefix, this.paths[name])\n } else {\n path = this.paths[name]\n }\n\n path = path.replace('/src/', `/${process.env.SRC_PATH ?? 'src'}/`.replace(/([^:]\\/)\\/+/g, \"$1\"))\n\n if (name === 'database' && process.env.SRC_PATH && !'/src/'.includes(process.env.SRC_PATH)) {\n return nodepath.resolve(path.replace(process.env.SRC_PATH, ''))\n }\n\n return path\n }\n\n /**\n * Programatically set the paths.\n *\n * @param name - The base name of the path property\n * @param path - The new path\n * @param base - The base path to include to the path\n */\n setPath (name: IPathName, path: string, base?: string) {\n if (base && name !== 'base') {\n this.paths[name] = nodepath.join(base, path)\n }\n\n this.paths[name] = path\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,IAAa,cAAb,MAAa,YAAY;CACrB,YACI,AAAOA,KACP,AAAOC,SACP,AAAOC,UACT;EAHS;EACA;EACA;;;;;;;CAQX,OAAO,KAAM,KAAiF;;;;AAI1F,SA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