arkos 1.2.30-test → 1.2.32-test

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 (60) hide show
  1. package/dist/cjs/modules/auth/auth.router.js +8 -82
  2. package/dist/cjs/modules/auth/auth.router.js.map +1 -1
  3. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +9 -93
  4. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  5. package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
  6. package/dist/cjs/modules/file-upload/file-upload.router.js +6 -19
  7. package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
  8. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +7 -0
  9. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
  10. package/dist/cjs/server.js +2 -2
  11. package/dist/cjs/server.js.map +1 -1
  12. package/dist/cjs/utils/cli/dev.js +7 -7
  13. package/dist/cjs/utils/cli/dev.js.map +1 -1
  14. package/dist/cjs/utils/cli/start.js +1 -1
  15. package/dist/cjs/utils/cli/start.js.map +1 -1
  16. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  17. package/dist/cjs/utils/features/api.features.js +9 -3
  18. package/dist/cjs/utils/features/api.features.js.map +1 -1
  19. package/dist/cjs/utils/helpers/global.helpers.js +1 -4
  20. package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
  21. package/dist/cjs/utils/helpers/models.helpers.js +2 -1
  22. package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
  23. package/dist/cjs/utils/helpers/routers.helpers.js +21 -0
  24. package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -0
  25. package/dist/cjs/utils/sheu.js +101 -125
  26. package/dist/cjs/utils/sheu.js.map +1 -1
  27. package/dist/esm/modules/auth/auth.router.js +8 -82
  28. package/dist/esm/modules/auth/auth.router.js.map +1 -1
  29. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +9 -93
  30. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  31. package/dist/esm/modules/error-handler/utils/catch-async.js.map +1 -1
  32. package/dist/esm/modules/file-upload/file-upload.router.js +6 -19
  33. package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
  34. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +6 -0
  35. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
  36. package/dist/esm/server.js +2 -2
  37. package/dist/esm/server.js.map +1 -1
  38. package/dist/esm/utils/cli/dev.js +7 -7
  39. package/dist/esm/utils/cli/dev.js.map +1 -1
  40. package/dist/esm/utils/cli/start.js +1 -1
  41. package/dist/esm/utils/cli/start.js.map +1 -1
  42. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  43. package/dist/esm/utils/features/api.features.js +9 -3
  44. package/dist/esm/utils/features/api.features.js.map +1 -1
  45. package/dist/esm/utils/helpers/global.helpers.js +1 -4
  46. package/dist/esm/utils/helpers/global.helpers.js.map +1 -1
  47. package/dist/esm/utils/helpers/models.helpers.js +2 -1
  48. package/dist/esm/utils/helpers/models.helpers.js.map +1 -1
  49. package/dist/esm/utils/helpers/routers.helpers.js +16 -0
  50. package/dist/esm/utils/helpers/routers.helpers.js.map +1 -0
  51. package/dist/esm/utils/sheu.js +101 -125
  52. package/dist/esm/utils/sheu.js.map +1 -1
  53. package/dist/types/modules/error-handler/utils/catch-async.d.ts +1 -0
  54. package/dist/types/modules/file-upload/utils/helpers/file-upload.helpers.d.ts +2 -1
  55. package/dist/types/server.d.ts +3 -0
  56. package/dist/types/utils/features/api.features.d.ts +1 -0
  57. package/dist/types/utils/helpers/models.helpers.d.ts +1 -1
  58. package/dist/types/utils/helpers/routers.helpers.d.ts +2 -0
  59. package/dist/types/utils/sheu.d.ts +66 -21
  60. package/package.json +1 -1
@@ -1,143 +1,119 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class Sheu {
4
- constructor() {
5
- this.codes = [];
6
- }
7
- _apply(text) {
8
- const openCodes = this.codes.join("");
9
- return `${openCodes}${text}\x1b[0m`;
10
- }
11
- _chain() {
12
- const newInstance = new Sheu();
13
- newInstance.codes = [...this.codes];
14
- return newInstance;
15
- }
16
- red(text) {
17
- if (text !== undefined) {
18
- return `\x1b[31m${text}\x1b[0m`;
19
- }
20
- const instance = this._chain();
21
- instance.codes.push("\x1b[31m");
22
- return instance;
23
- }
24
- blue(text) {
25
- if (text !== undefined) {
26
- return `\x1b[34m${text}\x1b[0m`;
27
- }
28
- const instance = this._chain();
29
- instance.codes.push("\x1b[34m");
30
- return instance;
31
- }
32
- green(text) {
33
- if (text !== undefined) {
34
- return `\x1b[32m${text}\x1b[0m`;
35
- }
36
- const instance = this._chain();
37
- instance.codes.push("\x1b[32m");
38
- return instance;
39
- }
40
- yellow(text) {
41
- if (text !== undefined) {
42
- return `\x1b[33m${text}\x1b[0m`;
43
- }
44
- const instance = this._chain();
45
- instance.codes.push("\x1b[33m");
46
- return instance;
47
- }
48
- cyan(text) {
49
- if (text !== undefined) {
50
- return `\x1b[36m${text}\x1b[0m`;
51
- }
52
- const instance = this._chain();
53
- instance.codes.push("\x1b[36m");
54
- return instance;
55
- }
56
- magenta(text) {
57
- if (text !== undefined) {
58
- return `\x1b[35m${text}\x1b[0m`;
4
+ getTimestamp() {
5
+ return new Date().toTimeString().split(" ")[0];
6
+ }
7
+ formatText(text = "", options = {}) {
8
+ const label = options?.label
9
+ ? text
10
+ ? options?.label + " "
11
+ : options?.label
12
+ : "";
13
+ let result = `${label}${text}`;
14
+ if (options.timestamp) {
15
+ const timestamp = this.getTimestamp();
16
+ if (options.timestamp === true)
17
+ result = `${label}\x1b[90m${timestamp}\x1b[0m ${text}`;
18
+ else if (typeof options.timestamp === "string") {
19
+ const colorCode = this.getColorCode(options.timestamp);
20
+ result = `${label}${colorCode}${timestamp}\x1b[0m ${text}`;
21
+ }
59
22
  }
60
- const instance = this._chain();
61
- instance.codes.push("\x1b[35m");
62
- return instance;
63
- }
64
- white(text) {
65
- if (text !== undefined) {
66
- return `\x1b[37m${text}\x1b[0m`;
67
- }
68
- const instance = this._chain();
69
- instance.codes.push("\x1b[37m");
70
- return instance;
71
- }
72
- black(text) {
73
- if (text !== undefined) {
74
- return `\x1b[30m${text}\x1b[0m`;
75
- }
76
- const instance = this._chain();
77
- instance.codes.push("\x1b[30m");
78
- return instance;
79
- }
80
- gray(text) {
81
- if (text !== undefined) {
82
- return `\x1b[90m${text}\x1b[0m`;
83
- }
84
- const instance = this._chain();
85
- instance.codes.push("\x1b[90m");
86
- return instance;
87
- }
88
- orange(text) {
89
- if (text !== undefined) {
90
- return `\x1b[91m${text}\x1b[0m`;
91
- }
92
- const instance = this._chain();
93
- instance.codes.push("\x1b[91m");
94
- return instance;
95
- }
96
- bold(text) {
97
- if (text !== undefined) {
98
- return `\x1b[1m${text}\x1b[0m`;
99
- }
100
- const instance = this._chain();
101
- instance.codes.push("\x1b[1m");
102
- return instance;
103
- }
104
- apply(text) {
105
- return this._apply(text);
106
- }
107
- info(message) {
23
+ if (options.bold)
24
+ result = `\x1b[1m${result}\x1b[0m`;
25
+ return result;
26
+ }
27
+ getColorCode(color) {
28
+ const colorMap = {
29
+ red: "\x1b[31m",
30
+ blue: "\x1b[34m",
31
+ green: "\x1b[32m",
32
+ yellow: "\x1b[33m",
33
+ cyan: "\x1b[36m",
34
+ magenta: "\x1b[35m",
35
+ white: "\x1b[37m",
36
+ black: "\x1b[30m",
37
+ gray: "\x1b[90m",
38
+ orange: "\x1b[91m",
39
+ };
40
+ return colorMap[color] || "\x1b[90m";
41
+ }
42
+ red(text, options) {
43
+ const coloredText = `\x1b[31m${text}\x1b[0m`;
44
+ return this.formatText(coloredText, options || {});
45
+ }
46
+ blue(text, options) {
47
+ const coloredText = `\x1b[34m${text}\x1b[0m`;
48
+ return this.formatText(coloredText, options || {});
49
+ }
50
+ green(text, options) {
51
+ const coloredText = `\x1b[32m${text}\x1b[0m`;
52
+ return this.formatText(coloredText, options || {});
53
+ }
54
+ yellow(text, options) {
55
+ const coloredText = `\x1b[33m${text}\x1b[0m`;
56
+ return this.formatText(coloredText, options || {});
57
+ }
58
+ cyan(text, options) {
59
+ const coloredText = `\x1b[36m${text}\x1b[0m`;
60
+ return this.formatText(coloredText, options || {});
61
+ }
62
+ magenta(text, options) {
63
+ const coloredText = `\x1b[35m${text}\x1b[0m`;
64
+ return this.formatText(coloredText, options || {});
65
+ }
66
+ white(text, options) {
67
+ const coloredText = `\x1b[37m${text}\x1b[0m`;
68
+ return this.formatText(coloredText, options || {});
69
+ }
70
+ black(text, options) {
71
+ const coloredText = `\x1b[30m${text}\x1b[0m`;
72
+ return this.formatText(coloredText, options || {});
73
+ }
74
+ gray(text, options) {
75
+ const coloredText = `\x1b[90m${text}\x1b[0m`;
76
+ return this.formatText(coloredText, options || {});
77
+ }
78
+ orange(text, options) {
79
+ const coloredText = `\x1b[91m${text}\x1b[0m`;
80
+ return this.formatText(coloredText, options || {});
81
+ }
82
+ bold(text, options) {
83
+ const boldText = `\x1b[1m${text}\x1b[0m`;
84
+ return this.formatText(boldText, { ...options, bold: false });
85
+ }
86
+ info(message, options) {
108
87
  const label = `[\x1b[36mINFO\x1b[0m]`;
109
- const content = message ? `${label} ${message}` : label;
110
- console.info(content);
111
- return content;
88
+ const result = this.formatText(message, { ...options, label });
89
+ console.info(result);
90
+ return result;
112
91
  }
113
- error(message) {
92
+ error(message, options) {
114
93
  const label = `[\x1b[31mERROR\x1b[0m]`;
115
- const content = message ? `${label} ${message}` : label;
116
- console.info(content);
117
- return content;
94
+ const result = this.formatText(message, { ...options, label });
95
+ console.error(result);
96
+ return result;
118
97
  }
119
- ready(message) {
98
+ ready(message, options) {
120
99
  const label = `[\x1b[32mREADY\x1b[0m]`;
121
- const content = message ? `${label} ${message}` : label;
122
- console.info(content);
123
- return content;
100
+ const result = this.formatText(message, { ...options, label });
101
+ console.info(result);
102
+ return result;
124
103
  }
125
- done(message) {
104
+ done(message, options) {
126
105
  const label = `[\x1b[32mDONE\x1b[0m]`;
127
- const content = message ? `${label} ${message}` : label;
128
- console.info(content);
129
- return content;
106
+ const result = this.formatText(message, { ...options, label });
107
+ console.info(result);
108
+ return result;
130
109
  }
131
- warn(message) {
110
+ warn(message, options) {
132
111
  const label = `[\x1b[33mWARN\x1b[0m]`;
133
- console.info(message ? `${label} ${message}` : label);
112
+ const result = this.formatText(message, { ...options, label });
113
+ console.warn(result);
114
+ return result;
134
115
  }
135
116
  }
136
117
  const sheu = new Sheu();
137
- Object.getOwnPropertyNames(Sheu.prototype).forEach((method) => {
138
- if (method !== "constructor" && method !== "_apply" && method !== "_chain") {
139
- sheu[method] = Sheu.prototype[method].bind(new Sheu());
140
- }
141
- });
142
118
  exports.default = sheu;
143
119
  //# sourceMappingURL=sheu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sheu.js","sourceRoot":"","sources":["../../../src/utils/sheu.ts"],"names":[],"mappings":";;AAIA,MAAM,IAAI;IAGR;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IAOD,MAAM,CAAC,IAAY;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtC,OAAO,GAAG,SAAS,GAAG,IAAI,SAAS,CAAC;IACtC,CAAC;IAMD,MAAM;QACJ,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;QAC/B,WAAW,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,WAAW,CAAC;IACrB,CAAC;IAOD,GAAG,CAAC,IAAa;QACf,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,WAAW,IAAI,SAAS,CAAC;QAClC,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC/B,QAAQ,CAAC,KAA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OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC;IACjB,CAAC;IAOD,IAAI,CAAC,OAAgB;QACnB,MAAM,KAAK,GAAG,uBAAuB,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;CACF;AAGD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;AAGxB,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;IAC5D,IAAI,MAAM,KAAK,aAAa,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1E,IAAY,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAsB,CAAC,CAAC,IAAI,CACjE,IAAI,IAAI,EAAE,CACX,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,kBAAe,IAAI,CAAC","sourcesContent":["/**\n * Sheu - Terminal color utility class for styling console output\n * Provides chainable methods for colors and text formatting\n */\nclass Sheu {\n codes: string[];\n\n constructor() {\n this.codes = [];\n }\n\n /**\n * Apply text to the current styling codes\n * @param {string} text - The text to style\n * @returns {string} The styled text with ANSI codes\n */\n _apply(text: string): string {\n const openCodes = this.codes.join(\"\");\n return `${openCodes}${text}\\x1b[0m`;\n }\n\n /**\n * Create a new instance with the current codes\n * @returns {Sheu} New Sheu instance\n */\n _chain(): Sheu {\n const newInstance = new Sheu();\n newInstance.codes = [...this.codes];\n return newInstance;\n }\n\n /**\n * Red color (Tailwind red-500: #ef4444)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n red(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[31m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[31m\");\n return instance;\n }\n\n /**\n * Blue color (Tailwind blue-500: #3b82f6)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n blue(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[34m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[34m\");\n return instance;\n }\n\n /**\n * Green color (Tailwind green-500: #22c55e)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n green(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[32m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[32m\");\n return instance;\n }\n\n /**\n * Yellow color (Tailwind yellow-500: #eab308)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n yellow(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[33m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[33m\");\n return instance;\n }\n\n /**\n * Cyan color (Tailwind cyan-500: #06b6d4)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n cyan(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[36m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[36m\");\n return instance;\n }\n\n /**\n * Magenta color (Tailwind fuchsia-500: #d946ef)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n magenta(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[35m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[35m\");\n return instance;\n }\n\n /**\n * White color (Tailwind white: #ffffff)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n white(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[37m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[37m\");\n return instance;\n }\n\n /**\n * Black color (Tailwind black: #000000)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n black(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[30m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[30m\");\n return instance;\n }\n\n /**\n * Gray color (Tailwind gray-500: #6b7280)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n gray(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[90m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[90m\");\n return instance;\n }\n\n /**\n * Orange color (Tailwind orange-500: #f97316)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n orange(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[91m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[91m\");\n return instance;\n }\n\n /**\n * Bold text formatting\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n bold(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[1m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[1m\");\n return instance;\n }\n\n /**\n * Apply all accumulated styles to text\n * @param {string} text - The text to style\n * @returns {string} The styled text\n */\n apply(text: string): string {\n return this._apply(text);\n }\n\n /**\n * Info label with cyan color [INFO]\n * @param {string} [message] - Optional message to append\n * @returns {string} Formatted info label\n */\n info(message?: string): string {\n const label = `[\\x1b[36mINFO\\x1b[0m]`;\n const content = message ? `${label} ${message}` : label;\n console.info(content);\n return content;\n }\n\n /**\n * Error label with red color [ERROR]\n * @param {string} [message] - Optional message to append\n * @returns {string} Formatted error label\n */\n error(message?: string): string {\n const label = `[\\x1b[31mERROR\\x1b[0m]`;\n const content = message ? `${label} ${message}` : label;\n console.info(content);\n return content;\n }\n\n /**\n * Ready label with green color [READY]\n * @param {string} [message] - Optional message to append\n * @returns {string} Formatted ready label\n */\n ready(message?: string): string {\n const label = `[\\x1b[32mREADY\\x1b[0m]`;\n const content = message ? `${label} ${message}` : label;\n console.info(content);\n return content;\n }\n\n /**\n * Done label with green color [DONE]\n * @param {string} [message] - Optional message to append\n * @returns {string} Formatted done label\n */\n done(message?: string): string {\n const label = `[\\x1b[32mDONE\\x1b[0m]`;\n const content = message ? `${label} ${message}` : label;\n console.info(content);\n return content;\n }\n\n /**\n * Warning label with yellow color [WARN]\n * @param {string} [message] - Optional message to append\n * @returns void\n */\n warn(message?: string) {\n const label = `[\\x1b[33mWARN\\x1b[0m]`;\n console.info(message ? `${label} ${message}` : label);\n }\n}\n\n// Create default instance\nconst sheu = new Sheu();\n\n// Add static methods to the default instance for direct usage\nObject.getOwnPropertyNames(Sheu.prototype).forEach((method) => {\n if (method !== \"constructor\" && method !== \"_apply\" && method !== \"_chain\") {\n (sheu as any)[method] = Sheu.prototype[method as keyof Object].bind(\n new Sheu()\n );\n }\n});\n\nexport default sheu;\n"]}
1
+ {"version":3,"file":"sheu.js","sourceRoot":"","sources":["../../../src/utils/sheu.ts"],"names":[],"mappings":";;AAGA,MAAM,IAAI;IAIA,YAAY;QAClB,OAAO,IAAI,IAAI,EAAE,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAKO,UAAU,CAChB,OAAe,EAAE,EACjB,UAII,EAAE;QAEN,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK;YAC1B,CAAC,CAAC,IAAI;gBACJ,CAAC,CAAC,OA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AAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IAKD,IAAI,CACF,OAAe,EACf,OAA0D;QAE1D,MAAM,KAAK,GAAG,uBAAuB,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IAKD,IAAI,CACF,OAAe,EACf,OAA0D;QAE1D,MAAM,KAAK,GAAG,uBAAuB,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;AAExB,kBAAe,IAAI,CAAC","sourcesContent":["/**\n * Sheu - Simplified terminal color utility for styling console output\n */\nclass Sheu {\n /**\n * Get current timestamp in HH:MM:SS format\n */\n private getTimestamp(): string {\n return new Date().toTimeString().split(\" \")[0];\n }\n\n /**\n * Apply timestamp and bold formatting if requested\n */\n private formatText(\n text: string = \"\",\n options: {\n timestamp?: boolean | string;\n bold?: boolean;\n label?: string;\n } = {}\n ): string {\n const label = options?.label\n ? text\n ? options?.label + \" \"\n : options?.label\n : \"\";\n let result = `${label}${text}`;\n\n // Apply timestamp if requested\n if (options.timestamp) {\n const timestamp = this.getTimestamp();\n if (options.timestamp === true)\n result = `${label}\\x1b[90m${timestamp}\\x1b[0m ${text}`;\n else if (typeof options.timestamp === \"string\") {\n const colorCode = this.getColorCode(options.timestamp);\n result = `${label}${colorCode}${timestamp}\\x1b[0m ${text}`;\n }\n }\n\n if (options.bold) result = `\\x1b[1m${result}\\x1b[0m`;\n\n return result;\n }\n\n /**\n * Get ANSI color code for color name\n */\n private getColorCode(color: string): string {\n const colorMap: { [key: string]: string } = {\n red: \"\\x1b[31m\",\n blue: \"\\x1b[34m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n cyan: \"\\x1b[36m\",\n magenta: \"\\x1b[35m\",\n white: \"\\x1b[37m\",\n black: \"\\x1b[30m\",\n gray: \"\\x1b[90m\",\n orange: \"\\x1b[91m\",\n };\n return colorMap[color] || \"\\x1b[90m\"; // Default to gray if color not found\n }\n\n /**\n * Red color\n */\n red(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[31m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Blue color\n */\n blue(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[34m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Green color\n */\n green(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[32m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Yellow color\n */\n yellow(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[33m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Cyan color\n */\n cyan(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[36m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Magenta color\n */\n magenta(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[35m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * White color\n */\n white(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[37m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Black color\n */\n black(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[30m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Gray color\n */\n gray(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[90m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Orange color\n */\n orange(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[91m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Bold text formatting\n */\n bold(text: string, options?: { timestamp?: boolean | string }): string {\n const boldText = `\\x1b[1m${text}\\x1b[0m`;\n return this.formatText(boldText, { ...options, bold: false }); // Don't double-bold\n }\n\n /**\n * Info label with cyan color [INFO]\n */\n info(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[36mINFO\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.info(result);\n return result;\n }\n\n /**\n * Error label with red color [ERROR]\n */\n error(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[31mERROR\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.error(result);\n return result;\n }\n\n /**\n * Ready label with green color [READY]\n */\n ready(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[32mREADY\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.info(result);\n return result;\n }\n\n /**\n * Done label with green color [DONE]\n */\n done(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[32mDONE\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.info(result);\n return result;\n }\n\n /**\n * Warning label with yellow color [WARN]\n */\n warn(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[33mWARN\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.warn(result);\n return result;\n }\n}\n\nconst sheu = new Sheu();\n\nexport default sheu;\n"]}
@@ -5,7 +5,7 @@ import rateLimit from "express-rate-limit";
5
5
  import { importPrismaModelModules } from "../../utils/helpers/models.helpers.js";
6
6
  import { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, sendResponse, } from "../base/base.middlewares.js";
7
7
  import deepmerge from "../../utils/helpers/deepmerge.helper.js";
8
- import catchAsync from "../error-handler/utils/catch-async.js";
8
+ import { processMiddleware } from "../../utils/helpers/routers.helpers.js";
9
9
  const router = Router();
10
10
  export async function getAuthRouter(arkosConfigs) {
11
11
  const { middlewares, dtos, schemas, prismaQueryOptions } = await importPrismaModelModules("auth", arkosConfigs);
@@ -20,43 +20,10 @@ export async function getAuthRouter(arkosConfigs) {
20
20
  }
21
21
  return undefined;
22
22
  };
23
- const safeCatchAsync = (middleware) => {
24
- return middleware ? catchAsync(middleware) : undefined;
25
- };
26
23
  router
27
- .get("/users/me", authService.authenticate, addPrismaQueryOptionsToRequest(prismaQueryOptions, "getMe"), ...[
28
- safeCatchAsync(middlewares?.beforeGetMe) || authController.getMe,
29
- safeCatchAsync(middlewares?.beforeGetMe)
30
- ? authController.getMe
31
- : safeCatchAsync(middlewares?.afterGetMe) || sendResponse,
32
- safeCatchAsync(middlewares?.beforeGetMe) &&
33
- safeCatchAsync(middlewares?.afterGetMe)
34
- ? safeCatchAsync(middlewares?.afterGetMe)
35
- : sendResponse,
36
- sendResponse,
37
- ].filter((middleware) => !!middleware))
38
- .patch("/users/me", authService.authenticate, handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updateMe")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMe"), ...[
39
- safeCatchAsync(middlewares?.beforeUpdateMe) || authController.updateMe,
40
- safeCatchAsync(middlewares?.beforeUpdateMe)
41
- ? authController.updateMe
42
- : safeCatchAsync(middlewares?.afterUpdateMe) || sendResponse,
43
- safeCatchAsync(middlewares?.beforeUpdateMe) &&
44
- safeCatchAsync(middlewares?.afterUpdateMe)
45
- ? safeCatchAsync(middlewares?.afterUpdateMe)
46
- : sendResponse,
47
- sendResponse,
48
- ].filter((middleware) => !!middleware))
49
- .delete("/users/me", authService.authenticate, addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMe"), ...[
50
- safeCatchAsync(middlewares?.beforeDeleteMe) || authController.deleteMe,
51
- safeCatchAsync(middlewares?.beforeDeleteMe)
52
- ? authController.deleteMe
53
- : safeCatchAsync(middlewares?.afterDeleteMe) || sendResponse,
54
- safeCatchAsync(middlewares?.beforeDeleteMe) &&
55
- safeCatchAsync(middlewares?.afterDeleteMe)
56
- ? safeCatchAsync(middlewares?.afterDeleteMe)
57
- : sendResponse,
58
- sendResponse,
59
- ].filter((middleware) => !!middleware));
24
+ .get("/users/me", authService.authenticate, addPrismaQueryOptionsToRequest(prismaQueryOptions, "getMe"), ...processMiddleware(middlewares?.beforeGetMe), authController.getMe, ...processMiddleware(middlewares?.afterGetMe), sendResponse)
25
+ .patch("/users/me", authService.authenticate, handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updateMe")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMe"), ...processMiddleware(middlewares?.beforeUpdateMe), authController.updateMe, ...processMiddleware(middlewares?.afterUpdateMe), sendResponse)
26
+ .delete("/users/me", authService.authenticate, addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMe"), ...processMiddleware(middlewares?.beforeDeleteMe), authController.deleteMe, ...processMiddleware(middlewares?.afterDeleteMe), sendResponse);
60
27
  router.use("/auth", rateLimit(deepmerge({
61
28
  windowMs: 5000,
62
29
  limit: 10,
@@ -68,51 +35,10 @@ export async function getAuthRouter(arkosConfigs) {
68
35
  });
69
36
  },
70
37
  }, arkosConfigs?.authentication?.requestRateLimitOptions || {})));
71
- router.post("/auth/login", handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("login")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "login"), ...[
72
- safeCatchAsync(middlewares?.beforeLogin) || authController.login,
73
- safeCatchAsync(middlewares?.beforeLogin)
74
- ? authController.login
75
- : safeCatchAsync(middlewares?.afterLogin) || sendResponse,
76
- safeCatchAsync(middlewares?.beforeLogin) &&
77
- safeCatchAsync(middlewares?.afterLogin)
78
- ? safeCatchAsync(middlewares?.afterLogin)
79
- : sendResponse,
80
- sendResponse,
81
- ].filter((middleware) => !!middleware));
82
- router.delete("/auth/logout", authService.authenticate, ...[
83
- safeCatchAsync(middlewares?.beforeLogout) || authController.logout,
84
- safeCatchAsync(middlewares?.beforeLogout)
85
- ? authController.logout
86
- : safeCatchAsync(middlewares?.afterLogout) || sendResponse,
87
- safeCatchAsync(middlewares?.beforeLogout) &&
88
- safeCatchAsync(middlewares?.afterLogout)
89
- ? safeCatchAsync(middlewares?.afterLogout)
90
- : sendResponse,
91
- sendResponse,
92
- ].filter((middleware) => !!middleware));
93
- router.post("/auth/signup", handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("signup")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "signup"), ...[
94
- safeCatchAsync(middlewares?.beforeSignup) || authController.signup,
95
- safeCatchAsync(middlewares?.beforeSignup)
96
- ? authController.signup
97
- : safeCatchAsync(middlewares?.afterSignup) || sendResponse,
98
- safeCatchAsync(middlewares?.beforeSignup) &&
99
- safeCatchAsync(middlewares?.afterSignup)
100
- ? safeCatchAsync(middlewares?.afterSignup)
101
- : sendResponse,
102
- sendResponse,
103
- ].filter((middleware) => !!middleware));
104
- router.post("/auth/update-password", authService.authenticate, handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updatePassword")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updatePassword"), ...[
105
- safeCatchAsync(middlewares?.beforeUpdatePassword) ||
106
- authController.updatePassword,
107
- safeCatchAsync(middlewares?.beforeUpdatePassword)
108
- ? authController.updatePassword
109
- : safeCatchAsync(middlewares?.afterUpdatePassword) || sendResponse,
110
- safeCatchAsync(middlewares?.beforeUpdatePassword) &&
111
- safeCatchAsync(middlewares?.afterUpdatePassword)
112
- ? safeCatchAsync(middlewares?.afterUpdatePassword)
113
- : sendResponse,
114
- sendResponse,
115
- ].filter((middleware) => !!middleware));
38
+ router.post("/auth/login", handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("login")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "login"), ...processMiddleware(middlewares?.beforeLogin), authController.login, ...processMiddleware(middlewares?.afterLogin), sendResponse);
39
+ router.delete("/auth/logout", authService.authenticate, ...processMiddleware(middlewares?.beforeLogout), authController.logout, ...processMiddleware(middlewares?.afterLogout), sendResponse);
40
+ router.post("/auth/signup", handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("signup")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "signup"), ...processMiddleware(middlewares?.beforeSignup), authController.signup, ...processMiddleware(middlewares?.afterSignup), sendResponse);
41
+ router.post("/auth/update-password", authService.authenticate, handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updatePassword")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updatePassword"), ...processMiddleware(middlewares?.beforeUpdatePassword), authController.updatePassword, ...processMiddleware(middlewares?.afterUpdatePassword), sendResponse);
116
42
  return router;
117
43
  }
118
44
  //# sourceMappingURL=auth.router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.router.js","sourceRoot":"","sources":["../../../../src/modules/auth/auth.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,WAAW,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AAW,EAAE,WAAW,CAAC;YAC1C,CAAC,CAAC,YAAY;QAChB,YAAY;KACb,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CACvC,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,uBAAuB,EACvB,WAAW,CAAC,YAAY,EACxB,4CAA4C,CAC1C,wBAAwB,CAAC,gBAAgB,CAAC,CAC3C,EACD,8BAA8B,CAC5B,kBAAiD,EACjD,gBAAgB,CACjB,EACD,GAAG;QACD,cAAc,CAAC,WAAW,EAAE,oBAAoB,CAAC;YAC/C,cAAc,CAAC,cAAc;QAC/B,cAAc,CAAC,WAAW,EAAE,oBAAoB,CAAC;YAC/C,CAAC,CAAC,cAAc,CAAC,cAAc;YAC/B,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE,mBAAmB,CAAC,IAAI,YAAY;QACpE,cAAc,CAAC,WAAW,EAAE,oBAAoB,CAAC;YACjD,cAAc,CAAC,WAAW,EAAE,mBAAmB,CAAC;YAC9C,CAAC,CAAC,cAAc,CAAC,WAAW,EAAE,mBAAmB,CAAC;YAClD,CAAC,CAAC,YAAY;QAChB,YAAY;KACb,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CACvC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Router } from \"express\";\nimport { authControllerFactory } from \"./auth.controller\";\nimport authService from \"./auth.service\";\nimport rateLimit from \"express-rate-limit\";\nimport { importPrismaModelModules } from \"../../utils/helpers/models.helpers\";\nimport {\n addPrismaQueryOptionsToRequest,\n handleRequestBodyValidationAndTransformation,\n sendResponse,\n} from \"../base/base.middlewares\";\nimport { ArkosConfig } from \"../../types/arkos-config\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport { AuthPrismaQueryOptions } from \"../../types\";\nimport catchAsync from \"../error-handler/utils/catch-async\";\n\nconst router: Router = Router();\n\nexport async function getAuthRouter(arkosConfigs: ArkosConfig) {\n const { middlewares, dtos, schemas, prismaQueryOptions } =\n await importPrismaModelModules(\"auth\", arkosConfigs);\n const authController = await authControllerFactory(middlewares);\n\n // Helper to get the correct schema or DTO based on Arkos Config\n const getValidationSchemaOrDto = (key: string) => {\n const validationConfigs = arkosConfigs?.validation;\n if (validationConfigs?.resolver === \"class-validator\") {\n return dtos?.[key];\n } else if (validationConfigs?.resolver === \"zod\") {\n return schemas?.[key];\n }\n return undefined;\n };\n\n // Helper to conditionally wrap middleware with catchAsync\n const safeCatchAsync = (middleware: any) => {\n return middleware ? catchAsync(middleware) : undefined;\n };\n\n router\n .get(\n \"/users/me\",\n authService.authenticate,\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"getMe\"\n ),\n ...[\n safeCatchAsync(middlewares?.beforeGetMe) || authController.getMe,\n safeCatchAsync(middlewares?.beforeGetMe)\n ? authController.getMe\n : safeCatchAsync(middlewares?.afterGetMe) || sendResponse,\n safeCatchAsync(middlewares?.beforeGetMe) &&\n safeCatchAsync(middlewares?.afterGetMe)\n ? safeCatchAsync(middlewares?.afterGetMe)\n : sendResponse,\n sendResponse,\n ].filter((middleware) => !!middleware)\n )\n .patch(\n \"/users/me\",\n authService.authenticate,\n handleRequestBodyValidationAndTransformation(\n getValidationSchemaOrDto(\"updateMe\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"updateMe\"\n ),\n ...[\n safeCatchAsync(middlewares?.beforeUpdateMe) || authController.updateMe,\n safeCatchAsync(middlewares?.beforeUpdateMe)\n ? authController.updateMe\n : safeCatchAsync(middlewares?.afterUpdateMe) || sendResponse,\n safeCatchAsync(middlewares?.beforeUpdateMe) &&\n safeCatchAsync(middlewares?.afterUpdateMe)\n ? safeCatchAsync(middlewares?.afterUpdateMe)\n : sendResponse,\n sendResponse,\n ].filter((middleware) => !!middleware)\n )\n .delete(\n \"/users/me\",\n authService.authenticate,\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"deleteMe\"\n ),\n ...[\n safeCatchAsync(middlewares?.beforeDeleteMe) || authController.deleteMe,\n safeCatchAsync(middlewares?.beforeDeleteMe)\n ? authController.deleteMe\n : safeCatchAsync(middlewares?.afterDeleteMe) || sendResponse,\n safeCatchAsync(middlewares?.beforeDeleteMe) &&\n safeCatchAsync(middlewares?.afterDeleteMe)\n ? safeCatchAsync(middlewares?.afterDeleteMe)\n : sendResponse,\n sendResponse,\n ].filter((middleware) => !!middleware)\n );\n\n router.use(\n \"/auth\",\n rateLimit(\n deepmerge(\n {\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n handler: (req, res) => {\n res.status(429).json({\n message: \"Too many requests, please try again later\",\n });\n },\n },\n arkosConfigs?.authentication?.requestRateLimitOptions || {}\n )\n )\n );\n\n router.post(\n \"/auth/login\",\n handleRequestBodyValidationAndTransformation(\n getValidationSchemaOrDto(\"login\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"login\"\n ),\n ...[\n safeCatchAsync(middlewares?.beforeLogin) || authController.login,\n safeCatchAsync(middlewares?.beforeLogin)\n ? authController.login\n : safeCatchAsync(middlewares?.afterLogin) || sendResponse,\n safeCatchAsync(middlewares?.beforeLogin) &&\n safeCatchAsync(middlewares?.afterLogin)\n ? safeCatchAsync(middlewares?.afterLogin)\n : sendResponse,\n sendResponse,\n ].filter((middleware) => !!middleware)\n );\n\n router.delete(\n \"/auth/logout\",\n authService.authenticate,\n ...[\n safeCatchAsync(middlewares?.beforeLogout) || authController.logout,\n safeCatchAsync(middlewares?.beforeLogout)\n ? authController.logout\n : safeCatchAsync(middlewares?.afterLogout) || sendResponse,\n safeCatchAsync(middlewares?.beforeLogout) &&\n safeCatchAsync(middlewares?.afterLogout)\n ? safeCatchAsync(middlewares?.afterLogout)\n : sendResponse,\n sendResponse,\n ].filter((middleware) => !!middleware)\n );\n\n router.post(\n \"/auth/signup\",\n handleRequestBodyValidationAndTransformation(\n getValidationSchemaOrDto(\"signup\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"signup\"\n ),\n ...[\n safeCatchAsync(middlewares?.beforeSignup) || authController.signup,\n safeCatchAsync(middlewares?.beforeSignup)\n ? authController.signup\n : safeCatchAsync(middlewares?.afterSignup) || sendResponse,\n safeCatchAsync(middlewares?.beforeSignup) &&\n safeCatchAsync(middlewares?.afterSignup)\n ? safeCatchAsync(middlewares?.afterSignup)\n : sendResponse,\n sendResponse,\n ].filter((middleware) => !!middleware)\n );\n\n router.post(\n \"/auth/update-password\",\n authService.authenticate,\n handleRequestBodyValidationAndTransformation(\n getValidationSchemaOrDto(\"updatePassword\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"updatePassword\"\n ),\n ...[\n safeCatchAsync(middlewares?.beforeUpdatePassword) ||\n authController.updatePassword,\n safeCatchAsync(middlewares?.beforeUpdatePassword)\n ? authController.updatePassword\n : safeCatchAsync(middlewares?.afterUpdatePassword) || sendResponse,\n safeCatchAsync(middlewares?.beforeUpdatePassword) &&\n safeCatchAsync(middlewares?.afterUpdatePassword)\n ? safeCatchAsync(middlewares?.afterUpdatePassword)\n : sendResponse,\n sendResponse,\n ].filter((middleware) => !!middleware)\n );\n\n return router;\n}\n"]}
1
+ {"version":3,"file":"auth.router.js","sourceRoot":"","sources":["../../../../src/modules/auth/auth.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EA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,MAAM,EACrB,GAAG,iBAAiB,CAAC,WAAW,EAAE,WAAW,CAAC,EAC9C,YAAY,CACb,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,cAAc,EACd,4CAA4C,CAC1C,wBAAwB,CAAC,QAAQ,CAAC,CACnC,EACD,8BAA8B,CAC5B,kBAAiD,EACjD,QAAQ,CACT,EACD,GAAG,iBAAiB,CAAC,WAAW,EAAE,YAAY,CAAC,EAC/C,cAAc,CAAC,MAAM,EACrB,GAAG,iBAAiB,CAAC,WAAW,EAAE,WAAW,CAAC,EAC9C,YAAY,CACb,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,uBAAuB,EACvB,WAAW,CAAC,YAAY,EACxB,4CAA4C,CAC1C,wBAAwB,CAAC,gBAAgB,CAAC,CAC3C,EACD,8BAA8B,CAC5B,kBAAiD,EACjD,gBAAgB,CACjB,EACD,GAAG,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,CAAC,EACvD,cAAc,CAAC,cAAc,EAC7B,GAAG,iBAAiB,CAAC,WAAW,EAAE,mBAAmB,CAAC,EACtD,YAAY,CACb,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Router } from \"express\";\nimport { authControllerFactory } from \"./auth.controller\";\nimport authService from \"./auth.service\";\nimport rateLimit from \"express-rate-limit\";\nimport { importPrismaModelModules } from \"../../utils/helpers/models.helpers\";\nimport {\n addPrismaQueryOptionsToRequest,\n handleRequestBodyValidationAndTransformation,\n sendResponse,\n} from \"../base/base.middlewares\";\nimport { ArkosConfig } from \"../../types/arkos-config\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport { AuthPrismaQueryOptions } from \"../../types\";\nimport { processMiddleware } from \"../../utils/helpers/routers.helpers\";\n\nconst router: Router = Router();\n\nexport async function getAuthRouter(arkosConfigs: ArkosConfig) {\n const { middlewares, dtos, schemas, prismaQueryOptions } =\n await importPrismaModelModules(\"auth\", arkosConfigs);\n const authController = await authControllerFactory(middlewares);\n\n // Helper to get the correct schema or DTO based on Arkos Config\n const getValidationSchemaOrDto = (key: string) => {\n const validationConfigs = arkosConfigs?.validation;\n if (validationConfigs?.resolver === \"class-validator\") {\n return dtos?.[key];\n } else if (validationConfigs?.resolver === \"zod\") {\n return schemas?.[key];\n }\n return undefined;\n };\n\n router\n .get(\n \"/users/me\",\n authService.authenticate,\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"getMe\"\n ),\n ...processMiddleware(middlewares?.beforeGetMe),\n authController.getMe,\n ...processMiddleware(middlewares?.afterGetMe),\n sendResponse\n )\n .patch(\n \"/users/me\",\n authService.authenticate,\n handleRequestBodyValidationAndTransformation(\n getValidationSchemaOrDto(\"updateMe\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"updateMe\"\n ),\n ...processMiddleware(middlewares?.beforeUpdateMe),\n authController.updateMe,\n ...processMiddleware(middlewares?.afterUpdateMe),\n sendResponse\n )\n .delete(\n \"/users/me\",\n authService.authenticate,\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"deleteMe\"\n ),\n ...processMiddleware(middlewares?.beforeDeleteMe),\n authController.deleteMe,\n ...processMiddleware(middlewares?.afterDeleteMe),\n sendResponse\n );\n\n router.use(\n \"/auth\",\n rateLimit(\n deepmerge(\n {\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n handler: (req, res) => {\n res.status(429).json({\n message: \"Too many requests, please try again later\",\n });\n },\n },\n arkosConfigs?.authentication?.requestRateLimitOptions || {}\n )\n )\n );\n\n router.post(\n \"/auth/login\",\n handleRequestBodyValidationAndTransformation(\n getValidationSchemaOrDto(\"login\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"login\"\n ),\n ...processMiddleware(middlewares?.beforeLogin),\n authController.login,\n ...processMiddleware(middlewares?.afterLogin),\n sendResponse\n );\n\n router.delete(\n \"/auth/logout\",\n authService.authenticate,\n ...processMiddleware(middlewares?.beforeLogout),\n authController.logout,\n ...processMiddleware(middlewares?.afterLogout),\n sendResponse\n );\n\n router.post(\n \"/auth/signup\",\n handleRequestBodyValidationAndTransformation(\n getValidationSchemaOrDto(\"signup\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"signup\"\n ),\n ...processMiddleware(middlewares?.beforeSignup),\n authController.signup,\n ...processMiddleware(middlewares?.afterSignup),\n sendResponse\n );\n\n router.post(\n \"/auth/update-password\",\n authService.authenticate,\n handleRequestBodyValidationAndTransformation(\n getValidationSchemaOrDto(\"updatePassword\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"updatePassword\"\n ),\n ...processMiddleware(middlewares?.beforeUpdatePassword),\n authController.updatePassword,\n ...processMiddleware(middlewares?.afterUpdatePassword),\n sendResponse\n );\n\n return router;\n}\n"]}
@@ -4,7 +4,7 @@ import { importPrismaModelModules } from "../../../../utils/helpers/models.helpe
4
4
  import authService from "../../../auth/auth.service.js";
5
5
  import { BaseController } from "../../base.controller.js";
6
6
  import { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, sendResponse, } from "../../base.middlewares.js";
7
- import catchAsync from "../../../error-handler/utils/catch-async.js";
7
+ import { processMiddleware } from "../../../../utils/helpers/routers.helpers.js";
8
8
  export function setupRouters(models, router, arkosConfigs) {
9
9
  return models.map(async (model) => {
10
10
  const modelNameInKebab = kebabCase(model);
@@ -33,121 +33,37 @@ export function setupRouters(models, router, arkosConfigs) {
33
33
  };
34
34
  if (customRouterModule?.default && !routerConfig?.disable)
35
35
  router.use(`/${routeName}`, customRouterModule.default);
36
- function safeCatchAsync(middleware) {
37
- return middleware ? catchAsync(middleware) : undefined;
38
- }
39
36
  if (!isEndpointDisabled(routerConfig, "createOne") &&
40
37
  !hasCustomImplementation(`/${routeName}`, "post")) {
41
- router.post(`/${routeName}`, authService.handleAuthenticationControl("Create", authConfigs?.authenticationControl), authService.handleAccessControl("Create", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("create")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "createOne"), ...[
42
- safeCatchAsync(middlewares?.beforeCreateOne) || controller.createOne,
43
- safeCatchAsync(middlewares?.beforeCreateOne)
44
- ? controller.createOne
45
- : safeCatchAsync(middlewares?.afterCreateOne) || sendResponse,
46
- safeCatchAsync(middlewares?.beforeCreateOne) &&
47
- safeCatchAsync(middlewares?.afterCreateOne)
48
- ? safeCatchAsync(middlewares?.afterCreateOne)
49
- : sendResponse,
50
- ].filter((m) => !!m), sendResponse);
38
+ router.post(`/${routeName}`, authService.handleAuthenticationControl("Create", authConfigs?.authenticationControl), authService.handleAccessControl("Create", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("create")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "createOne"), ...processMiddleware(middlewares?.beforeCreateOne), controller.createOne, ...processMiddleware(middlewares?.afterCreateOne), sendResponse);
51
39
  }
52
40
  if (!isEndpointDisabled(routerConfig, "findMany") &&
53
41
  !hasCustomImplementation(`/${routeName}`, "get")) {
54
- router.get(`/${routeName}`, authService.handleAuthenticationControl("View", authConfigs?.authenticationControl), authService.handleAccessControl("View", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), addPrismaQueryOptionsToRequest(prismaQueryOptions, "findMany"), ...[
55
- safeCatchAsync(middlewares?.beforeFindMany) || controller.findMany,
56
- safeCatchAsync(middlewares?.beforeFindMany)
57
- ? controller.findMany
58
- : safeCatchAsync(middlewares?.afterFindMany) || sendResponse,
59
- safeCatchAsync(middlewares?.beforeFindMany) &&
60
- safeCatchAsync(middlewares?.afterFindMany)
61
- ? safeCatchAsync(middlewares?.afterFindMany)
62
- : sendResponse,
63
- sendResponse,
64
- ].filter((m) => !!m));
42
+ router.get(`/${routeName}`, authService.handleAuthenticationControl("View", authConfigs?.authenticationControl), authService.handleAccessControl("View", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), addPrismaQueryOptionsToRequest(prismaQueryOptions, "findMany"), ...processMiddleware(middlewares?.beforeFindMany), controller.findMany, ...processMiddleware(middlewares?.afterFindMany), sendResponse);
65
43
  }
66
44
  if (!isEndpointDisabled(routerConfig, "createMany") &&
67
45
  !hasCustomImplementation(`/${routeName}/many`, "post")) {
68
- router.post(`/${routeName}/many`, authService.handleAuthenticationControl("Create", authConfigs?.authenticationControl), authService.handleAccessControl("Create", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("createMany")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "createMany"), ...[
69
- safeCatchAsync(middlewares?.beforeCreateMany) ||
70
- controller.createMany,
71
- safeCatchAsync(middlewares?.beforeCreateMany)
72
- ? controller.createMany
73
- : safeCatchAsync(middlewares?.afterCreateMany) || sendResponse,
74
- safeCatchAsync(middlewares?.beforeCreateMany) &&
75
- safeCatchAsync(middlewares?.afterCreateMany)
76
- ? safeCatchAsync(middlewares?.afterCreateMany)
77
- : sendResponse,
78
- sendResponse,
79
- ].filter((m) => !!m));
46
+ router.post(`/${routeName}/many`, authService.handleAuthenticationControl("Create", authConfigs?.authenticationControl), authService.handleAccessControl("Create", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("createMany")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "createMany"), ...processMiddleware(middlewares?.beforeCreateMany), controller.createMany, ...processMiddleware(middlewares?.afterCreateMany), sendResponse);
80
47
  }
81
48
  if (!isEndpointDisabled(routerConfig, "updateMany") &&
82
49
  !hasCustomImplementation(`/${routeName}/many`, "patch")) {
83
- router.patch(`/${routeName}/many`, authService.handleAuthenticationControl("Update", authConfigs?.authenticationControl), authService.handleAccessControl("Update", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updateMany")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMany"), ...[
84
- safeCatchAsync(middlewares?.beforeUpdateMany) ||
85
- controller.updateMany,
86
- safeCatchAsync(middlewares?.beforeUpdateMany)
87
- ? controller.updateMany
88
- : safeCatchAsync(middlewares?.afterUpdateMany) || sendResponse,
89
- safeCatchAsync(middlewares?.beforeUpdateMany) &&
90
- safeCatchAsync(middlewares?.afterUpdateMany)
91
- ? safeCatchAsync(middlewares?.afterUpdateMany)
92
- : sendResponse,
93
- sendResponse,
94
- ].filter((m) => !!m));
50
+ router.patch(`/${routeName}/many`, authService.handleAuthenticationControl("Update", authConfigs?.authenticationControl), authService.handleAccessControl("Update", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updateMany")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMany"), ...processMiddleware(middlewares?.beforeUpdateMany), controller.updateMany, ...processMiddleware(middlewares?.afterUpdateMany), sendResponse);
95
51
  }
96
52
  if (!isEndpointDisabled(routerConfig, "deleteMany") &&
97
53
  !hasCustomImplementation(`/${routeName}/many`, "delete")) {
98
- router.delete(`/${routeName}/many`, authService.handleAuthenticationControl("Delete", authConfigs?.authenticationControl), authService.handleAccessControl("Delete", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("deleteMany")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMany"), ...[
99
- safeCatchAsync(middlewares?.beforeDeleteMany) ||
100
- controller.deleteMany,
101
- safeCatchAsync(middlewares?.beforeDeleteMany)
102
- ? controller.deleteMany
103
- : safeCatchAsync(middlewares?.afterDeleteMany) || sendResponse,
104
- safeCatchAsync(middlewares?.beforeDeleteMany) &&
105
- safeCatchAsync(middlewares?.afterDeleteMany)
106
- ? safeCatchAsync(middlewares?.afterDeleteMany)
107
- : sendResponse,
108
- sendResponse,
109
- ].filter((middleware) => !!middleware));
54
+ router.delete(`/${routeName}/many`, authService.handleAuthenticationControl("Delete", authConfigs?.authenticationControl), authService.handleAccessControl("Delete", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("deleteMany")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMany"), ...processMiddleware(middlewares?.beforeDeleteMany), controller.deleteMany, ...processMiddleware(middlewares?.afterDeleteMany), sendResponse);
110
55
  }
111
56
  if (!isEndpointDisabled(routerConfig, "findOne") &&
112
57
  !hasCustomImplementation(`/${routeName}/:id`, "get")) {
113
- router.get(`/${routeName}/:id`, authService.handleAuthenticationControl("View", authConfigs?.authenticationControl), authService.handleAccessControl("View", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("findOne")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "findOne"), ...[
114
- safeCatchAsync(middlewares?.beforeFindOne) || controller.findOne,
115
- safeCatchAsync(middlewares?.beforeFindOne)
116
- ? controller.findOne
117
- : safeCatchAsync(middlewares?.afterFindOne) || sendResponse,
118
- safeCatchAsync(middlewares?.beforeFindOne) &&
119
- safeCatchAsync(middlewares?.afterFindOne)
120
- ? safeCatchAsync(middlewares?.afterFindOne)
121
- : sendResponse,
122
- sendResponse,
123
- ].filter((m) => !!m));
58
+ router.get(`/${routeName}/:id`, authService.handleAuthenticationControl("View", authConfigs?.authenticationControl), authService.handleAccessControl("View", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("findOne")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "findOne"), ...processMiddleware(middlewares?.beforeFindOne), controller.findOne, ...processMiddleware(middlewares?.afterFindOne), sendResponse);
124
59
  }
125
60
  if (!isEndpointDisabled(routerConfig, "updateOne") &&
126
61
  !hasCustomImplementation(`/${routeName}/:id`, "patch")) {
127
- router.patch(`/${routeName}/:id`, authService.handleAuthenticationControl("Update", authConfigs?.authenticationControl), authService.handleAccessControl("Update", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("update")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateOne"), ...[
128
- safeCatchAsync(middlewares?.beforeUpdateOne) || controller.updateOne,
129
- safeCatchAsync(middlewares?.beforeUpdateOne)
130
- ? controller.updateOne
131
- : safeCatchAsync(middlewares?.afterUpdateOne) || sendResponse,
132
- safeCatchAsync(middlewares?.beforeUpdateOne) &&
133
- safeCatchAsync(middlewares?.afterUpdateOne)
134
- ? safeCatchAsync(middlewares?.afterUpdateOne)
135
- : sendResponse,
136
- ].filter((m) => !!m), sendResponse);
62
+ router.patch(`/${routeName}/:id`, authService.handleAuthenticationControl("Update", authConfigs?.authenticationControl), authService.handleAccessControl("Update", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("update")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateOne"), ...processMiddleware(middlewares?.beforeUpdateOne), controller.updateOne, ...processMiddleware(middlewares?.afterUpdateOne), sendResponse);
137
63
  }
138
64
  if (!isEndpointDisabled(routerConfig, "deleteOne") &&
139
65
  !hasCustomImplementation(`/${routeName}/:id`, "delete")) {
140
- router.delete(`/${routeName}/:id`, authService.handleAuthenticationControl("Delete", authConfigs?.authenticationControl), authService.handleAccessControl("Delete", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("delete")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteOne"), ...[
141
- safeCatchAsync(middlewares?.beforeDeleteOne) || controller.deleteOne,
142
- safeCatchAsync(middlewares?.beforeDeleteOne)
143
- ? controller.deleteOne
144
- : safeCatchAsync(middlewares?.afterDeleteOne) || sendResponse,
145
- safeCatchAsync(middlewares?.beforeDeleteOne) &&
146
- safeCatchAsync(middlewares?.afterDeleteOne)
147
- ? safeCatchAsync(middlewares?.afterDeleteOne)
148
- : sendResponse,
149
- sendResponse,
150
- ].filter((m) => !!m));
66
+ router.delete(`/${routeName}/:id`, authService.handleAuthenticationControl("Delete", authConfigs?.authenticationControl), authService.handleAccessControl("Delete", kebabCase(pluralize.singular(modelNameInKebab)), authConfigs?.accessControl || {}), handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("delete")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteOne"), ...processMiddleware(middlewares?.beforeDeleteOne), controller.deleteOne, ...processMiddleware(middlewares?.afterDeleteOne), sendResponse);
151
67
  }
152
68
  });
153
69
  }