topsyde-utils 1.0.3 → 1.0.5

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 (42) hide show
  1. package/README.md +12 -3
  2. package/dist/application.d.ts +1 -1
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +1035 -74
  5. package/dist/index.js.map +22 -1
  6. package/dist/initializable.d.ts +2 -2
  7. package/dist/router/index.d.ts +3 -3
  8. package/dist/router/router.d.ts +2 -5
  9. package/dist/router/router.internal.d.ts +2 -1
  10. package/dist/router/routes.d.ts +4 -4
  11. package/dist/server/controller.d.ts +60 -0
  12. package/dist/server/index.d.ts +2 -0
  13. package/dist/types.d.ts +5 -0
  14. package/package.json +5 -3
  15. package/dist/application.js +0 -32
  16. package/dist/application.js.map +0 -1
  17. package/dist/consts.js +0 -34
  18. package/dist/consts.js.map +0 -1
  19. package/dist/enums.js +0 -19
  20. package/dist/enums.js.map +0 -1
  21. package/dist/errors.js +0 -46
  22. package/dist/errors.js.map +0 -1
  23. package/dist/guards.js +0 -42
  24. package/dist/guards.js.map +0 -1
  25. package/dist/initializable.js +0 -309
  26. package/dist/initializable.js.map +0 -1
  27. package/dist/lib.js +0 -460
  28. package/dist/lib.js.map +0 -1
  29. package/dist/router/index.js +0 -30
  30. package/dist/router/index.js.map +0 -1
  31. package/dist/router/router.internal.js +0 -47
  32. package/dist/router/router.internal.js.map +0 -1
  33. package/dist/router/router.js +0 -43
  34. package/dist/router/router.js.map +0 -1
  35. package/dist/router/routes.js +0 -10
  36. package/dist/router/routes.js.map +0 -1
  37. package/dist/singleton.js +0 -142
  38. package/dist/singleton.js.map +0 -1
  39. package/dist/throwable.js +0 -70
  40. package/dist/throwable.js.map +0 -1
  41. package/dist/types.js +0 -3
  42. package/dist/types.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1,22 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,6DAA6D;AAC7D,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,qBAAqB;AAErB,yBAAyB;AACzB,6CAAuD;AAA9C,2HAAA,OAAO,OAAe;AAC/B,mCAA6C;AAApC,iHAAA,OAAO,OAAU;AAC1B,iDAA2D;AAAlD,+HAAA,OAAO,OAAiB;AACjC,6BAAuC;AAA9B,2GAAA,OAAO,OAAO;AACvB,4DAA4E;AAAnE,yIAAA,OAAO,OAAyB;AACzC,0CAA0D;AAAjD,uHAAA,OAAO,OAAgB;AAChC,yCAAmD;AAA1C,uHAAA,OAAO,OAAa;AAC7B,yCAAmD;AAA1C,uHAAA,OAAO,OAAa;AAE7B,sDAAsD;AACtD,6CAAuE;AAA9D,4GAAA,aAAa,OAAA;AAAE,sHAAA,uBAAuB,OAAA;AAC/C,mCAA8D;AAArD,gHAAA,sBAAsB,OAAA;AAAE,oGAAA,UAAU,OAAA;AAC3C,iCAA+C;AAAtC,6FAAA,IAAI,OAAA;AAAE,uGAAA,cAAc,OAAA;AAC7B,mCAAsE;AAA7D,oGAAA,UAAU,OAAA;AAAE,yGAAA,eAAe,OAAA;AAAE,uGAAA,aAAa,OAAA;AAEnD,oCAAoC;AACpC,2BAA2B;AAC3B,uDAAyC;AAChB,8BAAM"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/application.ts", "../src/lib.ts", "../src/enums.ts", "../src/throwable.ts", "../src/guards.ts", "../src/initializable.ts", "../src/errors.ts", "../src/router/router.internal.ts", "../src/singleton.ts", "../src/router/router.ts", "../src/server/controller.ts", "../src/consts.ts", "../src/router/routes.ts"],
4
+ "sourcesContent": [
5
+ "import { I_ApplicationResponse } from \"./types\";\n\nexport const RESPONSE_INIT = (status?: number, headers?: HeadersInit): ResponseInit => {\n\treturn {\n\t\tstatus: status ?? 200,\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\"Access-Control-Allow-Methods\": \"GET, POST, OPTIONS\",\n\t\t\t\"Access-Control-Allow-Headers\": \"Content-Type, Authorization\",\n\t\t\t\"Access-Control-Allow-Credentials\": \"true\",\n\t\t},\n\t};\n};\n\nexport const RESPONSE_METHOD_OPTIONS = {\n\tname: \"Access-Control-Max-Age\",\n\tvalue: \"86400\",\n};\n\nclass Application {\n\tpublic static Response<T>(data: T, status: number = 200, headers?: HeadersInit): Response {\n\t\tconst response: I_ApplicationResponse<T> = {\n\t\t\tstatus: true,\n\t\t\tdata,\n\t\t};\n\t\treturn Response.json(response, RESPONSE_INIT(status, headers));\n\t}\n\n\tpublic static Error<T extends BodyInit | unknown | Error>(error: T, status: number = 200, headers?: HeadersInit) {\n\t\tconst response: I_ApplicationResponse<T> = {\n\t\t\tstatus: false,\n\t\t\tdata: error,\n\t\t\terror,\n\t\t};\n\t\treturn Response.json(response, RESPONSE_INIT(status, headers));\n\t}\n\n\tpublic static Throw<T extends BodyInit | unknown | Error>(error: T, status: number = 400, headers?: HeadersInit) {\n\t\treturn Response.json(error, RESPONSE_INIT(status, headers));\n\t}\n}\n\nexport default Application;\n",
6
+ "import * as fs from \"fs\";\nimport * as path from \"path\";\nimport { E_IS } from \"./enums\";\nimport Throwable from \"./throwable\";\n\nclass Lib {\n\tpublic static Log(...args: any) {\n\t\tconst timestamp = new Date().toLocaleTimeString();\n\t\tconsole.log(`[${timestamp}]:`, ...args);\n\t}\n\n\tpublic static LogObject(object: any, text?: string) {\n\t\tconst timestamp = new Date().toLocaleTimeString();\n\t\tconsole.log(`[${timestamp}]:`, text ?? \"\", JSON.stringify(object, null, 2));\n\t}\n\n\tpublic static Warn(...args: any) {\n\t\tconst timestamp = new Date().toLocaleTimeString();\n\t\tconsole.error(`[${timestamp}] Handled Error: `, ...args);\n\t}\n\n\tpublic static $Log(...args: any) {\n\t\tconst timestamp = new Date().toLocaleTimeString();\n\t\tconsole.error(`[${timestamp}]`, ...args);\n\t}\n\n\tpublic static secondsToMilliseconds(seconds: number): number {\n\t\treturn seconds * 1000;\n\t}\n\n\tpublic static minutesToMilliseconds(minutes: number): number {\n\t\treturn minutes * 60 * 1000;\n\t}\n\n\tpublic static hoursToMilliseconds(hours: number): number {\n\t\treturn hours * 60 * 60 * 1000;\n\t}\n\n\tpublic static GetTimestamp(milliseconds_ago: number) {\n\t\tconst now = new Date();\n\t\treturn new Date(now.getTime() - milliseconds_ago);\n\t}\n\n\tpublic static GetDateTimestamp(date: string | Date, format: string = \"DD/MM/YYYY HH:mm\", isUTC: boolean = false): number {\n\t\tif (typeof date === \"string\") {\n\t\t\tconst formatParts = format.split(/[-\\/. :]/);\n\t\t\tconst dateParts = date.split(/[-\\/. :]/);\n\n\t\t\tlet day: number | undefined;\n\t\t\tlet month: number | undefined;\n\t\t\tlet year: number | undefined;\n\t\t\tlet hours: number = 0;\n\t\t\tlet minutes: number = 0;\n\n\t\t\tformatParts.forEach((part, index) => {\n\t\t\t\tswitch (part) {\n\t\t\t\t\tcase \"DD\":\n\t\t\t\t\tcase \"dd\":\n\t\t\t\t\t\tday = parseInt(dateParts[index], 10);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"MM\":\n\t\t\t\t\t\tmonth = parseInt(dateParts[index], 10) - 1; // Months are 0-based in JavaScript Date\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"YYYY\":\n\t\t\t\t\tcase \"yyyy\":\n\t\t\t\t\t\tyear = parseInt(dateParts[index], 10);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"HH\":\n\t\t\t\t\tcase \"hh\":\n\t\t\t\t\t\thours = parseInt(dateParts[index], 10);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"mm\":\n\t\t\t\t\t\tminutes = parseInt(dateParts[index], 10);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (day === undefined || month === undefined || year === undefined) {\n\t\t\t\tthrow new Error(\"Invalid date format or date string\");\n\t\t\t}\n\n\t\t\tlet dateObj;\n\t\t\tif (isUTC) {\n\t\t\t\tdateObj = new Date(Date.UTC(year, month, day, hours, minutes));\n\t\t\t} else {\n\t\t\t\tdateObj = new Date(year, month, day, hours, minutes);\n\t\t\t}\n\t\t\treturn dateObj.getTime();\n\t\t} else {\n\t\t\treturn date.getTime();\n\t\t}\n\t}\n\n\tpublic static calculatePercentage(x: number, y: number): number {\n\t\tif (y === 0) {\n\t\t\tthrow new Error(\"The denominator (y) cannot be zero.\");\n\t\t}\n\t\treturn x / y;\n\t}\n\n\tpublic static MYSQLTimestamp(): string {\n\t\tconst now = new Date();\n\t\tconst year = now.getFullYear();\n\t\tconst month = now.getMonth() + 1;\n\t\tconst day = now.getDate();\n\t\tconst hours = now.getHours();\n\t\tconst minutes = now.getMinutes();\n\t\tconst seconds = now.getSeconds();\n\n\t\tconst formattedDate = `${year}-${month.toString().padStart(2, \"0\")}-${day.toString().padStart(2, \"0\")}`;\n\t\tconst formattedTime = `${hours.toString().padStart(2, \"0\")}:${minutes.toString().padStart(2, \"0\")}:${seconds.toString().padStart(2, \"0\")}`;\n\n\t\treturn `${formattedDate} ${formattedTime}`;\n\t}\n\n\tpublic static FormatUnixToDate(unix_time_stamp: number, in_milliseconds: boolean = false): Date {\n\t\tconst date = new Date(unix_time_stamp * (in_milliseconds ? 1 : 1000));\n\t\treturn date;\n\t}\n\n\tpublic static FormatDate(date: Date | string, format = \"MM/dd/yyyy\"): string {\n\t\ttry {\n\t\t\tconst leadingZero = (value: number) => (value < 10 ? `0${value}` : `${value}`);\n\t\t\tif (!date) throw new Error(\"Lib.FormatDate() Exception: Date is required\");\n\t\t\tif (typeof date === \"string\") {\n\t\t\t\tdate = new Date(date);\n\t\t\t}\n\t\t\tconst day = leadingZero(date.getDate());\n\t\t\tconst month = leadingZero(date.getMonth() + 1);\n\t\t\tconst year = date.getFullYear();\n\t\t\tconst hours = leadingZero(date.getHours());\n\t\t\tconst minutes = leadingZero(date.getMinutes());\n\t\t\tconst seconds = leadingZero(date.getSeconds());\n\n\t\t\tlet result = format\n\t\t\t\t.replace(/DD|dd/g, day)\n\t\t\t\t.replace(/MM/g, month)\n\t\t\t\t.replace(/yyyy|YYYY/g, year.toString());\n\n\t\t\tif (format.includes(\"HH\")) {\n\t\t\t\tresult = result.replace(/HH/g, hours);\n\t\t\t}\n\t\t\tif (format.toLowerCase().includes(\"mm\")) {\n\t\t\t\tresult = result.replace(/mm/g, minutes);\n\t\t\t}\n\t\t\tif (format.includes(\"ss\")) {\n\t\t\t\tresult = result.replace(/ss/g, seconds);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t} catch (e) {\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\tpublic static DaysBetweenDates(startDate: Date | string | undefined, endDate: Date | string | undefined, format: string = \"MM/dd/yyyy\"): number {\n\t\tif (startDate === null || startDate === undefined || endDate === null || endDate === undefined) {\n\t\t\tthrow new Error(\"Lib.DaysBetweenDates() Exception: Dates are required\" + startDate + \" \" + endDate);\n\t\t}\n\t\tconst start = new Date(this.FormatDate(startDate, format)).getTime();\n\t\tconst end = new Date(this.FormatDate(endDate, format)).getTime();\n\t\tconst difference = end - start;\n\t\tconst daysPassed = difference / (1000 * 3600 * 24);\n\t\treturn Math.floor(daysPassed);\n\t}\n\n\tpublic static IsPastDate(date: Date | string, format: string = \"MM/dd/yyyy HH:mm:ss\", debug: boolean = false, currentDate?: Date | string): boolean {\n\t\tconst truncateToSecond = (d: Date) => new Date(Math.floor(d.getTime() / 1000) * 1000);\n\n\t\tconst now = truncateToSecond(currentDate ? (typeof currentDate === \"string\" ? new Date(currentDate) : currentDate) : new Date());\n\t\tconst check = truncateToSecond(typeof date === \"string\" ? new Date(date) : date);\n\n\t\tif (debug) {\n\t\t\tDebug.Log(\"Now:\", this.FormatDate(now, format));\n\t\t\tDebug.Log(\"Check:\", this.FormatDate(check, format));\n\t\t}\n\n\t\treturn now.getTime() > check.getTime();\n\t}\n\n\tpublic static IsPastDateFrom(date: Date | string, from: Date | string, format: string = \"MM/dd/yyyy\"): boolean {\n\t\tconst now = this.FormatDate(from, format);\n\t\tconst check = this.FormatDate(date, format);\n\t\treturn new Date(now).getTime() > new Date(check).getTime();\n\t}\n\n\tpublic static addTimeFromDate(date: Date | string, milliseconds: number): Date {\n\t\tconst dateObj = new Date(typeof date === \"string\" ? new Date(date).getTime() : date.getTime() + milliseconds);\n\t\treturn dateObj;\n\t}\n\n\tpublic static UUID(minLength: number = 36): string {\n\t\tconst template = \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\";\n\t\tlet uuid = template.replace(/[xy]/g, function (c) {\n\t\t\tvar r = (Math.random() * 16) | 0,\n\t\t\t\tv = c === \"x\" ? r : (r & 0x3) | 0x8;\n\t\t\treturn v.toString(16);\n\t\t});\n\n\t\t// If the generated UUID is shorter than the minimum length, pad it with additional random characters\n\t\twhile (uuid.length < minLength) {\n\t\t\tuuid += ((Math.random() * 16) | 0).toString(16);\n\t\t}\n\n\t\treturn uuid.substring(0, minLength);\n\t}\n\n\tpublic static Debounce(callback: (...args: any[]) => void, delay = 500): (...args: any[]) => any {\n\t\tlet timeout: Timer;\n\t\treturn (...args: any[]) => {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(() => {\n\t\t\t\treturn callback(...args);\n\t\t\t}, delay);\n\t\t};\n\t}\n\n\tpublic static IsNil(value: any): boolean {\n\t\treturn value === null || value === undefined;\n\t}\n\n\tpublic static IsPrimitive(value: any): boolean {\n\t\treturn this.IsNumber(value) || this.IsString(value) || this.IsBoolean(value);\n\t}\n\n\tpublic static EmptyObject(value: any): boolean {\n\t\tlet empty_object = true;\n\t\tif (this.GetType(value) !== \"object\") {\n\t\t\tempty_object = false;\n\t\t\treturn empty_object;\n\t\t}\n\t\tif (Object.keys(value).length === 0) {\n\t\t\tempty_object = true;\n\t\t\treturn empty_object;\n\t\t}\n\t\tfor (let k in value) {\n\t\t\tif (!this.IsNil(value[k]) && value[k] !== \"\") {\n\t\t\t\tempty_object = false;\n\t\t\t}\n\t\t}\n\t\treturn empty_object;\n\t}\n\n\tpublic static IsNumpty(value: any, _objectsOnly: boolean = false): boolean {\n\t\treturn typeof value === \"number\" ? false : this.IsNil(value) || this.IsEmpty(value, _objectsOnly);\n\t}\n\n\tpublic static IsEmpty(value: any, _objectsOnly: boolean = false): boolean {\n\t\treturn (\n\t\t\t(this.GetType(value) === \"array\" && value.length === 0 && !_objectsOnly) ||\n\t\t\t(this.GetType(value) === \"object\" && this.EmptyObject(value)) ||\n\t\t\t(typeof value === \"string\" && value.trim().length === 0)\n\t\t);\n\t}\n\n\tpublic static IsArray(variable: any): boolean {\n\t\treturn this.GetType(variable) === E_IS.ARRAY;\n\t}\n\n\tpublic static IsString(variable: any): boolean {\n\t\treturn this.GetType(variable) === E_IS.STRING;\n\t}\n\n\tpublic static IsNumber(variable: any): boolean {\n\t\treturn this.GetType(variable) === E_IS.NUMBER;\n\t}\n\n\tpublic static IsObject(variable: any): boolean {\n\t\treturn this.GetType(variable) === E_IS.OBJECT;\n\t}\n\n\tpublic static IsFunction(variable: any): boolean {\n\t\treturn this.GetType(variable) === E_IS.FUNCTION;\n\t}\n\n\tpublic static IsRegex(variable: any): boolean {\n\t\treturn this.GetType(variable) === E_IS.REGEX;\n\t}\n\n\tpublic static IsBoolean(variable: any): boolean {\n\t\treturn this.GetType(variable, true) === E_IS.BOOLEAN;\n\t}\n\n\tpublic static GetType(value: any, asTypeOf = false): null | string | boolean {\n\t\tif (asTypeOf) {\n\t\t\treturn typeof value;\n\t\t}\n\t\tif (value === \"0\" || value === \"1\") {\n\t\t\treturn \"number\";\n\t\t}\n\t\tif (value === true) {\n\t\t\treturn true;\n\t\t} else if (value === false) {\n\t\t\treturn false;\n\t\t} else if (value === null || value === undefined) {\n\t\t\treturn null;\n\t\t} else if (Array.isArray(value)) {\n\t\t\treturn \"array\";\n\t\t} else if (value instanceof RegExp) {\n\t\t\treturn \"regex\";\n\t\t} else if (!isNaN(Number(value))) {\n\t\t\treturn \"number\";\n\t\t} else if (typeof value === \"string\") {\n\t\t\treturn \"string\";\n\t\t} else if ({}.toString.call(value) === \"[object Function]\" || typeof value === \"function\") {\n\t\t\treturn \"function\";\n\t\t} else {\n\t\t\treturn \"object\";\n\t\t}\n\t}\n\n\tpublic static GetProjectRoot(startDir: string = __dirname, rootReference: string = \"package.json\"): string {\n\t\tlet currentDir = startDir;\n\n\t\twhile (!fs.existsSync(path.join(currentDir, rootReference))) {\n\t\t\tconst parentDir = path.resolve(currentDir, \"..\");\n\t\t\tif (parentDir === currentDir) {\n\t\t\t\tthrow new Error(\"Unable to find project root\");\n\t\t\t}\n\t\t\tcurrentDir = parentDir;\n\t\t}\n\n\t\treturn currentDir;\n\t}\n\n\tpublic static async RunTaskWithTimeout(task: () => Promise<void>, timeout: number) {\n\t\treturn Promise.race([task(), new Promise((_, reject) => setTimeout(() => reject(new Error(\"Task timed out\")), timeout))]);\n\t}\n\n\tpublic static GetFolderPath(folder: string): string {\n\t\treturn path.join(this.GetProjectRoot(), folder);\n\t}\n\n\tpublic static GetFilePath(folder: string, file: string): string {\n\t\treturn path.join(this.GetFolderPath(folder), file);\n\t}\n\n\tpublic static async CreateDirectory(folderToCreate: string) {\n\t\tconst directoryPath = Lib.GetFolderPath(folderToCreate);\n\t\tawait fs.promises.access(directoryPath, fs.constants.F_OK).catch(async () => {\n\t\t\tawait fs.promises.mkdir(directoryPath, { recursive: true });\n\t\t});\n\t\treturn directoryPath;\n\t}\n\n\tpublic static async DeleteDirectory(folderToDelete: string) {\n\t\tconst directoryPath = path.join(this.GetProjectRoot(), folderToDelete);\n\t\tawait fs.promises.rm(directoryPath, { recursive: true, force: true });\n\t}\n\n\tpublic static async CreateFile(folderPath: string, filePath: string, content: string) {\n\t\tawait Lib.CreateDirectory(folderPath);\n\t\tconst file = Lib.GetFilePath(folderPath, filePath);\n\t\tawait fs.promises.writeFile(file, content, \"utf8\");\n\t}\n\n\tpublic static GetFile(filePathFromRoot: string) {\n\t\treturn fs.createReadStream(filePathFromRoot);\n\t}\n\n\tpublic static GetFilesInDirectory(directoryPath: string): string[] {\n\t\treturn fs.readdirSync(directoryPath);\n\t}\n\n\tpublic static async DeleteFile(filePathFromRoot: string) {\n\t\tawait fs.promises.unlink(filePathFromRoot);\n\t}\n\n\tpublic static Timestamp(log: boolean = false) {\n\t\tconst currentTime = new Date().toLocaleTimeString();\n\t\tif (log) console.log(`[${currentTime}]`);\n\t\treturn currentTime;\n\t}\n\n\tpublic static RemoveWhitespace(value: string): string {\n\t\treturn value.replace(/\\s/g, \"\");\n\t}\n\n\tpublic static msToString(ms: number): string {\n\t\tif (ms === 0) return \"0ms\"; // Handle zero duration case\n\t\tconst seconds = Math.floor(ms / 1000);\n\t\tconst minutes = Math.floor(seconds / 60);\n\t\tconst hours = Math.floor(minutes / 60);\n\t\tlet output = hours > 0 ? `${hours}h ` : \"\";\n\t\toutput += minutes > 0 ? `${minutes % 60}m ` : \"\";\n\t\toutput += seconds % 60 > 0 ? `${seconds % 60}s ` : \"\";\n\t\toutput += ms % 1000 > 0 ? `${(ms % 1000).toFixed(2)}ms` : \"\";\n\t\treturn output.trim();\n\t}\n\n\tpublic static FormatPhone(phone_number: string): string {\n\t\tlet output: string = phone_number;\n\t\t//remove all non-digit characters and whitespaces using regex\n\t\toutput = output.replace(/\\D/g, \"\");\n\t\t//if phone number doesn't start with + add +\n\t\tif (!output.startsWith(\"+\")) {\n\t\t\toutput = `+${output}`;\n\t\t}\n\t\treturn output;\n\t}\n\n\tpublic static ToMB(bytes: number, as_KB: boolean = true, decimalPlaces: number = 2): string {\n\t\tconst kb = bytes / 1024;\n\t\treturn (as_KB ? kb : kb / 1024).toFixed(decimalPlaces);\n\t}\n\n\tpublic static ToGB(bytes: number, as_KB: boolean = true, decimalPlaces: number = 2): string {\n\t\tconst mb = this.ToMB(bytes, as_KB, decimalPlaces);\n\t\treturn (parseInt(mb) / 1024).toFixed(decimalPlaces);\n\t}\n\n\tpublic static async RetryHandler<T extends (...args: any[]) => any>(func: T, retries: number = 3, ...args: Parameters<T>): Promise<ReturnType<T>> {\n\t\tlet attempts = 0;\n\t\tlet toThrow;\n\n\t\twhile (attempts < retries) {\n\t\t\ttry {\n\t\t\t\treturn await func(...args);\n\t\t\t} catch (e) {\n\t\t\t\tattempts++;\n\t\t\t\ttoThrow = e;\n\t\t\t\tif (attempts <= retries && !Throwable.IsThrowable(e)) {\n\t\t\t\t\tLib.$Log(`Attempt ${attempts} failed. Retrying...(${func.name})`);\n\t\t\t\t\tif (attempts == 1) Lib.Warn(toThrow);\n\t\t\t\t\t// Lib.Warn(toThrow, { hint: `Attempt ${attempts} failed. Retrying...(${func.name})`, data: JSON.stringify(args) });\n\t\t\t\t\t// Wait for 1 second before retrying\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 1000));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthrow toThrow;\n\t}\n\n\tpublic static Difference(x: any[], y: any[]) {\n\t\treturn x.filter((x) => !y.includes(x));\n\t}\n\n\tpublic static async ReadFileContent(filePath: string): Promise<string> {\n\t\treturn fs.promises.readFile(filePath, \"utf8\");\n\t}\n\n\tpublic static async measureExecutionTime<T extends (...args: any[]) => any, U extends ReturnType<T>>(\n\t\tfunc: T,\n\t\t...args: Parameters<T>\n\t): Promise<{ result: Awaited<U>; time: number | string }> {\n\t\tconst start = performance.now();\n\t\tconst result = await func(...args);\n\t\tconst end = performance.now();\n\t\treturn { result, time: this.msToString(end - start) };\n\t}\n\n\tpublic static ToCamelCase(str: string): string {\n\t\treturn str.replace(/(?:^\\w|[A-Z]|\\b\\w)/g, (word, index) => (index === 0 ? word.toLowerCase() : word.toUpperCase())).replace(/\\s+/g, \"\");\n\t}\n\n\tpublic static ToSnakeCase(str: string): string {\n\t\treturn str.replace(/([a-z])([A-Z])/g, \"$1_$2\").toLowerCase();\n\t}\n\n\tpublic static ToKebebCase(str: string): string {\n\t\treturn str.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n\t}\n}\n\nexport default Lib;\n\nexport class Debug {\n\tpublic static Log(...args: any) {\n\t\tif (process.env.NODE_ENV === \"production\") return;\n\t\tLib.Log(...args);\n\t}\n\n\tpublic static $Log(...args: any) {\n\t\tif (process.env.NODE_ENV === \"production\") return;\n\t\tLib.$Log(...args);\n\t}\n\n\tpublic static LogObject(object: any, text?: string) {\n\t\tif (process.env.NODE_ENV === \"production\") return;\n\t\tLib.LogObject(object, text);\n\t}\n}\n",
7
+ "export enum E_IS {\n\tARRAY = \"array\",\n\tOBJECT = \"object\",\n\tFUNCTION = \"function\",\n\tSTRING = \"string\",\n\tNUMBER = \"number\",\n\tBOOLEAN = \"boolean\",\n\tREGEX = \"regex\",\n}\n\nexport enum E_ENVIRONMENTS {\n\tDEV = \"development\",\n\tPROD = \"production\",\n}\n",
8
+ "import Guards from \"./guards\";\nimport Lib from \"./lib\";\n\n/**\n * @description Custom error class for errors that are expected to be thrown\n * and should not trigger retry mechanisms or be reported to error monitoring services.\n *\n * Use this class when you want to throw an error that:\n * 1. Is an expected part of the application flow\n * 2. Should not be retried by retry handlers\n * 3. Should not be reported to error monitoring services like Sentry\n */\nclass Throwable extends Error {\n\t/** Flag indicating this is a deliberate error that shouldn't be retried */\n\tpublic readonly isDeliberate: boolean = true;\n\n\t/** Original error if this Throwable wraps another error */\n\tpublic readonly originalError?: Error;\n\n\t/** Additional context that might be helpful for debugging */\n\tpublic readonly context?: Record<string, unknown>;\n\n\t/**\n\t * Create a new Throwable error\n\t * @param message Error message or existing Error object to wrap\n\t * @param options Configuration options\n\t */\n\tconstructor(\n\t\tmessage: unknown,\n\t\toptions: {\n\t\t\t/** Whether to log this error to console (default: true) */\n\t\t\tlogError?: boolean;\n\t\t\t/** Additional context data to attach to the error */\n\t\t\tcontext?: Record<string, unknown>;\n\t\t} = {},\n\t) {\n\t\tconst { logError = true, context } = options;\n\n\t\t// Format the message appropriately based on type\n\t\tconst _message = Guards.IsString(message) ? message : message instanceof Error ? message.message : JSON.stringify(message);\n\n\t\tsuper(_message);\n\t\tthis.name = \"Throwable\";\n\t\tthis.context = context;\n\n\t\t// Log the error if requested\n\t\tif (logError) {\n\t\t\tif (context) {\n\t\t\t\tLib.$Log(\"Throwable: \", _message, \"Context:\", context);\n\t\t\t} else {\n\t\t\t\tLib.$Log(\"Throwable: \", message);\n\t\t\t}\n\t\t}\n\n\t\t// Capture stack trace and cause if wrapping an existing error\n\t\tif (message instanceof Error) {\n\t\t\tthis.stack = message.stack;\n\t\t\tthis.cause = message.cause;\n\t\t\tthis.originalError = message;\n\t\t}\n\t}\n\n\t/**\n\t * Check if an error is a Throwable\n\t * @param e Any error to check\n\t * @returns True if the error is a Throwable\n\t */\n\tstatic IsThrowable(e: any): e is Throwable {\n\t\treturn e instanceof Throwable;\n\t}\n\n\t/**\n\t * Create a Throwable from any error or message\n\t * @param error Error or message to convert\n\t * @param context Additional context to attach\n\t * @returns A new Throwable instance\n\t */\n\tstatic from(error: unknown, context?: Record<string, unknown>): Throwable {\n\t\tif (error instanceof Throwable) {\n\t\t\treturn error;\n\t\t}\n\n\t\treturn new Throwable(error, { context });\n\t}\n}\n\nexport default Throwable;\n",
9
+ "import type { NonNullableType } from \"./types\";\nimport Lib from \"./lib\";\n\nclass Guards {\n\tpublic static IsString(value: any): value is string;\n\tpublic static IsString(value: any, excludeNull: true): value is NonNullableType<string>;\n\tpublic static IsString(value: any, excludeNull: boolean = false): value is string | NonNullableType<string> {\n\t\tconst output = Lib.IsString(value);\n\t\treturn excludeNull ? !Guards.IsNil(value) && output : output;\n\t}\n\n\tpublic static IsNumber(value: any): value is number;\n\tpublic static IsNumber(value: any, excludeNull: true): value is NonNullableType<number>;\n\tpublic static IsNumber(value: any, excludeNull: boolean = false): value is number | NonNullableType<number> {\n\t\tconst output = Lib.IsNumber(value);\n\t\treturn excludeNull ? !Guards.IsNil(value) && output : output;\n\t}\n\n\tpublic static IsBoolean(value: any): value is boolean;\n\tpublic static IsBoolean(value: any, excludeNull: true): value is NonNullableType<boolean>;\n\tpublic static IsBoolean(value: any, excludeNull: boolean = false): value is boolean | NonNullableType<boolean> {\n\t\tconst output = Lib.GetType(value, true) === \"boolean\";\n\t\treturn excludeNull ? !Guards.IsNil(value) && output : output;\n\t}\n\n\tpublic static IsArray<T>(value: any): value is T[];\n\tpublic static IsArray<T>(value: any, excludeNull: true): value is NonNullableType<T[]>;\n\tpublic static IsArray<T>(value: any, excludeNull: boolean = false): value is T[] | NonNullableType<T[]> {\n\t\tconst output = Lib.IsArray(value);\n\t\treturn excludeNull ? !Guards.IsNil(value) && output : output;\n\t}\n\n\tpublic static IsObject(value: any): value is object;\n\tpublic static IsObject(value: any, excludeNull: true): value is NonNullableType<object>;\n\tpublic static IsObject(value: any, excludeNull: boolean = false): value is object | NonNullableType<object> {\n\t\tconst output = Lib.IsObject(value);\n\t\treturn excludeNull ? !Guards.IsNil(value) && output : output;\n\t}\n\n\tpublic static IsFunction(value: any): value is Function;\n\tpublic static IsFunction(value: any, excludeNull: true): value is NonNullableType<Function>;\n\tpublic static IsFunction(value: any, excludeNull: boolean = false): value is Function | NonNullableType<Function> {\n\t\tconst output = Lib.IsFunction(value);\n\t\treturn excludeNull ? !Guards.IsNil(value) && output : output;\n\t}\n\n\tpublic static IsNil(value: any): value is null | undefined {\n\t\treturn Lib.IsNil(value);\n\t}\n\n\tpublic static IsType<T>(obj: any): obj is T;\n\tpublic static IsType<T>(obj: any, keys: (keyof T)[]): obj is T;\n\tpublic static IsType<T>(obj: any, keys?: (keyof T)[]): obj is T {\n\t\tif (!keys) return !this.IsNil(obj);\n\t\treturn keys.every((key) => key in obj);\n\t}\n}\n\nexport default Guards;\n",
10
+ "/* class Initializable {\n\tretries: number;\n\tinitialized: boolean;\n\tconstructor(retries: number = 25) {\n\t\tthis.retries = retries;\n\t\tthis.initialized = false;\n\t\tthis.initialize();\n\t}\n\n\tprotected initialize() {\n\t\tthis.initialized = true;\n\t}\n\n\tprotected async isInitialized(): Promise<boolean> {\n\t\tlet retries = this.retries; // 5 seconds / 200ms = 25 retries\n\n\t\twhile (!this.initialized && retries > 0) {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 200));\n\t\t\tretries--;\n\t\t}\n\n\t\tif (!this.initialized) {\n\t\t\tthrow new Error(\"Initialization failed after 5 seconds\");\n\t\t}\n\n\t\treturn true;\n\t}\n}\n\nexport default Initializable;\n */\n\n/**\n * Configuration options for initialization\n */\nexport interface InitializableOptions {\n\t/** Number of retry attempts (default: 25) */\n\tretries?: number;\n\n\t/** Time in milliseconds between retry attempts (default: 200) */\n\tretryInterval?: number;\n\n\t/** Whether to initialize automatically in constructor (default: false) */\n\tautoInitialize?: boolean;\n\n\t/** Custom timeout in milliseconds (overrides retries * retryInterval) */\n\ttimeout?: number;\n}\n\n/**\n * Events emitted by Initializable instances\n */\nexport type InitializableEvent = \"initializing\" | \"initialized\" | \"failed\" | \"timeout\";\n\n/**\n * Base class for objects that require asynchronous initialization\n *\n * @example\n * class Database extends Initializable {\n * private connection: any;\n *\n * constructor() {\n * super({ retries: 10, retryInterval: 500 });\n * }\n *\n * protected async doInitialize(): Promise<void> {\n * this.connection = await connectToDatabase();\n * }\n * }\n *\n * // Usage\n * const db = new Database();\n * await db.initialize();\n * // or check status\n * if (await db.isInitialized()) {\n * // use the database\n * }\n */\nclass Initializable {\n\t/** Number of retry attempts */\n\tprivate retries: number;\n\n\t/** Time in milliseconds between retry attempts */\n\tprivate retryInterval: number;\n\n\t/** Whether initialization has completed successfully */\n\tprivate _initialized: boolean = false;\n\n\t/** Whether initialization is in progress */\n\tprivate initializing: boolean = false;\n\n\t/** Whether initialization has failed */\n\tprivate failed: boolean = false;\n\n\t/** Optional timeout in milliseconds */\n\tprivate timeout?: number;\n\n\t/** Event listeners */\n\tprivate listeners: Map<InitializableEvent, Function[]> = new Map();\n\n\t/** Abort controller for cancellation */\n\tprivate abortController: AbortController | null = null;\n\n\t/**\n\t * Creates a new Initializable instance\n\t * @param options Configuration options\n\t */\n\tconstructor(options: InitializableOptions = {}) {\n\t\tthis.retries = options.retries ?? 25;\n\t\tthis.retryInterval = options.retryInterval ?? 200;\n\t\tthis.timeout = options.timeout;\n\n\t\tif (options.autoInitialize) {\n\t\t\t// Schedule initialization on next tick to allow subclass construction to complete\n\t\t\tsetTimeout(() => this.initialize(), 0);\n\t\t}\n\t}\n\n\t/**\n\t * Initialize the object\n\t * @returns Promise that resolves when initialization is complete\n\t * @throws Error if initialization fails\n\t */\n\tpublic async initialize(): Promise<void> {\n\t\t// If already initialized, return immediately\n\t\tif (this._initialized) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If already initializing, wait for it to complete\n\t\tif (this.initializing) {\n\t\t\treturn this.waitForInitialization();\n\t\t}\n\n\t\t// Start initialization\n\t\tthis.initializing = true;\n\t\tthis.failed = false;\n\t\tthis.abortController = new AbortController();\n\n\t\ttry {\n\t\t\t// Emit initializing event\n\t\t\tthis.emit(\"initializing\");\n\n\t\t\t// Call the implementation-specific initialization\n\t\t\tawait this.doInitialize();\n\n\t\t\t// Mark as initialized\n\t\t\tthis._initialized = true;\n\t\t\tthis.initializing = false;\n\n\t\t\t// Emit initialized event\n\t\t\tthis.emit(\"initialized\");\n\t\t} catch (error) {\n\t\t\t// Mark as failed\n\t\t\tthis.failed = true;\n\t\t\tthis.initializing = false;\n\n\t\t\t// Emit failed event\n\t\t\tthis.emit(\"failed\", error);\n\n\t\t\t// Re-throw the error\n\t\t\tthrow error instanceof Error ? error : new Error(`Initialization failed: ${String(error)}`);\n\t\t} finally {\n\t\t\tthis.abortController = null;\n\t\t}\n\t}\n\n\t/**\n\t * Implementation-specific initialization logic\n\t * Override this method in subclasses to provide custom initialization\n\t */\n\tprotected async doInitialize(): Promise<void> {\n\t\t// Default implementation does nothing\n\t\t// Subclasses should override this method\n\t\tthis._initialized = true;\n\t}\n\n\t/**\n\t * Check if the object is initialized\n\t * @param waitForIt Whether to wait for initialization to complete\n\t * @returns Promise that resolves to true if initialized, false otherwise\n\t */\n\tpublic async isInitialized(waitForIt: boolean = false): Promise<boolean> {\n\t\t// If already initialized, return immediately\n\t\tif (this._initialized) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// If not waiting or already failed, return current status\n\t\tif (!waitForIt || this.failed) {\n\t\t\treturn this._initialized;\n\t\t}\n\n\t\t// Wait for initialization to complete\n\t\ttry {\n\t\t\tawait this.waitForInitialization();\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Wait for initialization to complete\n\t * @returns Promise that resolves when initialization is complete\n\t * @throws Error if initialization fails or times out\n\t */\n\tprivate async waitForInitialization(): Promise<void> {\n\t\t// If already initialized, return immediately\n\t\tif (this._initialized) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If not initializing, start initialization\n\t\tif (!this.initializing) {\n\t\t\treturn this.initialize();\n\t\t}\n\n\t\tconst className = this.constructor.name;\n\t\tconst maxTime = this.timeout ?? this.retries * this.retryInterval;\n\t\tlet retries = this.retries;\n\n\t\t// Create a promise that resolves when initialization completes\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t// One-time event listeners for completion\n\t\t\tconst onInitialized = () => {\n\t\t\t\tthis.off(\"initialized\", onInitialized);\n\t\t\t\tthis.off(\"failed\", onFailed);\n\t\t\t\tthis.off(\"timeout\", onTimeout);\n\t\t\t\tresolve();\n\t\t\t};\n\n\t\t\tconst onFailed = (error: Error) => {\n\t\t\t\tthis.off(\"initialized\", onInitialized);\n\t\t\t\tthis.off(\"failed\", onFailed);\n\t\t\t\tthis.off(\"timeout\", onTimeout);\n\t\t\t\treject(error);\n\t\t\t};\n\n\t\t\tconst onTimeout = () => {\n\t\t\t\tthis.off(\"initialized\", onInitialized);\n\t\t\t\tthis.off(\"failed\", onFailed);\n\t\t\t\tthis.off(\"timeout\", onTimeout);\n\t\t\t\treject(new Error(`Initialization of ${className} timed out after ${maxTime}ms`));\n\t\t\t};\n\n\t\t\t// Register event listeners\n\t\t\tthis.on(\"initialized\", onInitialized);\n\t\t\tthis.on(\"failed\", onFailed);\n\t\t\tthis.on(\"timeout\", onTimeout);\n\n\t\t\t// Set up polling to check for timeout\n\t\t\tconst checkInterval = setInterval(() => {\n\t\t\t\tretries--;\n\n\t\t\t\tif (this._initialized) {\n\t\t\t\t\tclearInterval(checkInterval);\n\t\t\t\t\t// Will be handled by event\n\t\t\t\t} else if (retries <= 0) {\n\t\t\t\t\tclearInterval(checkInterval);\n\t\t\t\t\tthis.emit(\"timeout\");\n\t\t\t\t}\n\t\t\t}, this.retryInterval);\n\t\t});\n\t}\n\n\t/**\n\t * Cancel initialization if in progress\n\t */\n\tpublic cancel(): void {\n\t\tif (this.initializing && this.abortController) {\n\t\t\tthis.abortController.abort();\n\t\t\tthis.initializing = false;\n\t\t\tthis.failed = true;\n\t\t\tthis.emit(\"failed\", new Error(\"Initialization cancelled\"));\n\t\t}\n\t}\n\n\t/**\n\t * Reset initialization state\n\t * Allows re-initialization after failure\n\t */\n\tpublic reset(): void {\n\t\tif (this.initializing) {\n\t\t\tthis.cancel();\n\t\t}\n\n\t\tthis._initialized = false;\n\t\tthis.initializing = false;\n\t\tthis.failed = false;\n\t}\n\n\t/**\n\t * Register an event listener\n\t * @param event Event name\n\t * @param callback Function to call when event is emitted\n\t * @returns this for chaining\n\t */\n\tpublic on(event: InitializableEvent, callback: Function): this {\n\t\tif (!this.listeners.has(event)) {\n\t\t\tthis.listeners.set(event, []);\n\t\t}\n\n\t\tthis.listeners.get(event)!.push(callback);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Remove an event listener\n\t * @param event Event name\n\t * @param callback Function to remove\n\t * @returns this for chaining\n\t */\n\tpublic off(event: InitializableEvent, callback: Function): this {\n\t\tif (this.listeners.has(event)) {\n\t\t\tconst callbacks = this.listeners.get(event)!;\n\t\t\tconst index = callbacks.indexOf(callback);\n\n\t\t\tif (index !== -1) {\n\t\t\t\tcallbacks.splice(index, 1);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Emit an event\n\t * @param event Event name\n\t * @param args Arguments to pass to listeners\n\t */\n\tprotected emit(event: InitializableEvent, ...args: any[]): void {\n\t\tif (this.listeners.has(event)) {\n\t\t\tconst callbacks = [...this.listeners.get(event)!];\n\t\t\tcallbacks.forEach((callback) => {\n\t\t\t\ttry {\n\t\t\t\t\tcallback(...args);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(`Error in ${event} event listener:`, error);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the abort signal for cancellation\n\t * Can be passed to fetch or other cancellable operations\n\t */\n\tprotected get abortSignal(): AbortSignal | undefined {\n\t\treturn this.abortController?.signal;\n\t}\n\n\t/**\n\t * Check if initialization has been completed\n\t */\n\tpublic get initialized(): boolean {\n\t\treturn this._initialized;\n\t}\n\n\t/**\n\t * Check if initialization is in progress\n\t */\n\tpublic get isInitializing(): boolean {\n\t\treturn this.initializing;\n\t}\n\n\t/**\n\t * Check if initialization has failed\n\t */\n\tpublic get hasFailed(): boolean {\n\t\treturn this.failed;\n\t}\n}\n\nexport default Initializable;\n",
11
+ "// Error code enums\nexport enum ERROR_CODE {\n\tNO_REQUEST = -1,\n\tUNKNOWN_ERROR = 0,\n\tINVALID_METHOD = 1,\n\tINVALID_REQUEST = 2,\n\tINVALID_CONTROLLER = 3,\n\tINVALID_ACTION = 4,\n\tNO_ACTION_IN_MAP = 5,\n\tNO_METHOD_HANDLER = 6,\n\tINVALID_METHOD_INPUT = 7,\n\tREQ_BODY_EMPTY = 8,\n}\n\nexport enum HTTP_ERROR_CODE {\n\tOK = 200,\n\tBAD_REQUEST = 400,\n\tUNAUTHORIZED = 401,\n\tFORBIDDEN = 403,\n\tNOT_FOUND = 404,\n\tINTERNAL_SERVER_ERROR = 500,\n}\n\nexport enum WS_ERROR_CODE {\n\t// WebSocket close event codes\n\tNORMAL_CLOSURE = 1000,\n\tGOING_AWAY = 1001,\n\tPROTOCOL_ERROR = 1002,\n\tUNSUPPORTED_DATA = 1003,\n\tNO_STATUS_RECEIVED = 1005,\n\tABNORMAL_CLOSURE = 1006,\n\tINVALID_FRAME_PAYLOAD_DATA = 1007,\n\tPOLICY_VIOLATION = 1008,\n\tMESSAGE_TOO_BIG = 1009,\n\tMISSING_EXTENSION = 1010,\n\tINTERNAL_ERROR = 1011,\n\tSERVICE_RESTART = 1012,\n\tTRY_AGAIN_LATER = 1013,\n\tBAD_GATEWAY = 1014,\n\tTLS_HANDSHAKE = 1015,\n}\n",
12
+ "import { Throwable } from \"..\";\nimport { ERROR_CODE } from \"../errors\";\nimport { Debug } from \"../lib\";\nimport Controller from \"../server/controller\";\nimport { Routes } from \"./routes\";\n\nclass Router_Internal {\n\tprivate registry = new Map<string, Controller>();\n\tprivate routes: Routes;\n\n\tconstructor(routes?: Routes) {\n\t\tthis.routes = routes ?? {};\n\t}\n\n\tasync post<T>(req: Request): Promise<T> {\n\t\treturn await this.handleRequest(req);\n\t}\n\n\tasync get<T>(req: Request): Promise<T> {\n\t\treturn await this.handleRequest(req);\n\t}\n\n\tprivate async handleRequest<T>(request: Request): Promise<T> {\n\t\tconst path = this.getPath(request);\n\t\tconst output = await this.resolve(path).call<T>(request);\n\t\treturn output;\n\t}\n\n\tprivate getPath(request: Request): string {\n\t\treturn new URL(request.url).pathname;\n\t}\n\n\tprivate resolve(path: string): Controller {\n\t\tconst controllerKey = path.split(\"/\")[1];\n\t\treturn this.register(controllerKey, () => this.controllerFactory(controllerKey));\n\t}\n\n\tprivate register(controllerKey: string, factory: () => Controller): Controller {\n\t\tif (!this.registry.has(controllerKey)) {\n\t\t\tthis.registry.set(controllerKey, factory());\n\t\t\tDebug.Log(`Caching controller: /${controllerKey}`);\n\t\t}\n\t\treturn this.registry.get(controllerKey) as Controller;\n\t}\n\n\tpublic setRoutes(routes: Routes): void {\n\t\tthis.routes = routes;\n\t}\n\n\tprivate controllerFactory(controllerKey: string): Controller {\n\t\tif (!(controllerKey in this.routes)) throw new Throwable(`${ERROR_CODE.INVALID_CONTROLLER}: ${controllerKey}`, { logError: false });\n\n\t\tconst ControllerClass = this.routes[controllerKey as keyof typeof this.routes];\n\n\t\treturn new ControllerClass();\n\t}\n}\n\nexport default Router_Internal;\n",
13
+ "/**\n * Type representing a constructor function or class type\n */\nexport type Constructor<T> = new (...args: any[]) => T;\n\n/**\n * Type for a singleton constructor with static methods\n */\nexport type SingletonConstructor<T extends Singleton> = Constructor<T> & typeof Singleton;\n\n/**\n * Enhanced interface for singleton classes, providing type-safe instance management\n */\nexport interface SingletonClass<T extends Singleton> {\n\tnew (...args: any[]): T;\n\tGetInstance<U extends T>(...args: any[]): U;\n\tHasInstance(): boolean;\n\tClearInstance(): boolean;\n\tCreateFactory<U extends T>(...args: any[]): () => U;\n}\n\n/**\n * Base class for implementing the singleton pattern with type-safe instance management.\n * Supports constructors with any number of arguments.\n *\n * @example\n * // No constructor arguments\n * class DatabaseExample extends Singleton {\n * private constructor() { super(); }\n * public static connect() {\n * return this.getInstance();\n * }\n * }\n *\n * @example\n * // With constructor arguments\n * class EncryptionServiceExample extends Singleton {\n * private constructor(key: string, algorithm: string) { super(); }\n * public static create(key: string, algorithm: string) {\n * return this.getInstance(key, algorithm);\n * }\n * }\n *\n * @example\n * // Lazy initialization with factory function\n * class ConfigService extends Singleton {\n * private constructor(configPath: string) {\n * super();\n * // Heavy initialization work\n * }\n *\n * public static createLazy(configPath: string) {\n * return this.createFactory(configPath);\n * }\n * }\n */\nabstract class Singleton {\n\t// Using WeakMap allows garbage collection when no references remain to the class\n\tprivate static readonly instances = new WeakMap<Constructor<any>, Singleton>();\n\n\t// Lock to prevent concurrent initialization in worker environments\n\tprivate static readonly initializationLocks = new WeakMap<Constructor<any>, boolean>();\n\n\t// Track active instances for debugging and testing\n\tprivate static readonly activeInstances: Map<string, Constructor<any>> = new Map();\n\n\t/**\n\t * Protected constructor to prevent direct instantiation\n\t */\n\tprotected constructor() {\n\t\t// Ensure the constructor is only called from getInstance\n\t\tconst constructorName = this.constructor.name;\n\t\tconst callerName = new Error().stack?.split(\"\\n\")[2]?.trim() || \"\";\n\n\t\tif (!callerName.includes(\"getInstance\")) {\n\t\t\tconsole.warn(`${constructorName} is a singleton and should be accessed via ${constructorName}.getInstance()`);\n\t\t}\n\t}\n\n\t/**\n\t * Gets the singleton instance of the class\n\t * Creates a new instance if one doesn't exist\n\t * @throws Error if concurrent initialization is detected\n\t */\n\tpublic static GetInstance<T extends Singleton>(this: Constructor<T>, ...args: any[]): T {\n\t\tconst classReference = this;\n\n\t\t// Fast path: return existing instance if available\n\t\tif (Singleton.instances.has(classReference)) {\n\t\t\treturn Singleton.instances.get(classReference) as T;\n\t\t}\n\n\t\t// Protection for worker thread environments\n\t\tif (Singleton.initializationLocks.get(classReference)) {\n\t\t\tthrow new Error(`Concurrent initialization of ${classReference.name} singleton detected`);\n\t\t}\n\n\t\ttry {\n\t\t\tSingleton.initializationLocks.set(classReference, true);\n\n\t\t\t// Double-check pattern to handle race conditions\n\t\t\tif (!Singleton.instances.has(classReference)) {\n\t\t\t\tconst instance = new classReference(...args);\n\t\t\t\tSingleton.instances.set(classReference, instance);\n\t\t\t\t// Track the instance for debugging\n\t\t\t\tSingleton.activeInstances.set(classReference.name, classReference);\n\t\t\t}\n\n\t\t\treturn Singleton.instances.get(classReference) as T;\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to initialize ${classReference.name} singleton: ${error instanceof Error ? error.message : String(error)}`);\n\t\t} finally {\n\t\t\tSingleton.initializationLocks.delete(classReference);\n\t\t}\n\t}\n\n\t/**\n\t * Checks if an instance already exists\n\t */\n\tpublic static HasInstance<T extends Singleton>(this: Constructor<T>): boolean {\n\t\treturn Singleton.instances.has(this);\n\t}\n\n\t/**\n\t * Clears the instance (useful for testing or resource cleanup)\n\t * @returns true if an instance was cleared, false if no instance existed\n\t */\n\tpublic static ClearInstance<T extends Singleton>(this: Constructor<T>): boolean {\n\t\tconst hadInstance = Singleton.instances.has(this);\n\t\tSingleton.instances.delete(this);\n\t\tSingleton.activeInstances.delete(this.name);\n\t\treturn hadInstance;\n\t}\n\n\t/**\n\t * Creates a factory function for lazy initialization\n\t */\n\tpublic static CreateFactory<T extends Singleton>(this: SingletonConstructor<T>, ...args: any[]): () => T {\n\t\tconst classReference = this;\n\t\treturn () => classReference.GetInstance(...args);\n\t}\n\n\t/**\n\t * Clears all singleton instances\n\t * Primarily used for testing or application shutdown\n\t */\n\tpublic static ClearAllInstances(): void {\n\t\tconst instanceCount = Singleton.GetInstanceCount();\n\n\t\t// Clear the WeakMap by removing all references\n\t\tSingleton.activeInstances.forEach((constructor) => {\n\t\t\tSingleton.instances.delete(constructor);\n\t\t});\n\n\t\t// Clear the tracking map\n\t\tSingleton.activeInstances.clear();\n\n\t\tconsole.log(`Cleared ${instanceCount} singleton instances`);\n\t}\n\n\t/**\n\t * Gets the count of active singleton instances\n\t * Useful for debugging and testing\n\t */\n\tpublic static GetInstanceCount(): number {\n\t\treturn Singleton.activeInstances.size;\n\t}\n\n\t/**\n\t * Gets the list of active singleton class names\n\t * Useful for debugging and testing\n\t */\n\tpublic static GetActiveInstanceNames(): string[] {\n\t\treturn Array.from(Singleton.activeInstances.keys());\n\t}\n}\n\nexport default Singleton;\n",
14
+ "import { ERROR_CODE } from \"../errors\";\nimport Guards from \"../guards\";\nimport Singleton from \"../singleton\";\nimport Router_Internal from \"./router.internal\";\nimport { Routes } from \"./routes\";\n\ntype MethodMap<T> = {\n\t[method: string]: (req: Request) => Promise<T>;\n};\n\nclass Router extends Singleton {\n\tprivate internal: Router_Internal;\n\n\tpublic constructor(routes?: Routes) {\n\t\tsuper();\n\t\tthis.internal = new Router_Internal(routes);\n\t}\n\n\tprivate setRoutes(routes: Routes): void {\n\t\tthis.internal.setRoutes(routes);\n\t}\n\n\tpublic static async Call<T>(request: Request): Promise<T> {\n\t\tif (Guards.IsNil(request)) throw ERROR_CODE.NO_REQUEST;\n\t\tconst methods: MethodMap<T> = this.getMethodMap();\n\t\tconst method = methods[request.method];\n\n\t\tif (Guards.IsNil(method)) throw ERROR_CODE.INVALID_METHOD;\n\n\t\treturn await method(request);\n\t}\n\n\tpublic static SetRoutes(routes: Routes) {\n\t\tRouter.GetInstance().setRoutes(routes);\n\t}\n\n\tprivate static getMethodMap<T>(): MethodMap<T> {\n\t\tconst router = Router.GetInstance();\n\t\treturn {\n\t\t\tGET: async (req) => await router.internal.get(req),\n\t\t\tPOST: async (req) => await router.internal.post(req),\n\t\t};\n\t}\n\n\tpublic static GetQueryParams(request: Request): URLSearchParams {\n\t\tconst url = new URL(request.url);\n\t\treturn url.searchParams;\n\t}\n}\n\nexport default Router;\n",
15
+ "import { ERROR_CODE } from \"../errors\";\nimport Guards from \"../guards\";\nimport Initializable, { InitializableOptions } from \"../initializable\";\nimport { I_ApplicationResponse } from \"../types\";\n\nexport type ControllerResponse<T = unknown> = Promise<I_ApplicationResponse<T> | PromiseLike<I_ApplicationResponse<T>>>;\nexport type ControllerAction<T> = (req: Request) => ControllerResponse<T>;\nexport type ControllerMap<T = unknown> = Map<string, ControllerAction<T>>;\nexport type ControllerOptions<T = unknown> = InitializableOptions & {\n\tpath: string | undefined;\n\tpost: Map<string, ControllerAction<T>>;\n\tget: ControllerMap<T>;\n\tcontrollerMap: Map<string, ControllerMap<T>>;\n};\n\nexport default abstract class Controller extends Initializable {\n\tpath: string | undefined;\n\tpost: Map<string, ControllerAction<any>> = new Map();\n\tget: ControllerMap = new Map();\n\tcontrollerMap: Map<string, ControllerMap> = new Map();\n\n\tprotected constructor(options: ControllerOptions) {\n\t\tsuper(options);\n\t\tthis.POST();\n\t\tthis.GET();\n\t\tthis.setControllerMap();\n\t}\n\n\tpublic static Create<T>(this: new () => T): T {\n\t\treturn new this();\n\t}\n\n\tpublic static async AsyncCreate<T>(this: new () => T): Promise<T> {\n\t\treturn new this();\n\t}\n\n\tpublic async call<T>(request: Request): Promise<T> {\n\t\tawait this.isInitialized();\n\t\tconst action = this.resolve(request);\n\t\treturn await action(request);\n\t}\n\n\tprivate setControllerMap() {\n\t\tthis.controllerMap.set(\"GET\", this.get);\n\t\tthis.controllerMap.set(\"POST\", this.post);\n\t}\n\n\tprivate resolve(req: Request): Function {\n\t\tconst url = new URL(req.url);\n\t\tconst endpointArray = url.pathname.split(\"/\");\n\t\tconst actionName = endpointArray.slice(2).join(\"/\");\n\n\t\tif (!Guards.IsString(actionName, true)) throw ERROR_CODE.INVALID_ACTION;\n\n\t\tconst methodMap = this.controllerMap.get(req.method);\n\n\t\tif (Guards.IsNil(methodMap)) {\n\t\t\tthrow ERROR_CODE.INVALID_METHOD;\n\t\t}\n\n\t\treturn this.resolveAction(methodMap, actionName);\n\t}\n\n\tprivate resolveAction(methodMap: ControllerMap, actionName: string) {\n\t\tconst action = methodMap.get(actionName) as Function;\n\n\t\tif (!Guards.IsFunction(action, true)) {\n\t\t\tthrow ERROR_CODE.NO_ACTION_IN_MAP;\n\t\t}\n\n\t\treturn action;\n\t}\n\n\t/**\n\t * Abstract method that needs to be implemented in derived classes.\n\t * This method is used to map post actions to their corresponding handler methods.\n\t *\n\t * Each action is a string that represents a specific operation, and the handler is a function that performs this operation.\n\t * The handler is bound to the current context (`this`) to ensure it has access to the class's properties and methods.\n\t *\n\t * Example implementation:\n\t *\n\t * ```typescript\n\t * setActionsMap() {\n\t * this.post.set(\"action\", this.controllerMethod.bind(this));\n\t * }\n\t * ```\n\t *\n\t * In this example, when \"https://webserver_url:port/controller/action\" is called by the router, the `controllerMethod` method will be called.\n\t */\n\tabstract POST(): void;\n\n\t/**\n\t * Abstract method that needs to be implemented in derived classes.\n\t * This method is used to map actions to their corresponding handler methods.\n\t *\n\t * Each action is a string that represents a specific operation, and the handler is a function that performs this operation.\n\t * The handler is bound to the current context (`this`) to ensure it has access to the class's properties and methods.\n\t *\n\t * Example implementation:\n\t *\n\t * ```typescript\n\t * setActionsMap() {\n\t * this.get.set(\"action\", this.controllerMethod.bind(this));\n\t * }\n\t * ```\n\t *\n\t * In this example, when \"https://webserver_url:port/controller/action\" is called by the router, the `controllerMethod` method will be called.\n\t */\n\tabstract GET(): void;\n}\n",
16
+ "export const DEFAULT_FALSE_RESPONSE = \"Something went wrong. Please try again later.\";\n\nexport const LOG_COLORS = {\n\treset: \"\\x1b[0m\",\n\tbright: \"\\x1b[1m\",\n\tdim: \"\\x1b[2m\",\n\tunderscore: \"\\x1b[4m\",\n\tblink: \"\\x1b[5m\",\n\treverse: \"\\x1b[7m\",\n\thidden: \"\\x1b[8m\",\n\n\ttext: {\n\t\tblack: \"\\x1b[30m\",\n\t\tred: \"\\x1b[31m\",\n\t\tgreen: \"\\x1b[32m\",\n\t\tyellow: \"\\x1b[33m\",\n\t\tblue: \"\\x1b[34m\",\n\t\tmagenta: \"\\x1b[35m\",\n\t\tcyan: \"\\x1b[36m\",\n\t\twhite: \"\\x1b[37m\",\n\t},\n\tbg: {\n\t\tblack: \"\\x1b[40m\",\n\t\tred: \"\\x1b[41m\",\n\t\tgreen: \"\\x1b[42m\",\n\t\tyellow: \"\\x1b[43m\",\n\t\tblue: \"\\x1b[44m\",\n\t\tmagenta: \"\\x1b[45m\",\n\t\tcyan: \"\\x1b[46m\",\n\t\twhite: \"\\x1b[47m\",\n\t},\n};\n",
17
+ "import Controller from \"../server/controller\";\n\nexport type Routes = {\n\t[key: string]: new () => Controller;\n};\n\nexport const routes: Routes = {};\n"
18
+ ],
19
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,gBAAgB,CAAC,QAAiB,YAAwC;AAAA,EACtF,OAAO;AAAA,IACN,QAAQ,UAAU;AAAA,IAClB,SAAS;AAAA,MACR,gBAAgB;AAAA,MAChB,gCAAgC;AAAA,MAChC,gCAAgC;AAAA,MAChC,oCAAoC;AAAA,IACrC;AAAA,EACD;AAAA;AAGM,IAAM,0BAA0B;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AACR;AAAA;AAEA,MAAM,YAAY;AAAA,SACH,QAAW,CAAC,MAAS,SAAi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,KAAK,cAAc,IAAI,IAAI,MAAM;AAAA,IAEnD,IAAI,eAAO,MAAM,SAAS,GAAG;AAAA,MAC5B;AAAA,IACD;AAAA,IAEA,OAAO,KAAK,cAAc,WAAW,UAAU;AAAA;AAAA,EAGxC,aAAa,CAAC,WAA0B,YAAoB;AAAA,IACnE,MAAM,SAAS,UAAU,IAAI,UAAU;AAAA,IAEvC,KAAK,eAAO,WAAW,QAAQ,IAAI,GAAG;AAAA,MACrC;AAAA,IACD;AAAA,IAEA,OAAO;AAAA;AAwCT;;AC9GO,IAAM,yBAAyB;AAE/B,IAAM,aAAa;AAAA,EACzB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EAER,MAAM;AAAA,IACL,OAAO;AAAA,IACP,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACH,OAAO;AAAA,IACP,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AACD;;;;;;;;;;ACzBO,IAAM,SAAiB,CAAC;",
20
+ "debugId": "0B1F55E649341FB164756E2164756E21",
21
+ "names": []
22
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Configuration options for initialization
3
3
  */
4
- export interface InitOptions {
4
+ export interface InitializableOptions {
5
5
  /** Number of retry attempts (default: 25) */
6
6
  retries?: number;
7
7
  /** Time in milliseconds between retry attempts (default: 200) */
@@ -60,7 +60,7 @@ declare class Initializable {
60
60
  * Creates a new Initializable instance
61
61
  * @param options Configuration options
62
62
  */
63
- constructor(options?: InitOptions);
63
+ constructor(options?: InitializableOptions);
64
64
  /**
65
65
  * Initialize the object
66
66
  * @returns Promise that resolves when initialization is complete
@@ -1,5 +1,5 @@
1
- export * from "./router.internal";
2
- export { default as Router_internal } from "./router.internal";
1
+ export * from "./routes";
3
2
  export * from "./router";
4
3
  export { default as Router } from "./router";
5
- export * from "./routes";
4
+ export * from "./router.internal";
5
+ export { default as Router_internal } from "./router.internal";
@@ -1,11 +1,8 @@
1
- import { Controller } from "./routes";
2
1
  import Singleton from "../singleton";
3
- export type Routes = {
4
- [key: string]: new () => Controller;
5
- };
2
+ import { Routes } from "./routes";
6
3
  declare class Router extends Singleton {
7
4
  private internal;
8
- constructor();
5
+ constructor(routes?: Routes);
9
6
  private setRoutes;
10
7
  static Call<T>(request: Request): Promise<T>;
11
8
  static SetRoutes(routes: Routes): void;
@@ -1,7 +1,8 @@
1
- import type { Routes } from "./router";
1
+ import { Routes } from "./routes";
2
2
  declare class Router_Internal {
3
3
  private registry;
4
4
  private routes;
5
+ constructor(routes?: Routes);
5
6
  post<T>(req: Request): Promise<T>;
6
7
  get<T>(req: Request): Promise<T>;
7
8
  private handleRequest;
@@ -1,5 +1,5 @@
1
- import type { Routes } from "./router";
1
+ import Controller from "../server/controller";
2
+ export type Routes = {
3
+ [key: string]: new () => Controller;
4
+ };
2
5
  export declare const routes: Routes;
3
- export declare class Controller {
4
- call: any;
5
- }
@@ -0,0 +1,60 @@
1
+ import Initializable, { InitializableOptions } from "../initializable";
2
+ import { I_ApplicationResponse } from "../types";
3
+ export type ControllerResponse<T = unknown> = Promise<I_ApplicationResponse<T> | PromiseLike<I_ApplicationResponse<T>>>;
4
+ export type ControllerAction<T> = (req: Request) => ControllerResponse<T>;
5
+ export type ControllerMap<T = unknown> = Map<string, ControllerAction<T>>;
6
+ export type ControllerOptions<T = unknown> = InitializableOptions & {
7
+ path: string | undefined;
8
+ post: Map<string, ControllerAction<T>>;
9
+ get: ControllerMap<T>;
10
+ controllerMap: Map<string, ControllerMap<T>>;
11
+ };
12
+ export default abstract class Controller extends Initializable {
13
+ path: string | undefined;
14
+ post: Map<string, ControllerAction<any>>;
15
+ get: ControllerMap;
16
+ controllerMap: Map<string, ControllerMap>;
17
+ protected constructor(options: ControllerOptions);
18
+ static Create<T>(this: new () => T): T;
19
+ static AsyncCreate<T>(this: new () => T): Promise<T>;
20
+ call<T>(request: Request): Promise<T>;
21
+ private setControllerMap;
22
+ private resolve;
23
+ private resolveAction;
24
+ /**
25
+ * Abstract method that needs to be implemented in derived classes.
26
+ * This method is used to map post actions to their corresponding handler methods.
27
+ *
28
+ * Each action is a string that represents a specific operation, and the handler is a function that performs this operation.
29
+ * The handler is bound to the current context (`this`) to ensure it has access to the class's properties and methods.
30
+ *
31
+ * Example implementation:
32
+ *
33
+ * ```typescript
34
+ * setActionsMap() {
35
+ * this.post.set("action", this.controllerMethod.bind(this));
36
+ * }
37
+ * ```
38
+ *
39
+ * In this example, when "https://webserver_url:port/controller/action" is called by the router, the `controllerMethod` method will be called.
40
+ */
41
+ abstract POST(): void;
42
+ /**
43
+ * Abstract method that needs to be implemented in derived classes.
44
+ * This method is used to map actions to their corresponding handler methods.
45
+ *
46
+ * Each action is a string that represents a specific operation, and the handler is a function that performs this operation.
47
+ * The handler is bound to the current context (`this`) to ensure it has access to the class's properties and methods.
48
+ *
49
+ * Example implementation:
50
+ *
51
+ * ```typescript
52
+ * setActionsMap() {
53
+ * this.get.set("action", this.controllerMethod.bind(this));
54
+ * }
55
+ * ```
56
+ *
57
+ * In this example, when "https://webserver_url:port/controller/action" is called by the router, the `controllerMethod` method will be called.
58
+ */
59
+ abstract GET(): void;
60
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./controller";
2
+ export { default as Controller } from "./controller";
package/dist/types.d.ts CHANGED
@@ -6,4 +6,9 @@ export type KVObj<T> = {
6
6
  key: string;
7
7
  value: T;
8
8
  };
9
+ export interface I_ApplicationResponse<T = unknown> {
10
+ status: boolean | number;
11
+ data: T;
12
+ error?: T;
13
+ }
9
14
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topsyde-utils",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A bundle of TypeScript utility classes and functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,10 +10,12 @@
10
10
  "scripts": {
11
11
  "clean": "rimraf dist",
12
12
  "format": "prettier --cache --write \"**/*.ts\"",
13
+ "format:generated": "prettier --cache --write \"src/index.ts\" \"src/*/index.ts\"",
13
14
  "lint": "eslint . --ext .ts --cache",
14
15
  "generate-indexes": "./scripts/generate-indexes.sh",
15
- "prebuild": "bun run clean && bun run generate-indexes && bun run format",
16
- "build": "bun run tsc",
16
+ "prebuild": "bun run clean && bun run generate-indexes",
17
+ "build": "bun build ./src/index.ts --outdir ./dist --target node --format cjs --sourcemap && bun run format:generated && bun tsc --emitDeclarationOnly --declaration --outDir ./dist",
18
+ "build:fast": "bun build ./src/index.ts --outdir ./dist --target node --format cjs",
17
19
  "test": "bun test",
18
20
  "prepublishOnly": "bun run build",
19
21
  "prepare": "bun run build",
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RESPONSE_METHOD_OPTIONS = exports.RESPONSE_INIT = void 0;
4
- const RESPONSE_INIT = (status, headers) => {
5
- return {
6
- status: status ?? 200,
7
- headers: {
8
- "Content-Type": "application/json",
9
- "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
10
- "Access-Control-Allow-Headers": "Content-Type, Authorization",
11
- "Access-Control-Allow-Credentials": "true",
12
- },
13
- };
14
- };
15
- exports.RESPONSE_INIT = RESPONSE_INIT;
16
- exports.RESPONSE_METHOD_OPTIONS = {
17
- name: "Access-Control-Max-Age",
18
- value: "86400",
19
- };
20
- class Application {
21
- static Response(data, status = 200, headers) {
22
- return Response.json({ status: true, data }, (0, exports.RESPONSE_INIT)(status, headers));
23
- }
24
- static Error(error, status = 200, headers) {
25
- return Response.json({ status: false, error }, (0, exports.RESPONSE_INIT)(status, headers));
26
- }
27
- static Throw(error, status = 400, headers) {
28
- return Response.json(error, (0, exports.RESPONSE_INIT)(status, headers));
29
- }
30
- }
31
- exports.default = Application;
32
- //# sourceMappingURL=application.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAAC,MAAe,EAAE,OAAqB,EAAgB,EAAE;IACrF,OAAO;QACN,MAAM,EAAE,MAAM,IAAI,GAAG;QACrB,OAAO,EAAE;YACR,cAAc,EAAE,kBAAkB;YAClC,8BAA8B,EAAE,oBAAoB;YACpD,8BAA8B,EAAE,6BAA6B;YAC7D,kCAAkC,EAAE,MAAM;SAC1C;KACD,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB;AAEW,QAAA,uBAAuB,GAAG;IACtC,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE,OAAO;CACd,CAAC;AAEF,MAAM,WAAW;IACT,MAAM,CAAC,QAAQ,CAAC,IAAS,EAAE,SAAiB,GAAG,EAAE,OAAqB;QAC5E,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAA,qBAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEM,MAAM,CAAC,KAAK,CAAuC,KAAQ,EAAE,SAAiB,GAAG,EAAE,OAAqB;QAC9G,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAA,qBAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChF,CAAC;IAEM,MAAM,CAAC,KAAK,CAAuC,KAAQ,EAAE,SAAiB,GAAG,EAAE,OAAqB;QAC9G,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAA,qBAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7D,CAAC;CACD;AAED,kBAAe,WAAW,CAAC"}
package/dist/consts.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LOG_COLORS = exports.DEFAULT_FALSE_RESPONSE = void 0;
4
- exports.DEFAULT_FALSE_RESPONSE = "Something went wrong. Please try again later.";
5
- exports.LOG_COLORS = {
6
- reset: "\x1b[0m",
7
- bright: "\x1b[1m",
8
- dim: "\x1b[2m",
9
- underscore: "\x1b[4m",
10
- blink: "\x1b[5m",
11
- reverse: "\x1b[7m",
12
- hidden: "\x1b[8m",
13
- text: {
14
- black: "\x1b[30m",
15
- red: "\x1b[31m",
16
- green: "\x1b[32m",
17
- yellow: "\x1b[33m",
18
- blue: "\x1b[34m",
19
- magenta: "\x1b[35m",
20
- cyan: "\x1b[36m",
21
- white: "\x1b[37m",
22
- },
23
- bg: {
24
- black: "\x1b[40m",
25
- red: "\x1b[41m",
26
- green: "\x1b[42m",
27
- yellow: "\x1b[43m",
28
- blue: "\x1b[44m",
29
- magenta: "\x1b[45m",
30
- cyan: "\x1b[46m",
31
- white: "\x1b[47m",
32
- },
33
- };
34
- //# sourceMappingURL=consts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,+CAA+C,CAAC;AAEzE,QAAA,UAAU,GAAG;IACzB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IAEjB,IAAI,EAAE;QACL,KAAK,EAAE,UAAU;QACjB,GAAG,EAAE,UAAU;QACf,KAAK,EAAE,UAAU;QACjB,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KACjB;IACD,EAAE,EAAE;QACH,KAAK,EAAE,UAAU;QACjB,GAAG,EAAE,UAAU;QACf,KAAK,EAAE,UAAU;QACjB,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KACjB;CACD,CAAC"}
package/dist/enums.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.E_ENVIRONMENTS = exports.E_IS = void 0;
4
- var E_IS;
5
- (function (E_IS) {
6
- E_IS["ARRAY"] = "array";
7
- E_IS["OBJECT"] = "object";
8
- E_IS["FUNCTION"] = "function";
9
- E_IS["STRING"] = "string";
10
- E_IS["NUMBER"] = "number";
11
- E_IS["BOOLEAN"] = "boolean";
12
- E_IS["REGEX"] = "regex";
13
- })(E_IS || (exports.E_IS = E_IS = {}));
14
- var E_ENVIRONMENTS;
15
- (function (E_ENVIRONMENTS) {
16
- E_ENVIRONMENTS["DEV"] = "development";
17
- E_ENVIRONMENTS["PROD"] = "production";
18
- })(E_ENVIRONMENTS || (exports.E_ENVIRONMENTS = E_ENVIRONMENTS = {}));
19
- //# sourceMappingURL=enums.js.map
package/dist/enums.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":";;;AAAA,IAAY,IAQX;AARD,WAAY,IAAI;IACf,uBAAe,CAAA;IACf,yBAAiB,CAAA;IACjB,6BAAqB,CAAA;IACrB,yBAAiB,CAAA;IACjB,yBAAiB,CAAA;IACjB,2BAAmB,CAAA;IACnB,uBAAe,CAAA;AAChB,CAAC,EARW,IAAI,oBAAJ,IAAI,QAQf;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACzB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;AACpB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB"}
package/dist/errors.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WS_ERROR_CODE = exports.HTTP_ERROR_CODE = exports.ERROR_CODE = void 0;
4
- // Error code enums
5
- var ERROR_CODE;
6
- (function (ERROR_CODE) {
7
- ERROR_CODE[ERROR_CODE["NO_REQUEST"] = -1] = "NO_REQUEST";
8
- ERROR_CODE[ERROR_CODE["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9
- ERROR_CODE[ERROR_CODE["INVALID_METHOD"] = 1] = "INVALID_METHOD";
10
- ERROR_CODE[ERROR_CODE["INVALID_REQUEST"] = 2] = "INVALID_REQUEST";
11
- ERROR_CODE[ERROR_CODE["INVALID_CONTROLLER"] = 3] = "INVALID_CONTROLLER";
12
- ERROR_CODE[ERROR_CODE["INVALID_ACTION"] = 4] = "INVALID_ACTION";
13
- ERROR_CODE[ERROR_CODE["NO_ACTION_IN_MAP"] = 5] = "NO_ACTION_IN_MAP";
14
- ERROR_CODE[ERROR_CODE["NO_METHOD_HANDLER"] = 6] = "NO_METHOD_HANDLER";
15
- ERROR_CODE[ERROR_CODE["INVALID_METHOD_INPUT"] = 7] = "INVALID_METHOD_INPUT";
16
- ERROR_CODE[ERROR_CODE["REQ_BODY_EMPTY"] = 8] = "REQ_BODY_EMPTY";
17
- })(ERROR_CODE || (exports.ERROR_CODE = ERROR_CODE = {}));
18
- var HTTP_ERROR_CODE;
19
- (function (HTTP_ERROR_CODE) {
20
- HTTP_ERROR_CODE[HTTP_ERROR_CODE["OK"] = 200] = "OK";
21
- HTTP_ERROR_CODE[HTTP_ERROR_CODE["BAD_REQUEST"] = 400] = "BAD_REQUEST";
22
- HTTP_ERROR_CODE[HTTP_ERROR_CODE["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
23
- HTTP_ERROR_CODE[HTTP_ERROR_CODE["FORBIDDEN"] = 403] = "FORBIDDEN";
24
- HTTP_ERROR_CODE[HTTP_ERROR_CODE["NOT_FOUND"] = 404] = "NOT_FOUND";
25
- HTTP_ERROR_CODE[HTTP_ERROR_CODE["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
26
- })(HTTP_ERROR_CODE || (exports.HTTP_ERROR_CODE = HTTP_ERROR_CODE = {}));
27
- var WS_ERROR_CODE;
28
- (function (WS_ERROR_CODE) {
29
- // WebSocket close event codes
30
- WS_ERROR_CODE[WS_ERROR_CODE["NORMAL_CLOSURE"] = 1000] = "NORMAL_CLOSURE";
31
- WS_ERROR_CODE[WS_ERROR_CODE["GOING_AWAY"] = 1001] = "GOING_AWAY";
32
- WS_ERROR_CODE[WS_ERROR_CODE["PROTOCOL_ERROR"] = 1002] = "PROTOCOL_ERROR";
33
- WS_ERROR_CODE[WS_ERROR_CODE["UNSUPPORTED_DATA"] = 1003] = "UNSUPPORTED_DATA";
34
- WS_ERROR_CODE[WS_ERROR_CODE["NO_STATUS_RECEIVED"] = 1005] = "NO_STATUS_RECEIVED";
35
- WS_ERROR_CODE[WS_ERROR_CODE["ABNORMAL_CLOSURE"] = 1006] = "ABNORMAL_CLOSURE";
36
- WS_ERROR_CODE[WS_ERROR_CODE["INVALID_FRAME_PAYLOAD_DATA"] = 1007] = "INVALID_FRAME_PAYLOAD_DATA";
37
- WS_ERROR_CODE[WS_ERROR_CODE["POLICY_VIOLATION"] = 1008] = "POLICY_VIOLATION";
38
- WS_ERROR_CODE[WS_ERROR_CODE["MESSAGE_TOO_BIG"] = 1009] = "MESSAGE_TOO_BIG";
39
- WS_ERROR_CODE[WS_ERROR_CODE["MISSING_EXTENSION"] = 1010] = "MISSING_EXTENSION";
40
- WS_ERROR_CODE[WS_ERROR_CODE["INTERNAL_ERROR"] = 1011] = "INTERNAL_ERROR";
41
- WS_ERROR_CODE[WS_ERROR_CODE["SERVICE_RESTART"] = 1012] = "SERVICE_RESTART";
42
- WS_ERROR_CODE[WS_ERROR_CODE["TRY_AGAIN_LATER"] = 1013] = "TRY_AGAIN_LATER";
43
- WS_ERROR_CODE[WS_ERROR_CODE["BAD_GATEWAY"] = 1014] = "BAD_GATEWAY";
44
- WS_ERROR_CODE[WS_ERROR_CODE["TLS_HANDSHAKE"] = 1015] = "TLS_HANDSHAKE";
45
- })(WS_ERROR_CODE || (exports.WS_ERROR_CODE = WS_ERROR_CODE = {}));
46
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,mBAAmB;AACnB,IAAY,UAWX;AAXD,WAAY,UAAU;IACrB,wDAAe,CAAA;IACf,6DAAiB,CAAA;IACjB,+DAAkB,CAAA;IAClB,iEAAmB,CAAA;IACnB,uEAAsB,CAAA;IACtB,+DAAkB,CAAA;IAClB,mEAAoB,CAAA;IACpB,qEAAqB,CAAA;IACrB,2EAAwB,CAAA;IACxB,+DAAkB,CAAA;AACnB,CAAC,EAXW,UAAU,0BAAV,UAAU,QAWrB;AAED,IAAY,eAOX;AAPD,WAAY,eAAe;IAC1B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,uEAAkB,CAAA;IAClB,iEAAe,CAAA;IACf,iEAAe,CAAA;IACf,yFAA2B,CAAA;AAC5B,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,aAiBX;AAjBD,WAAY,aAAa;IACxB,8BAA8B;IAC9B,wEAAqB,CAAA;IACrB,gEAAiB,CAAA;IACjB,wEAAqB,CAAA;IACrB,4EAAuB,CAAA;IACvB,gFAAyB,CAAA;IACzB,4EAAuB,CAAA;IACvB,gGAAiC,CAAA;IACjC,4EAAuB,CAAA;IACvB,0EAAsB,CAAA;IACtB,8EAAwB,CAAA;IACxB,wEAAqB,CAAA;IACrB,0EAAsB,CAAA;IACtB,0EAAsB,CAAA;IACtB,kEAAkB,CAAA;IAClB,sEAAoB,CAAA;AACrB,CAAC,EAjBW,aAAa,6BAAb,aAAa,QAiBxB"}
package/dist/guards.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const lib_1 = __importDefault(require("./lib"));
7
- class Guards {
8
- static IsString(value, excludeNull = false) {
9
- const output = lib_1.default.IsString(value);
10
- return excludeNull ? !Guards.IsNil(value) && output : output;
11
- }
12
- static IsNumber(value, excludeNull = false) {
13
- const output = lib_1.default.IsNumber(value);
14
- return excludeNull ? !Guards.IsNil(value) && output : output;
15
- }
16
- static IsBoolean(value, excludeNull = false) {
17
- const output = lib_1.default.GetType(value, true) === "boolean";
18
- return excludeNull ? !Guards.IsNil(value) && output : output;
19
- }
20
- static IsArray(value, excludeNull = false) {
21
- const output = lib_1.default.IsArray(value);
22
- return excludeNull ? !Guards.IsNil(value) && output : output;
23
- }
24
- static IsObject(value, excludeNull = false) {
25
- const output = lib_1.default.IsObject(value);
26
- return excludeNull ? !Guards.IsNil(value) && output : output;
27
- }
28
- static IsFunction(value, excludeNull = false) {
29
- const output = lib_1.default.IsFunction(value);
30
- return excludeNull ? !Guards.IsNil(value) && output : output;
31
- }
32
- static IsNil(value) {
33
- return lib_1.default.IsNil(value);
34
- }
35
- static IsType(obj, keys) {
36
- if (!keys)
37
- return !this.IsNil(obj);
38
- return keys.every((key) => key in obj);
39
- }
40
- }
41
- exports.default = Guards;
42
- //# sourceMappingURL=guards.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":";;;;;AACA,gDAAwB;AAExB,MAAM,MAAM;IAGJ,MAAM,CAAC,QAAQ,CAAC,KAAU,EAAE,cAAuB,KAAK;QAC9D,MAAM,MAAM,GAAG,aAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,WAAW,CAAC,CAA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