@mahameru/diatrema 0.0.0

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 (101) hide show
  1. package/README.md +1 -0
  2. package/container-error.cjs +45 -0
  3. package/container-error.cjs.map +1 -0
  4. package/container-error.d.cts +7 -0
  5. package/container-error.d.ts +7 -0
  6. package/container-error.js +22 -0
  7. package/container-error.js.map +1 -0
  8. package/container.cjs +322 -0
  9. package/container.cjs.map +1 -0
  10. package/container.d.cts +62 -0
  11. package/container.d.ts +62 -0
  12. package/container.js +289 -0
  13. package/container.js.map +1 -0
  14. package/diatrema.cjs +130 -0
  15. package/diatrema.cjs.map +1 -0
  16. package/diatrema.d.cts +73 -0
  17. package/diatrema.d.ts +71 -0
  18. package/diatrema.js +107 -0
  19. package/diatrema.js.map +1 -0
  20. package/event-emitter.cjs +68 -0
  21. package/event-emitter.cjs.map +1 -0
  22. package/event-emitter.d.cts +11 -0
  23. package/event-emitter.d.ts +11 -0
  24. package/event-emitter.js +45 -0
  25. package/event-emitter.js.map +1 -0
  26. package/helpers.cjs +93 -0
  27. package/helpers.cjs.map +1 -0
  28. package/helpers.d.cts +22 -0
  29. package/helpers.d.ts +22 -0
  30. package/helpers.js +67 -0
  31. package/helpers.js.map +1 -0
  32. package/http-server-error.cjs +44 -0
  33. package/http-server-error.cjs.map +1 -0
  34. package/http-server-error.d.cts +7 -0
  35. package/http-server-error.d.ts +7 -0
  36. package/http-server-error.js +21 -0
  37. package/http-server-error.js.map +1 -0
  38. package/http-server.cjs +382 -0
  39. package/http-server.cjs.map +1 -0
  40. package/http-server.d.cts +81 -0
  41. package/http-server.d.ts +81 -0
  42. package/http-server.js +359 -0
  43. package/http-server.js.map +1 -0
  44. package/index.cjs +66 -0
  45. package/index.cjs.map +1 -0
  46. package/index.d.cts +19 -0
  47. package/index.d.ts +19 -0
  48. package/index.js +19 -0
  49. package/index.js.map +1 -0
  50. package/logger.cjs +52 -0
  51. package/logger.cjs.map +1 -0
  52. package/logger.d.cts +9 -0
  53. package/logger.d.ts +9 -0
  54. package/logger.js +29 -0
  55. package/logger.js.map +1 -0
  56. package/mahameru-error.cjs +42 -0
  57. package/mahameru-error.cjs.map +1 -0
  58. package/mahameru-error.d.cts +5 -0
  59. package/mahameru-error.d.ts +5 -0
  60. package/mahameru-error.js +19 -0
  61. package/mahameru-error.js.map +1 -0
  62. package/mahameru-request.cjs +79 -0
  63. package/mahameru-request.cjs.map +1 -0
  64. package/mahameru-request.d.cts +3 -0
  65. package/mahameru-request.d.ts +3 -0
  66. package/mahameru-request.js +56 -0
  67. package/mahameru-request.js.map +1 -0
  68. package/mahameru-response.cjs +71 -0
  69. package/mahameru-response.cjs.map +1 -0
  70. package/mahameru-response.d.cts +17 -0
  71. package/mahameru-response.d.ts +17 -0
  72. package/mahameru-response.js +48 -0
  73. package/mahameru-response.js.map +1 -0
  74. package/mahameru-server-error.cjs +54 -0
  75. package/mahameru-server-error.cjs.map +1 -0
  76. package/mahameru-server-error.d.cts +19 -0
  77. package/mahameru-server-error.d.ts +19 -0
  78. package/mahameru-server-error.js +31 -0
  79. package/mahameru-server-error.js.map +1 -0
  80. package/module-error.cjs +46 -0
  81. package/module-error.cjs.map +1 -0
  82. package/module-error.d.cts +12 -0
  83. package/module-error.d.ts +12 -0
  84. package/module-error.js +23 -0
  85. package/module-error.js.map +1 -0
  86. package/package.json +40 -0
  87. package/route.cjs +128 -0
  88. package/route.cjs.map +1 -0
  89. package/route.d.cts +46 -0
  90. package/route.d.ts +46 -0
  91. package/route.js +105 -0
  92. package/route.js.map +1 -0
  93. package/scripts/preinstall.js +9 -0
  94. package/types-BRwWYiUN.d.ts +108 -0
  95. package/types-CipcRmc9.d.cts +108 -0
  96. package/types.cjs +40 -0
  97. package/types.cjs.map +1 -0
  98. package/types.d.cts +3 -0
  99. package/types.d.ts +3 -0
  100. package/types.js +16 -0
  101. package/types.js.map +1 -0
package/diatrema.js ADDED
@@ -0,0 +1,107 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { join } from "node:path";
4
+ import { HttpServer } from "./http-server.js";
5
+ import { EventEmitter } from "./event-emitter.js";
6
+ const diatremaDefaultConfig = {
7
+ dev: false,
8
+ isStandalone: false,
9
+ rootPath: process.cwd(),
10
+ get appPath() {
11
+ if (this.isStandalone)
12
+ return this.rootPath;
13
+ return join(this.rootPath, this.dev ? this.developmentDir : this.productionDir);
14
+ },
15
+ productionDir: ".mahameru",
16
+ developmentDir: ".mahameru",
17
+ routesDir: "routes"
18
+ };
19
+ class Diatrema extends EventEmitter {
20
+ static {
21
+ __name(this, "Diatrema");
22
+ }
23
+ #initialized = false;
24
+ #isShuttingDown = false;
25
+ options = diatremaDefaultConfig;
26
+ dependencies;
27
+ constructor(arg1, arg2) {
28
+ super();
29
+ if (typeof arg2 !== "undefined")
30
+ this.options = { ...this.options, ...arg1 };
31
+ if (typeof arg2 !== "undefined") {
32
+ this.dependencies = arg2;
33
+ } else {
34
+ this.dependencies = arg1;
35
+ }
36
+ }
37
+ /**
38
+ * Indicates whether the Mahameru server has been initialized or not.
39
+ * @returns {boolean}
40
+ */
41
+ get initialized() {
42
+ return this.#initialized;
43
+ }
44
+ /**
45
+ * Indicates whether the Mahameru server is shutting down or not.
46
+ * @returns {boolean}
47
+ */
48
+ get isShuttingDown() {
49
+ return this.#isShuttingDown;
50
+ }
51
+ /**
52
+ * Initialize the Mahameru server.
53
+ */
54
+ async initialize() {
55
+ try {
56
+ if (this.#initialized)
57
+ return;
58
+ await this.dependencies.container.discover();
59
+ } catch (error) {
60
+ throw error;
61
+ }
62
+ const { port, host } = await this.dependencies.httpServer.listen();
63
+ this.#initialized = true;
64
+ this.emit("ready", { mode: this.options.dev ? "development" : "production", port, host });
65
+ }
66
+ /**
67
+ * Hot reload the middleware and routes when a file changes in development mode.
68
+ */
69
+ async devHRM(changedFile) {
70
+ if (!this.#initialized)
71
+ return;
72
+ if (changedFile) {
73
+ if (await this.dependencies.container.onFileChanged(changedFile))
74
+ this.dependencies.logger.debug(`File changed: ${changedFile}`);
75
+ }
76
+ }
77
+ /**
78
+ * Shut down the Mahameru server gracefully.
79
+ * @returns {Promise<void>}
80
+ */
81
+ async shutdown() {
82
+ if (this.#isShuttingDown)
83
+ return;
84
+ this.#isShuttingDown = true;
85
+ this.dependencies.logger.info("Shutting down Mahameru server...");
86
+ try {
87
+ this.dependencies.logger.info("Databases destroyed successfully.");
88
+ } catch (error) {
89
+ this.dependencies.logger.error("Error destroying databases", error);
90
+ }
91
+ if (this.dependencies.httpServer.listening) {
92
+ try {
93
+ await this.dependencies.httpServer.close();
94
+ this.dependencies.logger.info("HTTP server closed successfully.");
95
+ } catch (error) {
96
+ this.dependencies.logger.error("Error closing HTTP server", error);
97
+ }
98
+ }
99
+ this.#initialized = false;
100
+ this.dependencies.logger.info("Mahameru server shut down.");
101
+ }
102
+ }
103
+ export {
104
+ Diatrema as default,
105
+ diatremaDefaultConfig
106
+ };
107
+ //# sourceMappingURL=diatrema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/diatrema.ts"],"sourcesContent":["import { join } from 'node:path';\n\nimport { HttpServer } from './http-server';\nimport { EventEmitter } from \"./event-emitter\";\n\nimport type { Container } from './container';\nimport type { Route } from './route';\nimport type { Logger } from './logger';\n\nexport type DiatremaEvents = {\n ready: [data: { mode: \"development\" | \"production\"; port: number; host: string; }];\n};\n\nexport type DiatremaOptions = {\n dev: boolean;\n isStandalone: boolean;\n rootPath: string;\n appPath: string;\n routesDir: string;\n productionDir: string;\n developmentDir: string;\n}\n\nexport type DiatremaDependencies = {\n container: Container;\n route: Route;\n httpServer: HttpServer;\n logger: Logger;\n};\n\nexport const diatremaDefaultConfig: DiatremaOptions = {\n dev: false,\n isStandalone: false,\n rootPath: process.cwd(),\n get appPath(): string {\n if (this.isStandalone)\n return this.rootPath;\n\n return join(this.rootPath, this.dev ? this.developmentDir : this.productionDir);\n },\n productionDir: '.mahameru',\n developmentDir: '.mahameru',\n routesDir: 'routes'\n}\n\n/**\n * Main Diatrema class that orchestrates the application lifecycle.\n */\nexport default class Diatrema extends EventEmitter<DiatremaEvents> {\n #initialized = false;\n #isShuttingDown = false;\n public readonly options: DiatremaOptions = diatremaDefaultConfig;\n protected readonly dependencies: DiatremaDependencies;\n\n constructor(dependencies: DiatremaDependencies)\n constructor(\n initialOptions: Partial<DiatremaOptions>,\n dependencies: DiatremaDependencies\n )\n constructor(\n arg1: Partial<DiatremaOptions> | DiatremaDependencies,\n arg2?: DiatremaDependencies\n ) {\n super();\n\n if (typeof arg2 !== 'undefined')\n this.options = { ...this.options, ...arg1 as Partial<DiatremaOptions> };\n\n if (typeof arg2 !== 'undefined') {\n this.dependencies = arg2;\n } else {\n this.dependencies = arg1 as DiatremaDependencies;\n }\n }\n\n /**\n * Indicates whether the Mahameru server has been initialized or not.\n * @returns {boolean}\n */\n get initialized() {\n return this.#initialized;\n }\n\n /**\n * Indicates whether the Mahameru server is shutting down or not.\n * @returns {boolean}\n */\n get isShuttingDown() {\n return this.#isShuttingDown;\n }\n\n /**\n * Initialize the Mahameru server.\n */\n async initialize(): Promise<void> {\n try {\n if (this.#initialized)\n return;\n\n await this.dependencies.container.discover();\n } catch (error) {\n throw error;\n }\n\n const { port, host } = await this.dependencies.httpServer.listen();\n this.#initialized = true;\n\n this.emit('ready', { mode: this.options.dev ? 'development' : 'production', port: port, host: host });\n }\n\n /**\n * Hot reload the middleware and routes when a file changes in development mode.\n */\n async devHRM(changedFile?: string) {\n if (!this.#initialized)\n return\n\n if (changedFile) {\n if (await this.dependencies.container.onFileChanged(changedFile))\n this.dependencies.logger.debug(`File changed: ${changedFile}`);\n }\n }\n\n /**\n * Shut down the Mahameru server gracefully.\n * @returns {Promise<void>}\n */\n async shutdown(): Promise<void> {\n if (this.#isShuttingDown)\n return\n\n this.#isShuttingDown = true;\n\n this.dependencies.logger.info('Shutting down Mahameru server...');\n\n try {\n this.dependencies.logger.info('Databases destroyed successfully.');\n } catch (error) {\n this.dependencies.logger.error('Error destroying databases', error);\n }\n\n if (this.dependencies.httpServer.listening) {\n try {\n await this.dependencies.httpServer.close();\n this.dependencies.logger.info('HTTP server closed successfully.');\n } catch (error) {\n this.dependencies.logger.error('Error closing HTTP server', error);\n }\n }\n\n this.#initialized = false;\n this.dependencies.logger.info('Mahameru server shut down.');\n }\n}\n"],"mappings":";;AAAA,SAAS,YAAY;AAErB,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AA2BtB,MAAM,wBAAyC;AAAA,EAClD,KAAK;AAAA,EACL,cAAc;AAAA,EACd,UAAU,QAAQ,IAAI;AAAA,EACtB,IAAI,UAAkB;AAClB,QAAI,KAAK;AACL,aAAO,KAAK;AAEhB,WAAO,KAAK,KAAK,UAAU,KAAK,MAAM,KAAK,iBAAiB,KAAK,aAAa;AAAA,EAClF;AAAA,EACA,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,WAAW;AACf;AAKA,MAAO,iBAA+B,aAA6B;AAAA,EAhDnE,OAgDmE;AAAA;AAAA;AAAA,EAC/D,eAAe;AAAA,EACf,kBAAkB;AAAA,EACF,UAA2B;AAAA,EACxB;AAAA,EAOnB,YACI,MACA,MACF;AACE,UAAM;AAEN,QAAI,OAAO,SAAS;AAChB,WAAK,UAAU,EAAE,GAAG,KAAK,SAAS,GAAG,KAAiC;AAE1E,QAAI,OAAO,SAAS,aAAa;AAC7B,WAAK,eAAe;AAAA,IACxB,OAAO;AACH,WAAK,eAAe;AAAA,IACxB;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,cAAc;AACd,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,iBAAiB;AACjB,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAC9B,QAAI;AACA,UAAI,KAAK;AACL;AAEJ,YAAM,KAAK,aAAa,UAAU,SAAS;AAAA,IAC/C,SAAS,OAAO;AACZ,YAAM;AAAA,IACV;AAEA,UAAM,EAAE,MAAM,KAAK,IAAI,MAAM,KAAK,aAAa,WAAW,OAAO;AACjE,SAAK,eAAe;AAEpB,SAAK,KAAK,SAAS,EAAE,MAAM,KAAK,QAAQ,MAAM,gBAAgB,cAAc,MAAY,KAAW,CAAC;AAAA,EACxG;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,aAAsB;AAC/B,QAAI,CAAC,KAAK;AACN;AAEJ,QAAI,aAAa;AACb,UAAI,MAAM,KAAK,aAAa,UAAU,cAAc,WAAW;AAC3D,aAAK,aAAa,OAAO,MAAM,iBAAiB,WAAW,EAAE;AAAA,IACrE;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAA0B;AAC5B,QAAI,KAAK;AACL;AAEJ,SAAK,kBAAkB;AAEvB,SAAK,aAAa,OAAO,KAAK,kCAAkC;AAEhE,QAAI;AACA,WAAK,aAAa,OAAO,KAAK,mCAAmC;AAAA,IACrE,SAAS,OAAO;AACZ,WAAK,aAAa,OAAO,MAAM,8BAA8B,KAAK;AAAA,IACtE;AAEA,QAAI,KAAK,aAAa,WAAW,WAAW;AACxC,UAAI;AACA,cAAM,KAAK,aAAa,WAAW,MAAM;AACzC,aAAK,aAAa,OAAO,KAAK,kCAAkC;AAAA,MACpE,SAAS,OAAO;AACZ,aAAK,aAAa,OAAO,MAAM,6BAA6B,KAAK;AAAA,MACrE;AAAA,IACJ;AAEA,SAAK,eAAe;AACpB,SAAK,aAAa,OAAO,KAAK,4BAA4B;AAAA,EAC9D;AACJ;","names":[]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var event_emitter_exports = {};
21
+ __export(event_emitter_exports, {
22
+ EventEmitter: () => EventEmitter
23
+ });
24
+ module.exports = __toCommonJS(event_emitter_exports);
25
+ class EventEmitter {
26
+ static {
27
+ __name(this, "EventEmitter");
28
+ }
29
+ listeners = /* @__PURE__ */ new Map();
30
+ on(event, listener) {
31
+ if (!this.listeners.has(event)) this.listeners.set(event, []);
32
+ this.listeners.get(event).push(listener);
33
+ }
34
+ off(event, listener) {
35
+ const list = this.listeners.get(event);
36
+ if (!list) return;
37
+ const index = list.findIndex(
38
+ (l) => l === listener || l.original === listener
39
+ );
40
+ if (index !== -1) list.splice(index, 1);
41
+ }
42
+ emit(event, ...args) {
43
+ const list = this.listeners.get(event);
44
+ if (list) {
45
+ [...list].forEach((listener) => listener(...args));
46
+ }
47
+ }
48
+ once(event, listener) {
49
+ const onceListener = /* @__PURE__ */ __name((...args) => {
50
+ listener(...args);
51
+ this.off(event, onceListener);
52
+ }, "onceListener");
53
+ onceListener.original = listener;
54
+ this.on(event, onceListener);
55
+ }
56
+ removeAllListeners(event) {
57
+ if (event) {
58
+ this.listeners.delete(event);
59
+ } else {
60
+ this.listeners.clear();
61
+ }
62
+ }
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ EventEmitter
67
+ });
68
+ //# sourceMappingURL=event-emitter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/event-emitter.ts"],"sourcesContent":["type Listener<T extends any[]> = (...args: T) => void;\r\n\r\nexport class EventEmitter<Events extends Record<string, any[]>> {\r\n private listeners = new Map<keyof Events, Listener<any[]>[]>();\r\n\r\n on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void {\r\n if (!this.listeners.has(event)) this.listeners.set(event, []);\r\n this.listeners.get(event)!.push(listener as Listener<any[]>);\r\n }\r\n\r\n off<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void {\r\n const list = this.listeners.get(event);\r\n\r\n if (!list) return;\r\n\r\n const index = list.findIndex(\r\n (l) => l === listener || (l as any).original === listener\r\n );\r\n\r\n if (index !== -1) list.splice(index, 1);\r\n }\r\n\r\n emit<K extends keyof Events>(event: K, ...args: Events[K]): void {\r\n const list = this.listeners.get(event);\r\n\r\n if (list) {\r\n [...list].forEach((listener) => listener(...args));\r\n }\r\n }\r\n\r\n once<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void {\r\n const onceListener = (...args: Events[K]) => {\r\n listener(...args);\r\n\r\n this.off(event, onceListener as any);\r\n };\r\n\r\n onceListener.original = listener;\r\n\r\n this.on(event, onceListener as any);\r\n }\r\n\r\n removeAllListeners<K extends keyof Events>(event?: K): void {\r\n if (event) {\r\n this.listeners.delete(event);\r\n } else {\r\n this.listeners.clear();\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,aAAmD;AAAA,EAFhE,OAEgE;AAAA;AAAA;AAAA,EACpD,YAAY,oBAAI,IAAqC;AAAA,EAE7D,GAA2B,OAAU,UAAqC;AACtE,QAAI,CAAC,KAAK,UAAU,IAAI,KAAK,EAAG,MAAK,UAAU,IAAI,OAAO,CAAC,CAAC;AAC5D,SAAK,UAAU,IAAI,KAAK,EAAG,KAAK,QAA2B;AAAA,EAC/D;AAAA,EAEA,IAA4B,OAAU,UAAqC;AACvE,UAAM,OAAO,KAAK,UAAU,IAAI,KAAK;AAErC,QAAI,CAAC,KAAM;AAEX,UAAM,QAAQ,KAAK;AAAA,MACf,CAAC,MAAM,MAAM,YAAa,EAAU,aAAa;AAAA,IACrD;AAEA,QAAI,UAAU,GAAI,MAAK,OAAO,OAAO,CAAC;AAAA,EAC1C;AAAA,EAEA,KAA6B,UAAa,MAAuB;AAC7D,UAAM,OAAO,KAAK,UAAU,IAAI,KAAK;AAErC,QAAI,MAAM;AACN,OAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,aAAa,SAAS,GAAG,IAAI,CAAC;AAAA,IACrD;AAAA,EACJ;AAAA,EAEA,KAA6B,OAAU,UAAqC;AACxE,UAAM,eAAe,2BAAI,SAAoB;AACzC,eAAS,GAAG,IAAI;AAEhB,WAAK,IAAI,OAAO,YAAmB;AAAA,IACvC,GAJqB;AAMrB,iBAAa,WAAW;AAExB,SAAK,GAAG,OAAO,YAAmB;AAAA,EACtC;AAAA,EAEA,mBAA2C,OAAiB;AACxD,QAAI,OAAO;AACP,WAAK,UAAU,OAAO,KAAK;AAAA,IAC/B,OAAO;AACH,WAAK,UAAU,MAAM;AAAA,IACzB;AAAA,EACJ;AACJ;","names":[]}
@@ -0,0 +1,11 @@
1
+ type Listener<T extends any[]> = (...args: T) => void;
2
+ declare class EventEmitter<Events extends Record<string, any[]>> {
3
+ private listeners;
4
+ on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void;
5
+ off<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void;
6
+ emit<K extends keyof Events>(event: K, ...args: Events[K]): void;
7
+ once<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void;
8
+ removeAllListeners<K extends keyof Events>(event?: K): void;
9
+ }
10
+
11
+ export { EventEmitter };
@@ -0,0 +1,11 @@
1
+ type Listener<T extends any[]> = (...args: T) => void;
2
+ declare class EventEmitter<Events extends Record<string, any[]>> {
3
+ private listeners;
4
+ on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void;
5
+ off<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void;
6
+ emit<K extends keyof Events>(event: K, ...args: Events[K]): void;
7
+ once<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void;
8
+ removeAllListeners<K extends keyof Events>(event?: K): void;
9
+ }
10
+
11
+ export { EventEmitter };
@@ -0,0 +1,45 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class EventEmitter {
4
+ static {
5
+ __name(this, "EventEmitter");
6
+ }
7
+ listeners = /* @__PURE__ */ new Map();
8
+ on(event, listener) {
9
+ if (!this.listeners.has(event)) this.listeners.set(event, []);
10
+ this.listeners.get(event).push(listener);
11
+ }
12
+ off(event, listener) {
13
+ const list = this.listeners.get(event);
14
+ if (!list) return;
15
+ const index = list.findIndex(
16
+ (l) => l === listener || l.original === listener
17
+ );
18
+ if (index !== -1) list.splice(index, 1);
19
+ }
20
+ emit(event, ...args) {
21
+ const list = this.listeners.get(event);
22
+ if (list) {
23
+ [...list].forEach((listener) => listener(...args));
24
+ }
25
+ }
26
+ once(event, listener) {
27
+ const onceListener = /* @__PURE__ */ __name((...args) => {
28
+ listener(...args);
29
+ this.off(event, onceListener);
30
+ }, "onceListener");
31
+ onceListener.original = listener;
32
+ this.on(event, onceListener);
33
+ }
34
+ removeAllListeners(event) {
35
+ if (event) {
36
+ this.listeners.delete(event);
37
+ } else {
38
+ this.listeners.clear();
39
+ }
40
+ }
41
+ }
42
+ export {
43
+ EventEmitter
44
+ };
45
+ //# sourceMappingURL=event-emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/event-emitter.ts"],"sourcesContent":["type Listener<T extends any[]> = (...args: T) => void;\r\n\r\nexport class EventEmitter<Events extends Record<string, any[]>> {\r\n private listeners = new Map<keyof Events, Listener<any[]>[]>();\r\n\r\n on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void {\r\n if (!this.listeners.has(event)) this.listeners.set(event, []);\r\n this.listeners.get(event)!.push(listener as Listener<any[]>);\r\n }\r\n\r\n off<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void {\r\n const list = this.listeners.get(event);\r\n\r\n if (!list) return;\r\n\r\n const index = list.findIndex(\r\n (l) => l === listener || (l as any).original === listener\r\n );\r\n\r\n if (index !== -1) list.splice(index, 1);\r\n }\r\n\r\n emit<K extends keyof Events>(event: K, ...args: Events[K]): void {\r\n const list = this.listeners.get(event);\r\n\r\n if (list) {\r\n [...list].forEach((listener) => listener(...args));\r\n }\r\n }\r\n\r\n once<K extends keyof Events>(event: K, listener: Listener<Events[K]>): void {\r\n const onceListener = (...args: Events[K]) => {\r\n listener(...args);\r\n\r\n this.off(event, onceListener as any);\r\n };\r\n\r\n onceListener.original = listener;\r\n\r\n this.on(event, onceListener as any);\r\n }\r\n\r\n removeAllListeners<K extends keyof Events>(event?: K): void {\r\n if (event) {\r\n this.listeners.delete(event);\r\n } else {\r\n this.listeners.clear();\r\n }\r\n }\r\n}\r\n"],"mappings":";;AAEO,MAAM,aAAmD;AAAA,EAFhE,OAEgE;AAAA;AAAA;AAAA,EACpD,YAAY,oBAAI,IAAqC;AAAA,EAE7D,GAA2B,OAAU,UAAqC;AACtE,QAAI,CAAC,KAAK,UAAU,IAAI,KAAK,EAAG,MAAK,UAAU,IAAI,OAAO,CAAC,CAAC;AAC5D,SAAK,UAAU,IAAI,KAAK,EAAG,KAAK,QAA2B;AAAA,EAC/D;AAAA,EAEA,IAA4B,OAAU,UAAqC;AACvE,UAAM,OAAO,KAAK,UAAU,IAAI,KAAK;AAErC,QAAI,CAAC,KAAM;AAEX,UAAM,QAAQ,KAAK;AAAA,MACf,CAAC,MAAM,MAAM,YAAa,EAAU,aAAa;AAAA,IACrD;AAEA,QAAI,UAAU,GAAI,MAAK,OAAO,OAAO,CAAC;AAAA,EAC1C;AAAA,EAEA,KAA6B,UAAa,MAAuB;AAC7D,UAAM,OAAO,KAAK,UAAU,IAAI,KAAK;AAErC,QAAI,MAAM;AACN,OAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,aAAa,SAAS,GAAG,IAAI,CAAC;AAAA,IACrD;AAAA,EACJ;AAAA,EAEA,KAA6B,OAAU,UAAqC;AACxE,UAAM,eAAe,2BAAI,SAAoB;AACzC,eAAS,GAAG,IAAI;AAEhB,WAAK,IAAI,OAAO,YAAmB;AAAA,IACvC,GAJqB;AAMrB,iBAAa,WAAW;AAExB,SAAK,GAAG,OAAO,YAAmB;AAAA,EACtC;AAAA,EAEA,mBAA2C,OAAiB;AACxD,QAAI,OAAO;AACP,WAAK,UAAU,OAAO,KAAK;AAAA,IAC/B,OAAO;AACH,WAAK,UAAU,MAAM;AAAA,IACzB;AAAA,EACJ;AACJ;","names":[]}
package/helpers.cjs ADDED
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var helpers_exports = {};
21
+ __export(helpers_exports, {
22
+ dynamicRequire: () => dynamicRequire,
23
+ exists: () => exists,
24
+ resolveWithinBase: () => resolveWithinBase,
25
+ validateProtectedRoute: () => validateProtectedRoute
26
+ });
27
+ module.exports = __toCommonJS(helpers_exports);
28
+ var import_promises = require("node:fs/promises");
29
+ var import_node_path = require("node:path");
30
+ var import_node_url = require("node:url");
31
+ const matchRoutePattern = /* @__PURE__ */ __name((currentPath, routePattern) => {
32
+ const regexPattern = routePattern.replace(/\//g, "\\/").replace(/:[^/]+/g, "[^/]+");
33
+ const regex = new RegExp(`^${regexPattern}$`);
34
+ return regex.test(currentPath);
35
+ }, "matchRoutePattern");
36
+ const validateProtectedRoute = /* @__PURE__ */ __name((protectedRoutes, method, path) => {
37
+ return protectedRoutes.some((route) => {
38
+ if (typeof route === "string")
39
+ return matchRoutePattern(path, route);
40
+ const isPathMatch = matchRoutePattern(path, route.path);
41
+ const isMethodMatch = route.methods.includes(method);
42
+ return isPathMatch && isMethodMatch;
43
+ });
44
+ }, "validateProtectedRoute");
45
+ const exists = /* @__PURE__ */ __name(async (target) => {
46
+ try {
47
+ await (0, import_promises.access)(target, import_promises.constants.R_OK);
48
+ return true;
49
+ } catch {
50
+ return false;
51
+ }
52
+ }, "exists");
53
+ function isWithin(base, target) {
54
+ if (target === base)
55
+ return true;
56
+ if (target.startsWith(base)) {
57
+ const nextChar = target.charAt(base.length);
58
+ return nextChar === import_node_path.sep;
59
+ }
60
+ return false;
61
+ }
62
+ __name(isWithin, "isWithin");
63
+ function resolveWithinBase(base, target) {
64
+ const baseResolved = (0, import_node_path.resolve)(base);
65
+ const targetResolved = (0, import_node_path.resolve)(base, target);
66
+ if (isWithin(baseResolved, targetResolved))
67
+ return targetResolved;
68
+ return null;
69
+ }
70
+ __name(resolveWithinBase, "resolveWithinBase");
71
+ async function dynamicRequire(type, resolvedFilePath, noCache = false) {
72
+ if (!await exists(resolvedFilePath))
73
+ return;
74
+ if (type === "commonjs") {
75
+ if (noCache) {
76
+ delete require.cache[resolvedFilePath];
77
+ }
78
+ return require(resolvedFilePath);
79
+ }
80
+ let fileUrl = (0, import_node_url.pathToFileURL)(resolvedFilePath).href;
81
+ if (noCache)
82
+ fileUrl += `?update=${Date.now()}`;
83
+ return await import(fileUrl);
84
+ }
85
+ __name(dynamicRequire, "dynamicRequire");
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ dynamicRequire,
89
+ exists,
90
+ resolveWithinBase,
91
+ validateProtectedRoute
92
+ });
93
+ //# sourceMappingURL=helpers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers.ts"],"sourcesContent":["import { access, constants } from \"node:fs/promises\";\nimport type { HTTPMethod, ProtectedRoute } from \"./types\";\nimport { resolve, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nconst matchRoutePattern = (currentPath: string, routePattern: string): boolean => {\n const regexPattern = routePattern\n .replace(/\\//g, '\\\\/')\n .replace(/:[^/]+/g, '[^/]+');\n\n const regex = new RegExp(`^${regexPattern}$`);\n\n return regex.test(currentPath);\n};\n\nexport const validateProtectedRoute = (protectedRoutes: ProtectedRoute, method: string, path: string): boolean => {\n return protectedRoutes.some(route => {\n if (typeof route === 'string')\n return matchRoutePattern(path, route);\n\n const isPathMatch = matchRoutePattern(path, route.path);\n const isMethodMatch = route.methods.includes(method as HTTPMethod);\n\n return isPathMatch && isMethodMatch;\n });\n};\n\nexport const exists = async (target: string): Promise<boolean> => {\n try {\n await access(target, constants.R_OK);\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Checks if the target path is within the base path.\n * @param base The base directory (absolute path)\n * @param target The target path (absolute path) to check\n * @returns true if target is within base, false otherwise\n */\nfunction isWithin(base: string, target: string): boolean {\n if (target === base)\n return true;\n\n if (target.startsWith(base)) {\n const nextChar = target.charAt(base.length);\n\n return nextChar === sep;\n }\n\n return false;\n}\n\n/**\n * Resolves a target path relative to a base directory, ensuring the result is within the base.\n * Returns null if the resolved path would be outside the base.\n * @param base The base directory (absolute path)\n * @param target The target path (relative to base) to resolve\n * @returns The resolved absolute path if within base, null otherwise\n */\nexport function resolveWithinBase(base: string, target: string): string | null {\n const baseResolved = resolve(base);\n const targetResolved = resolve(base, target);\n\n if (isWithin(baseResolved, targetResolved))\n return targetResolved;\n\n return null;\n}\n\n/**\n * \n * @param type \"commonjs\" | \"esm\"\n * @param filePath string - path to resolved file: require.resolve(\"./path/to/file\")\n */\nexport async function dynamicRequire<T extends Record<string, unknown> = Record<string, unknown>>(type: \"commonjs\" | \"esm\", resolvedFilePath: string, noCache: boolean = false): Promise<T | undefined> {\n if (!(await exists(resolvedFilePath)))\n return;\n\n if (type === \"commonjs\") {\n if (noCache) {\n delete require.cache[resolvedFilePath];\n }\n\n return require(resolvedFilePath) as T;\n }\n\n let fileUrl = pathToFileURL(resolvedFilePath).href;\n\n if (noCache)\n fileUrl += `?update=${Date.now()}`;\n\n return (await import(fileUrl)) as T;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAkC;AAElC,uBAA6B;AAC7B,sBAA8B;AAE9B,MAAM,oBAAoB,wBAAC,aAAqB,iBAAkC;AAC9E,QAAM,eAAe,aAChB,QAAQ,OAAO,KAAK,EACpB,QAAQ,WAAW,OAAO;AAE/B,QAAM,QAAQ,IAAI,OAAO,IAAI,YAAY,GAAG;AAE5C,SAAO,MAAM,KAAK,WAAW;AACjC,GAR0B;AAUnB,MAAM,yBAAyB,wBAAC,iBAAiC,QAAgB,SAA0B;AAC9G,SAAO,gBAAgB,KAAK,WAAS;AACjC,QAAI,OAAO,UAAU;AACjB,aAAO,kBAAkB,MAAM,KAAK;AAExC,UAAM,cAAc,kBAAkB,MAAM,MAAM,IAAI;AACtD,UAAM,gBAAgB,MAAM,QAAQ,SAAS,MAAoB;AAEjE,WAAO,eAAe;AAAA,EAC1B,CAAC;AACL,GAVsC;AAY/B,MAAM,SAAS,8BAAO,WAAqC;AAC9D,MAAI;AACA,cAAM,wBAAO,QAAQ,0BAAU,IAAI;AACnC,WAAO;AAAA,EACX,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ,GAPsB;AAetB,SAAS,SAAS,MAAc,QAAyB;AACrD,MAAI,WAAW;AACX,WAAO;AAEX,MAAI,OAAO,WAAW,IAAI,GAAG;AACzB,UAAM,WAAW,OAAO,OAAO,KAAK,MAAM;AAE1C,WAAO,aAAa;AAAA,EACxB;AAEA,SAAO;AACX;AAXS;AAoBF,SAAS,kBAAkB,MAAc,QAA+B;AAC3E,QAAM,mBAAe,0BAAQ,IAAI;AACjC,QAAM,qBAAiB,0BAAQ,MAAM,MAAM;AAE3C,MAAI,SAAS,cAAc,cAAc;AACrC,WAAO;AAEX,SAAO;AACX;AARgB;AAehB,eAAsB,eAA4E,MAA0B,kBAA0B,UAAmB,OAA+B;AACpM,MAAI,CAAE,MAAM,OAAO,gBAAgB;AAC/B;AAEJ,MAAI,SAAS,YAAY;AACrB,QAAI,SAAS;AACT,aAAO,QAAQ,MAAM,gBAAgB;AAAA,IACzC;AAEA,WAAO,QAAQ,gBAAgB;AAAA,EACnC;AAEA,MAAI,cAAU,+BAAc,gBAAgB,EAAE;AAE9C,MAAI;AACA,eAAW,WAAW,KAAK,IAAI,CAAC;AAEpC,SAAQ,MAAM,OAAO;AACzB;AAlBsB;","names":[]}
package/helpers.d.cts ADDED
@@ -0,0 +1,22 @@
1
+ import { P as ProtectedRoute } from './types-CipcRmc9.cjs';
2
+ import 'node:http';
3
+ import './mahameru-response.cjs';
4
+
5
+ declare const validateProtectedRoute: (protectedRoutes: ProtectedRoute, method: string, path: string) => boolean;
6
+ declare const exists: (target: string) => Promise<boolean>;
7
+ /**
8
+ * Resolves a target path relative to a base directory, ensuring the result is within the base.
9
+ * Returns null if the resolved path would be outside the base.
10
+ * @param base The base directory (absolute path)
11
+ * @param target The target path (relative to base) to resolve
12
+ * @returns The resolved absolute path if within base, null otherwise
13
+ */
14
+ declare function resolveWithinBase(base: string, target: string): string | null;
15
+ /**
16
+ *
17
+ * @param type "commonjs" | "esm"
18
+ * @param filePath string - path to resolved file: require.resolve("./path/to/file")
19
+ */
20
+ declare function dynamicRequire<T extends Record<string, unknown> = Record<string, unknown>>(type: "commonjs" | "esm", resolvedFilePath: string, noCache?: boolean): Promise<T | undefined>;
21
+
22
+ export { dynamicRequire, exists, resolveWithinBase, validateProtectedRoute };
package/helpers.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { P as ProtectedRoute } from './types-BRwWYiUN.js';
2
+ import 'node:http';
3
+ import './mahameru-response.js';
4
+
5
+ declare const validateProtectedRoute: (protectedRoutes: ProtectedRoute, method: string, path: string) => boolean;
6
+ declare const exists: (target: string) => Promise<boolean>;
7
+ /**
8
+ * Resolves a target path relative to a base directory, ensuring the result is within the base.
9
+ * Returns null if the resolved path would be outside the base.
10
+ * @param base The base directory (absolute path)
11
+ * @param target The target path (relative to base) to resolve
12
+ * @returns The resolved absolute path if within base, null otherwise
13
+ */
14
+ declare function resolveWithinBase(base: string, target: string): string | null;
15
+ /**
16
+ *
17
+ * @param type "commonjs" | "esm"
18
+ * @param filePath string - path to resolved file: require.resolve("./path/to/file")
19
+ */
20
+ declare function dynamicRequire<T extends Record<string, unknown> = Record<string, unknown>>(type: "commonjs" | "esm", resolvedFilePath: string, noCache?: boolean): Promise<T | undefined>;
21
+
22
+ export { dynamicRequire, exists, resolveWithinBase, validateProtectedRoute };
package/helpers.js ADDED
@@ -0,0 +1,67 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { access, constants } from "node:fs/promises";
4
+ import { resolve, sep } from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ const matchRoutePattern = /* @__PURE__ */ __name((currentPath, routePattern) => {
7
+ const regexPattern = routePattern.replace(/\//g, "\\/").replace(/:[^/]+/g, "[^/]+");
8
+ const regex = new RegExp(`^${regexPattern}$`);
9
+ return regex.test(currentPath);
10
+ }, "matchRoutePattern");
11
+ const validateProtectedRoute = /* @__PURE__ */ __name((protectedRoutes, method, path) => {
12
+ return protectedRoutes.some((route) => {
13
+ if (typeof route === "string")
14
+ return matchRoutePattern(path, route);
15
+ const isPathMatch = matchRoutePattern(path, route.path);
16
+ const isMethodMatch = route.methods.includes(method);
17
+ return isPathMatch && isMethodMatch;
18
+ });
19
+ }, "validateProtectedRoute");
20
+ const exists = /* @__PURE__ */ __name(async (target) => {
21
+ try {
22
+ await access(target, constants.R_OK);
23
+ return true;
24
+ } catch {
25
+ return false;
26
+ }
27
+ }, "exists");
28
+ function isWithin(base, target) {
29
+ if (target === base)
30
+ return true;
31
+ if (target.startsWith(base)) {
32
+ const nextChar = target.charAt(base.length);
33
+ return nextChar === sep;
34
+ }
35
+ return false;
36
+ }
37
+ __name(isWithin, "isWithin");
38
+ function resolveWithinBase(base, target) {
39
+ const baseResolved = resolve(base);
40
+ const targetResolved = resolve(base, target);
41
+ if (isWithin(baseResolved, targetResolved))
42
+ return targetResolved;
43
+ return null;
44
+ }
45
+ __name(resolveWithinBase, "resolveWithinBase");
46
+ async function dynamicRequire(type, resolvedFilePath, noCache = false) {
47
+ if (!await exists(resolvedFilePath))
48
+ return;
49
+ if (type === "commonjs") {
50
+ if (noCache) {
51
+ delete require.cache[resolvedFilePath];
52
+ }
53
+ return require(resolvedFilePath);
54
+ }
55
+ let fileUrl = pathToFileURL(resolvedFilePath).href;
56
+ if (noCache)
57
+ fileUrl += `?update=${Date.now()}`;
58
+ return await import(fileUrl);
59
+ }
60
+ __name(dynamicRequire, "dynamicRequire");
61
+ export {
62
+ dynamicRequire,
63
+ exists,
64
+ resolveWithinBase,
65
+ validateProtectedRoute
66
+ };
67
+ //# sourceMappingURL=helpers.js.map
package/helpers.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers.ts"],"sourcesContent":["import { access, constants } from \"node:fs/promises\";\nimport type { HTTPMethod, ProtectedRoute } from \"./types\";\nimport { resolve, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nconst matchRoutePattern = (currentPath: string, routePattern: string): boolean => {\n const regexPattern = routePattern\n .replace(/\\//g, '\\\\/')\n .replace(/:[^/]+/g, '[^/]+');\n\n const regex = new RegExp(`^${regexPattern}$`);\n\n return regex.test(currentPath);\n};\n\nexport const validateProtectedRoute = (protectedRoutes: ProtectedRoute, method: string, path: string): boolean => {\n return protectedRoutes.some(route => {\n if (typeof route === 'string')\n return matchRoutePattern(path, route);\n\n const isPathMatch = matchRoutePattern(path, route.path);\n const isMethodMatch = route.methods.includes(method as HTTPMethod);\n\n return isPathMatch && isMethodMatch;\n });\n};\n\nexport const exists = async (target: string): Promise<boolean> => {\n try {\n await access(target, constants.R_OK);\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Checks if the target path is within the base path.\n * @param base The base directory (absolute path)\n * @param target The target path (absolute path) to check\n * @returns true if target is within base, false otherwise\n */\nfunction isWithin(base: string, target: string): boolean {\n if (target === base)\n return true;\n\n if (target.startsWith(base)) {\n const nextChar = target.charAt(base.length);\n\n return nextChar === sep;\n }\n\n return false;\n}\n\n/**\n * Resolves a target path relative to a base directory, ensuring the result is within the base.\n * Returns null if the resolved path would be outside the base.\n * @param base The base directory (absolute path)\n * @param target The target path (relative to base) to resolve\n * @returns The resolved absolute path if within base, null otherwise\n */\nexport function resolveWithinBase(base: string, target: string): string | null {\n const baseResolved = resolve(base);\n const targetResolved = resolve(base, target);\n\n if (isWithin(baseResolved, targetResolved))\n return targetResolved;\n\n return null;\n}\n\n/**\n * \n * @param type \"commonjs\" | \"esm\"\n * @param filePath string - path to resolved file: require.resolve(\"./path/to/file\")\n */\nexport async function dynamicRequire<T extends Record<string, unknown> = Record<string, unknown>>(type: \"commonjs\" | \"esm\", resolvedFilePath: string, noCache: boolean = false): Promise<T | undefined> {\n if (!(await exists(resolvedFilePath)))\n return;\n\n if (type === \"commonjs\") {\n if (noCache) {\n delete require.cache[resolvedFilePath];\n }\n\n return require(resolvedFilePath) as T;\n }\n\n let fileUrl = pathToFileURL(resolvedFilePath).href;\n\n if (noCache)\n fileUrl += `?update=${Date.now()}`;\n\n return (await import(fileUrl)) as T;\n}\n"],"mappings":";;AAAA,SAAS,QAAQ,iBAAiB;AAElC,SAAS,SAAS,WAAW;AAC7B,SAAS,qBAAqB;AAE9B,MAAM,oBAAoB,wBAAC,aAAqB,iBAAkC;AAC9E,QAAM,eAAe,aAChB,QAAQ,OAAO,KAAK,EACpB,QAAQ,WAAW,OAAO;AAE/B,QAAM,QAAQ,IAAI,OAAO,IAAI,YAAY,GAAG;AAE5C,SAAO,MAAM,KAAK,WAAW;AACjC,GAR0B;AAUnB,MAAM,yBAAyB,wBAAC,iBAAiC,QAAgB,SAA0B;AAC9G,SAAO,gBAAgB,KAAK,WAAS;AACjC,QAAI,OAAO,UAAU;AACjB,aAAO,kBAAkB,MAAM,KAAK;AAExC,UAAM,cAAc,kBAAkB,MAAM,MAAM,IAAI;AACtD,UAAM,gBAAgB,MAAM,QAAQ,SAAS,MAAoB;AAEjE,WAAO,eAAe;AAAA,EAC1B,CAAC;AACL,GAVsC;AAY/B,MAAM,SAAS,8BAAO,WAAqC;AAC9D,MAAI;AACA,UAAM,OAAO,QAAQ,UAAU,IAAI;AACnC,WAAO;AAAA,EACX,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ,GAPsB;AAetB,SAAS,SAAS,MAAc,QAAyB;AACrD,MAAI,WAAW;AACX,WAAO;AAEX,MAAI,OAAO,WAAW,IAAI,GAAG;AACzB,UAAM,WAAW,OAAO,OAAO,KAAK,MAAM;AAE1C,WAAO,aAAa;AAAA,EACxB;AAEA,SAAO;AACX;AAXS;AAoBF,SAAS,kBAAkB,MAAc,QAA+B;AAC3E,QAAM,eAAe,QAAQ,IAAI;AACjC,QAAM,iBAAiB,QAAQ,MAAM,MAAM;AAE3C,MAAI,SAAS,cAAc,cAAc;AACrC,WAAO;AAEX,SAAO;AACX;AARgB;AAehB,eAAsB,eAA4E,MAA0B,kBAA0B,UAAmB,OAA+B;AACpM,MAAI,CAAE,MAAM,OAAO,gBAAgB;AAC/B;AAEJ,MAAI,SAAS,YAAY;AACrB,QAAI,SAAS;AACT,aAAO,QAAQ,MAAM,gBAAgB;AAAA,IACzC;AAEA,WAAO,QAAQ,gBAAgB;AAAA,EACnC;AAEA,MAAI,UAAU,cAAc,gBAAgB,EAAE;AAE9C,MAAI;AACA,eAAW,WAAW,KAAK,IAAI,CAAC;AAEpC,SAAQ,MAAM,OAAO;AACzB;AAlBsB;","names":[]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var http_server_error_exports = {};
21
+ __export(http_server_error_exports, {
22
+ HttpServerError: () => HttpServerError
23
+ });
24
+ module.exports = __toCommonJS(http_server_error_exports);
25
+ class HttpServerError extends Error {
26
+ static {
27
+ __name(this, "HttpServerError");
28
+ }
29
+ statusCode = 500;
30
+ details;
31
+ constructor(details) {
32
+ super("Internal Server Error");
33
+ this.name = "HttpServerError";
34
+ this.details = details;
35
+ Object.setPrototypeOf(this, HttpServerError.prototype);
36
+ if (Error.captureStackTrace)
37
+ Error.captureStackTrace(this, HttpServerError);
38
+ }
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ HttpServerError
43
+ });
44
+ //# sourceMappingURL=http-server-error.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/http-server-error.ts"],"sourcesContent":["export class HttpServerError extends Error {\n public readonly statusCode: number = 500;\n public readonly details?: string;\n\n constructor(details?: string) {\n super('Internal Server Error');\n this.name = 'HttpServerError';\n this.details = details;\n\n Object.setPrototypeOf(this, HttpServerError.prototype);\n\n if (Error.captureStackTrace)\n Error.captureStackTrace(this, HttpServerError);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,wBAAwB,MAAM;AAAA,EAA3C,OAA2C;AAAA;AAAA;AAAA,EACvB,aAAqB;AAAA,EACrB;AAAA,EAEhB,YAAY,SAAkB;AAC1B,UAAM,uBAAuB;AAC7B,SAAK,OAAO;AACZ,SAAK,UAAU;AAEf,WAAO,eAAe,MAAM,gBAAgB,SAAS;AAErD,QAAI,MAAM;AACN,YAAM,kBAAkB,MAAM,eAAe;AAAA,EACrD;AACJ;","names":[]}
@@ -0,0 +1,7 @@
1
+ declare class HttpServerError extends Error {
2
+ readonly statusCode: number;
3
+ readonly details?: string;
4
+ constructor(details?: string);
5
+ }
6
+
7
+ export { HttpServerError };
@@ -0,0 +1,7 @@
1
+ declare class HttpServerError extends Error {
2
+ readonly statusCode: number;
3
+ readonly details?: string;
4
+ constructor(details?: string);
5
+ }
6
+
7
+ export { HttpServerError };
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class HttpServerError extends Error {
4
+ static {
5
+ __name(this, "HttpServerError");
6
+ }
7
+ statusCode = 500;
8
+ details;
9
+ constructor(details) {
10
+ super("Internal Server Error");
11
+ this.name = "HttpServerError";
12
+ this.details = details;
13
+ Object.setPrototypeOf(this, HttpServerError.prototype);
14
+ if (Error.captureStackTrace)
15
+ Error.captureStackTrace(this, HttpServerError);
16
+ }
17
+ }
18
+ export {
19
+ HttpServerError
20
+ };
21
+ //# sourceMappingURL=http-server-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/http-server-error.ts"],"sourcesContent":["export class HttpServerError extends Error {\n public readonly statusCode: number = 500;\n public readonly details?: string;\n\n constructor(details?: string) {\n super('Internal Server Error');\n this.name = 'HttpServerError';\n this.details = details;\n\n Object.setPrototypeOf(this, HttpServerError.prototype);\n\n if (Error.captureStackTrace)\n Error.captureStackTrace(this, HttpServerError);\n }\n}\n"],"mappings":";;AAAO,MAAM,wBAAwB,MAAM;AAAA,EAA3C,OAA2C;AAAA;AAAA;AAAA,EACvB,aAAqB;AAAA,EACrB;AAAA,EAEhB,YAAY,SAAkB;AAC1B,UAAM,uBAAuB;AAC7B,SAAK,OAAO;AACZ,SAAK,UAAU;AAEf,WAAO,eAAe,MAAM,gBAAgB,SAAS;AAErD,QAAI,MAAM;AACN,YAAM,kBAAkB,MAAM,eAAe;AAAA,EACrD;AACJ;","names":[]}