arkos 1.4.0-canary.83 → 1.4.0-canary.84

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 (47) hide show
  1. package/dist/cjs/modules/auth/auth.router.js +12 -12
  2. package/dist/cjs/modules/auth/auth.router.js.map +1 -1
  3. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +10 -10
  4. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  5. package/dist/cjs/modules/swagger/utils/helpers/class-validator-to-json-schema.js +2 -2
  6. package/dist/cjs/modules/swagger/utils/helpers/class-validator-to-json-schema.js.map +1 -1
  7. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +2 -2
  8. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -1
  9. package/dist/cjs/utils/arkos-router/index.js +6 -5
  10. package/dist/cjs/utils/arkos-router/index.js.map +1 -1
  11. package/dist/cjs/utils/arkos-router/types/body-parser-config.js +3 -0
  12. package/dist/cjs/utils/arkos-router/types/body-parser-config.js.map +1 -0
  13. package/dist/cjs/utils/arkos-router/types/index.js.map +1 -1
  14. package/dist/cjs/utils/arkos-router/utils/helpers/index.js +13 -3
  15. package/dist/cjs/utils/arkos-router/utils/helpers/index.js.map +1 -1
  16. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  17. package/dist/cjs/utils/helpers/dynamic-loader.helpers.js +34 -55
  18. package/dist/cjs/utils/helpers/dynamic-loader.helpers.js.map +1 -1
  19. package/dist/cjs/utils/helpers/routers.helpers.js +6 -4
  20. package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -1
  21. package/dist/esm/modules/auth/auth.router.js +12 -12
  22. package/dist/esm/modules/auth/auth.router.js.map +1 -1
  23. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +10 -10
  24. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  25. package/dist/esm/modules/swagger/utils/helpers/class-validator-to-json-schema.js +1 -1
  26. package/dist/esm/modules/swagger/utils/helpers/class-validator-to-json-schema.js.map +1 -1
  27. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +1 -1
  28. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +1 -1
  29. package/dist/esm/utils/arkos-router/index.js +6 -5
  30. package/dist/esm/utils/arkos-router/index.js.map +1 -1
  31. package/dist/esm/utils/arkos-router/types/body-parser-config.js +2 -0
  32. package/dist/esm/utils/arkos-router/types/body-parser-config.js.map +1 -0
  33. package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
  34. package/dist/esm/utils/arkos-router/utils/helpers/index.js +13 -3
  35. package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
  36. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  37. package/dist/esm/utils/helpers/arkos-config.helpers.js +2 -2
  38. package/dist/esm/utils/helpers/dynamic-loader.helpers.js +34 -55
  39. package/dist/esm/utils/helpers/dynamic-loader.helpers.js.map +1 -1
  40. package/dist/esm/utils/helpers/routers.helpers.js +6 -4
  41. package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
  42. package/dist/types/modules/auth/auth.router.d.ts +1 -1
  43. package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +1 -1
  44. package/dist/types/utils/arkos-router/types/body-parser-config.d.ts +18 -0
  45. package/dist/types/utils/arkos-router/types/index.d.ts +2 -17
  46. package/dist/types/utils/helpers/routers.helpers.d.ts +2 -1
  47. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/utils/arkos-router/utils/helpers/index.ts"],"names":[],"mappings":";;;;;AAUA,gDA+DC;AAED,gDAyCC;AApHD,4EAA2C;AAC3C,yFAAgE;AAChE,gFAAkF;AAClF,wFAA8D;AAE9D,sDAA8B;AAC9B,8DAAsC;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AI,CAAC,IAAA,4BAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IACpE,IAAI,MAAM,CAAC,WAAW;QAAE,WAAW,CAAC,IAAI,CAAC,IAAA,qBAAW,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1E,IAAI,MAAM,CAAC,WAAW;QAAE,WAAW,CAAC,IAAI,CAAC,IAAA,kCAAW,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IAE1E,IACE,OAAO,MAAM,EAAE,UAAU,KAAK,QAAQ;QACtC,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC;QAE1E,WAAW,CAAC,IAAI,CACd,iBAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAC7D,CAAC;IAEJ,IAAI,MAAM,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACjC,WAAW,CAAC,IAAI,CAAC,wBAAa,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAE1E,WAAW,CAAC,IAAI,CAAC,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC;QAEhD,WAAW,CAAC,IAAI,CACd,wBAAa,CAAC,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAC5D,CAAC;IACJ,CAAC;;QAAM,WAAW,CAAC,IAAI,CAAC,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC;IAEvD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import rateLimit from \"express-rate-limit\";\nimport authService from \"../../../../modules/auth/auth.service\";\nimport { validateRequestInputs } from \"../../../../modules/base/base.middlewares\";\nimport RouteConfigRegistry from \"../../route-config-registry\";\nimport { ArkosRouteConfig } from \"../../types\";\nimport express from \"express\";\nimport compression from \"compression\";\nimport { queryParser } from \"../../../helpers/query-parser.helpers\";\nimport uploadManager from \"./upload-manager\";\n\nexport function extractArkosRoutes(\n app: any,\n basePath = \"\"\n): Array<{\n path: string;\n method: string;\n config?: ArkosRouteConfig;\n}> {\n const routes: Array<{\n path: string;\n method: string;\n config?: ArkosRouteConfig;\n }> = [];\n\n function extractFromStack(stack: any[], prefix = \"\") {\n stack.forEach((layer: any) => {\n if (layer.route) {\n const fullPath = prefix + layer.route.path;\n const methods = Object.keys(layer.route.methods);\n\n methods.forEach((method) => {\n const handlers = layer.route.stack || [];\n let config: ArkosRouteConfig | undefined;\n\n for (const handler of handlers) {\n const foundConfig = RouteConfigRegistry.get(handler.handle);\n\n if (foundConfig) {\n config = foundConfig;\n routes.push({\n path: fullPath,\n method: method.toUpperCase(),\n config,\n });\n\n break;\n }\n }\n });\n } else if (layer.name === \"router\" && layer.handle?.stack) {\n let nestedPrefix = prefix;\n\n if (layer.regexp) {\n const match = layer.regexp\n .toString()\n .match(/\\/\\^?(\\\\\\/[^?]+|\\/[^?]+)/);\n if (match) {\n nestedPrefix = prefix + \"/\" + match[1].replace(/\\\\\\//g, \"/\");\n nestedPrefix = nestedPrefix\n .replace(/\\/\\//g, \"/\")\n .replace(/\\/$/, \"\");\n }\n }\n\n extractFromStack(layer.handle.stack, nestedPrefix);\n }\n });\n }\n\n const stack = app._router?.stack || app.stack;\n if (stack) extractFromStack(stack, basePath);\n\n return routes;\n}\n\nexport function getMiddlewareStack(config: ArkosRouteConfig) {\n const middlewares = [];\n\n if (config.authentication) middlewares.push(authService.authenticate);\n\n if (\n typeof config.authentication === \"object\" &&\n config.authentication.action &&\n config.authentication.resource\n )\n middlewares.push(\n authService.handleAccessControl(\n config.authentication.action,\n config.authentication.resource,\n { [config.authentication.action]: config.authentication?.rule }\n )\n );\n\n if (config.rateLimit) middlewares.push(rateLimit(config.rateLimit));\n if (config.compression) middlewares.push(compression(config.compression));\n if (config.queryParser) middlewares.push(queryParser(config.queryParser));\n\n if (\n typeof config?.bodyParser === \"object\" &&\n [\"json\", \"urlencoded\", \"raw\", \"text\"].includes(config?.bodyParser?.parser)\n )\n middlewares.push(\n express[config.bodyParser.parser](config.bodyParser.options)\n );\n\n if (config.experimental?.uploads) {\n middlewares.push(uploadManager.handleUpload(config.experimental.uploads));\n\n middlewares.push(validateRequestInputs(config));\n\n middlewares.push(\n uploadManager.handlePostUpload(config.experimental.uploads)\n );\n } else middlewares.push(validateRequestInputs(config));\n\n return middlewares;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/utils/arkos-router/utils/helpers/index.ts"],"names":[],"mappings":";;;;;AAWA,gDA+DC;AAED,gDA+CC;AA3HD,4EAA2C;AAC3C,yFAAgE;AAChE,gFAAkF;AAClF,wFAA8D;AAE9D,sDAA8B;AAC9B,8DAAsC;AACtC,gFAAoE;AACpE,sEAA6C;AAC7C,oDAA4B;AAE5B,SAAgB,kBAAkB,CAChC,GAAQ,EACR,QAAQ,GAAG,EAAE;IAMb,MAAM,MAAM,GAIP,EAAE,CAAC;IAER,SAAS,gBAAgB,CAAC,KAAY,EAAE,MAAM,GAAG,EAAE;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;YAC3B,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChB,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAEjD,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;oBACzB,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;oBACzC,IAAI,MAAoC,CAAC;oBAEzC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;wBAC/B,MAAM,WA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,WAAW,CAAC,IAAI,CAAC,iBAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;qBACtD,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW;oBACpC,WAAW,CAAC,IAAI,CAAC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,MAAM,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACjC,WAAW,CAAC,IAAI,CAAC,wBAAa,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAE1E,WAAW,CAAC,IAAI,CAAC,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC;QAEhD,WAAW,CAAC,IAAI,CACd,wBAAa,CAAC,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAC5D,CAAC;IACJ,CAAC;;QAAM,WAAW,CAAC,IAAI,CAAC,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC;IAEvD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import rateLimit from \"express-rate-limit\";\nimport authService from \"../../../../modules/auth/auth.service\";\nimport { validateRequestInputs } from \"../../../../modules/base/base.middlewares\";\nimport RouteConfigRegistry from \"../../route-config-registry\";\nimport { ArkosRouteConfig } from \"../../types\";\nimport express from \"express\";\nimport compression from \"compression\";\nimport { queryParser } from \"../../../helpers/query-parser.helpers\";\nimport uploadManager from \"./upload-manager\";\nimport multer from \"multer\";\n\nexport function extractArkosRoutes(\n app: any,\n basePath = \"\"\n): Array<{\n path: string;\n method: string;\n config?: ArkosRouteConfig;\n}> {\n const routes: Array<{\n path: string;\n method: string;\n config?: ArkosRouteConfig;\n }> = [];\n\n function extractFromStack(stack: any[], prefix = \"\") {\n stack.forEach((layer: any) => {\n if (layer.route) {\n const fullPath = prefix + layer.route.path;\n const methods = Object.keys(layer.route.methods);\n\n methods.forEach((method) => {\n const handlers = layer.route.stack || [];\n let config: ArkosRouteConfig | undefined;\n\n for (const handler of handlers) {\n const foundConfig = RouteConfigRegistry.get(handler.handle);\n\n if (foundConfig) {\n config = foundConfig;\n routes.push({\n path: fullPath,\n method: method.toUpperCase(),\n config,\n });\n\n break;\n }\n }\n });\n } else if (layer.name === \"router\" && layer.handle?.stack) {\n let nestedPrefix = prefix;\n\n if (layer.regexp) {\n const match = layer.regexp\n .toString()\n .match(/\\/\\^?(\\\\\\/[^?]+|\\/[^?]+)/);\n if (match) {\n nestedPrefix = prefix + \"/\" + match[1].replace(/\\\\\\//g, \"/\");\n nestedPrefix = nestedPrefix\n .replace(/\\/\\//g, \"/\")\n .replace(/\\/$/, \"\");\n }\n }\n\n extractFromStack(layer.handle.stack, nestedPrefix);\n }\n });\n }\n\n const stack = app._router?.stack || app.stack;\n if (stack) extractFromStack(stack, basePath);\n\n return routes;\n}\n\nexport function getMiddlewareStack(config: ArkosRouteConfig) {\n const middlewares = [];\n\n if (config.authentication) middlewares.push(authService.authenticate);\n\n if (\n typeof config.authentication === \"object\" &&\n config.authentication.action &&\n config.authentication.resource\n )\n middlewares.push(\n authService.handleAccessControl(\n config.authentication.action,\n config.authentication.resource,\n { [config.authentication.action]: config.authentication?.rule }\n )\n );\n\n if (config.rateLimit) middlewares.push(rateLimit(config.rateLimit));\n if (config.compression) middlewares.push(compression(config.compression));\n if (config.queryParser) middlewares.push(queryParser(config.queryParser));\n\n if (config?.bodyParser) {\n const parsers = Array.isArray(config.bodyParser)\n ? config.bodyParser\n : [config.bodyParser];\n\n parsers.forEach((parser) => {\n if (typeof parser === \"object\" && parser.parser)\n if (parser.parser !== \"multipart\")\n middlewares.push(express[parser.parser](parser.options));\n else if (parser.parser === \"multipart\")\n middlewares.push(multer({ limits: parser.options }).none());\n });\n }\n\n if (config.experimental?.uploads) {\n middlewares.push(uploadManager.handleUpload(config.experimental.uploads));\n\n middlewares.push(validateRequestInputs(config));\n\n middlewares.push(\n uploadManager.handlePostUpload(config.experimental.uploads)\n );\n } else middlewares.push(validateRequestInputs(config));\n\n return middlewares;\n}\n"]}
@@ -19,6 +19,6 @@ function killServerChildProcess() {
19
19
  (0, start_1.killProductionServerChildProcess)();
20
20
  }
21
21
  function getVersion() {
22
- return "1.4.0-canary.83";
22
+ return "1.4.0-canary.84";
23
23
  }
24
24
  //# sourceMappingURL=cli.helpers.js.map
@@ -7,10 +7,9 @@ exports.applyStrictRoutingRules = applyStrictRoutingRules;
7
7
  exports.validateRouterConfigConsistency = validateRouterConfigConsistency;
8
8
  exports.pathExists = pathExists;
9
9
  const fs_1 = __importDefault(require("fs"));
10
- const deepmerge_helper_1 = __importDefault(require("./deepmerge.helper"));
11
10
  function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
12
11
  const strictMode = arkosConfig?.routers?.strict || false;
13
- let config = moduleConfig || {};
12
+ let config = moduleConfig ? { ...moduleConfig } : {};
14
13
  appModule = appModule.toLowerCase();
15
14
  const allEndpoints = appModule === "auth"
16
15
  ? [
@@ -38,18 +37,15 @@ function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
38
37
  const hadBooleanDisable = typeof config.disable === "boolean";
39
38
  if (hadBooleanDisable) {
40
39
  const disableValue = config.disable;
41
- const disableObject = {};
42
- const endpointConfigs = {};
40
+ config.disable = {};
43
41
  for (const endpoint of allEndpoints) {
44
- disableObject[endpoint] = disableValue;
45
- endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)(config[endpoint] || {}, {
46
- disabled: disableValue,
47
- });
42
+ config.disable[endpoint] = disableValue;
43
+ if (!config[endpoint]) {
44
+ config[endpoint] = {};
45
+ }
46
+ config[endpoint].disabled = disableValue;
48
47
  }
49
- return (0, deepmerge_helper_1.default)(config, {
50
- disable: disableObject,
51
- ...endpointConfigs,
52
- });
48
+ return config;
53
49
  }
54
50
  if (strictMode === true) {
55
51
  const strictDefaults = appModule === "auth"
@@ -80,30 +76,7 @@ function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
80
76
  updateMany: true,
81
77
  deleteMany: true,
82
78
  };
83
- const disableConfig = (0, deepmerge_helper_1.default)(strictDefaults, config?.disable || {});
84
- const endpointConfigs = {};
85
- for (const endpoint of Object.keys(strictDefaults)) {
86
- endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)({ disabled: strictDefaults[endpoint] }, config[endpoint] || {});
87
- }
88
- const syncedDisable = { ...disableConfig };
89
- for (const endpoint of allEndpoints) {
90
- const endpointDisabled = config[endpoint]?.disabled;
91
- if (endpointDisabled !== undefined) {
92
- syncedDisable[endpoint] = endpointDisabled;
93
- }
94
- }
95
- const syncedEndpoints = { ...endpointConfigs };
96
- for (const endpoint of allEndpoints) {
97
- if (syncedDisable[endpoint] !== undefined) {
98
- syncedEndpoints[endpoint] = (0, deepmerge_helper_1.default)(syncedEndpoints[endpoint] || {}, {
99
- disabled: syncedDisable[endpoint],
100
- });
101
- }
102
- }
103
- return (0, deepmerge_helper_1.default)(config, {
104
- disable: syncedDisable,
105
- ...syncedEndpoints,
106
- });
79
+ applyDisabledFlags(config, allEndpoints, strictDefaults);
107
80
  }
108
81
  else if (strictMode === "no-bulk" &&
109
82
  !["auth", "file-upload"].includes(appModule.toLowerCase())) {
@@ -112,30 +85,36 @@ function applyStrictRoutingRules(appModule, arkosConfig, moduleConfig) {
112
85
  updateMany: true,
113
86
  deleteMany: true,
114
87
  };
115
- const disableConfig = (0, deepmerge_helper_1.default)(noBulkDefaults, config.disable || {});
116
- const endpointConfigs = {};
117
- for (const endpoint of Object.keys(noBulkDefaults)) {
118
- endpointConfigs[endpoint] = (0, deepmerge_helper_1.default)({ disabled: noBulkDefaults[endpoint] }, config[endpoint] || {});
88
+ applyDisabledFlags(config, allEndpoints, noBulkDefaults);
89
+ }
90
+ return config;
91
+ }
92
+ function applyDisabledFlags(config, allEndpoints, defaults) {
93
+ if (!config.disable || typeof config.disable === "boolean") {
94
+ config.disable = {};
95
+ }
96
+ for (const endpoint of allEndpoints) {
97
+ const defaultDisabled = defaults[endpoint];
98
+ const userDisableOverride = config.disable[endpoint];
99
+ const endpointDisabled = config[endpoint]?.disabled;
100
+ let finalDisabled;
101
+ if (endpointDisabled !== undefined) {
102
+ finalDisabled = endpointDisabled;
119
103
  }
120
- const syncedDisable = { ...disableConfig };
121
- for (const endpoint of allEndpoints) {
122
- const endpointDisabled = config[endpoint]?.disabled;
123
- if (endpointDisabled !== undefined) {
124
- syncedDisable[endpoint] = endpointDisabled;
125
- }
104
+ else if (userDisableOverride !== undefined) {
105
+ finalDisabled = userDisableOverride;
126
106
  }
127
- const syncedEndpoints = { ...endpointConfigs };
128
- for (const endpoint of allEndpoints) {
129
- if (syncedDisable[endpoint] !== undefined) {
130
- syncedEndpoints[endpoint] = (0, deepmerge_helper_1.default)({ disabled: syncedDisable[endpoint] }, syncedEndpoints[endpoint] || {});
107
+ else if (defaultDisabled !== undefined) {
108
+ finalDisabled = defaultDisabled;
109
+ }
110
+ if (finalDisabled !== undefined) {
111
+ config.disable[endpoint] = finalDisabled;
112
+ if (!config[endpoint]) {
113
+ config[endpoint] = {};
131
114
  }
115
+ config[endpoint].disabled = finalDisabled;
132
116
  }
133
- return (0, deepmerge_helper_1.default)(config, {
134
- disable: syncedDisable,
135
- ...syncedEndpoints,
136
- });
137
117
  }
138
- return config;
139
118
  }
140
119
  function validateRouterConfigConsistency(appModule, config) {
141
120
  if (!config.disable || typeof config.disable === "boolean")
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-loader.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/dynamic-loader.helpers.ts"],"names":[],"mappings":";;;;;AAOA,0DA0KC;AAED,0EAwBC;AAED,gCAOC;AAnND,4CAAoB;AACpB,0EAA2C;AAK3C,SAAgB,uBAAuB,CACrC,SAAY,EACZ,WAAwB,EACxB,YAA8B;IAE9B,MAAM,UAAU,GAAG,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;YACD,MAAM,IAAI,KAAK,CACb,6CAA6C,QAAQ,eAAe,SAAS,IAAI;gBAC/E,WAAW,QAAQ,MAAM,WAAW,SAAS,QAAQ,eAAe,WAAW,IAAI;gBACnF,kDAAkD,CACrD,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,MAAM,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport fs from \"fs\";\nimport deepmerge from \"./deepmerge.helper\";\n\n/**\n * Applies strict routing rules to module configuration\n */\nexport function applyStrictRoutingRules<T extends string>(\n appModule: T,\n arkosConfig: ArkosConfig,\n moduleConfig?: RouterConfig<T>\n): RouterConfig<T> {\n const strictMode = arkosConfig?.routers?.strict || false;\n let config: any = moduleConfig || ({} as RouterConfig<T>);\n appModule = appModule.toLowerCase() as T;\n\n const allEndpoints =\n appModule === \"auth\"\n ? [\n \"getMe\",\n \"updateMe\",\n \"deleteMe\",\n \"login\",\n \"logout\",\n \"signup\",\n \"updatePassword\",\n \"findManyAuthAction\",\n ]\n : appModule === \"file-upload\"\n ? [\"findFile\", \"uploadFile\", \"updateFile\", \"deleteFile\"]\n : [\n \"createOne\",\n \"findOne\",\n \"updateOne\",\n \"deleteOne\",\n \"createMany\",\n \"findMany\",\n \"updateMany\",\n \"deleteMany\",\n ];\n\n const hadBooleanDisable = typeof config.disable === \"boolean\";\n\n // IMPORTANT: Order matters in deepmerge!\n // User config must be SECOND argument to override defaults\n\n if (hadBooleanDisable) {\n const disableValue = config.disable;\n const disableObject: Record<string, boolean> = {};\n const endpointConfigs: Record<string, any> = {};\n\n for (const endpoint of allEndpoints) {\n (disableObject as any)[endpoint] = disableValue;\n endpointConfigs[endpoint] = deepmerge((config as any)[endpoint] || {}, {\n disabled: disableValue,\n });\n }\n\n return deepmerge(config as any, {\n disable: disableObject,\n ...endpointConfigs,\n }) as RouterConfig<T>;\n }\n\n if (strictMode === true) {\n const strictDefaults: any =\n appModule === \"auth\"\n ? {\n getMe: true,\n updateMe: true,\n deleteMe: true,\n login: true,\n logout: true,\n signup: true,\n updatePassword: true,\n findManyAuthAction: true,\n }\n : appModule === \"file-upload\"\n ? {\n findFile: true,\n uploadFile: true,\n updateFile: true,\n deleteFile: true,\n }\n : {\n createOne: true,\n findOne: true,\n updateOne: true,\n deleteOne: true,\n createMany: true,\n findMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n strictDefaults,\n (config?.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(strictDefaults)) {\n endpointConfigs[endpoint] = deepmerge(\n { disabled: strictDefaults[endpoint] },\n (config as any)[endpoint] || {}\n );\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (syncedDisable[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(syncedEndpoints[endpoint] || {}, {\n disabled: syncedDisable[endpoint],\n });\n }\n }\n\n return deepmerge(config as any, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n } else if (\n strictMode === \"no-bulk\" &&\n ![\"auth\", \"file-upload\"].includes(appModule.toLowerCase())\n ) {\n const noBulkDefaults: any = {\n createMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n const disableConfig: any = deepmerge(\n noBulkDefaults,\n (config.disable as any) || {}\n );\n\n const endpointConfigs: Record<string, any> = {};\n for (const endpoint of Object.keys(noBulkDefaults)) {\n endpointConfigs[endpoint] = deepmerge(\n { disabled: noBulkDefaults[endpoint] },\n (config as any)[endpoint] || {}\n );\n }\n\n const syncedDisable: Record<string, boolean> = { ...disableConfig };\n for (const endpoint of allEndpoints) {\n const endpointDisabled = (config as any)[endpoint]?.disabled;\n if (endpointDisabled !== undefined) {\n syncedDisable[endpoint] = endpointDisabled;\n }\n }\n\n const syncedEndpoints: Record<string, any> = { ...endpointConfigs };\n for (const endpoint of allEndpoints) {\n if (syncedDisable[endpoint] !== undefined) {\n syncedEndpoints[endpoint] = deepmerge(\n { disabled: syncedDisable[endpoint] },\n syncedEndpoints[endpoint] || {}\n );\n }\n }\n\n return deepmerge(config as any, {\n disable: syncedDisable,\n ...syncedEndpoints,\n }) as RouterConfig<T>;\n }\n\n return config;\n}\n\nexport function validateRouterConfigConsistency(\n appModule: string,\n config: Record<string, any>\n): void {\n if (!config.disable || typeof config.disable === \"boolean\") return;\n\n const endpoints = Object.keys(config.disable) as any[];\n\n for (const endpoint of endpoints) {\n const oldWayValue = (config.disable as any)[endpoint];\n const newWayValue = (config as any)[endpoint]?.disabled;\n\n if (\n oldWayValue !== undefined &&\n newWayValue !== undefined &&\n oldWayValue !== newWayValue\n ) {\n throw new Error(\n `Conflicting disabled values for endpoint \"${endpoint}\" of module ${appModule}: ` +\n `disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +\n `Please use only one method to disable endpoints.`\n );\n }\n }\n}\n\nexport async function pathExists(path: string) {\n try {\n await fs.promises.stat(path);\n return true;\n } catch (err) {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"dynamic-loader.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/dynamic-loader.helpers.ts"],"names":[],"mappings":";;;;;AAMA,0DAiGC;AAqCD,0EAwBC;AAED,gCAOC;AA5KD,4CAAoB;AAKpB,SAAgB,uBAAuB,CACrC,SAAY,EACZ,WAAwB,EACx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,MAAM,WAAW,GAAI,MAAc,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;QAExD,IACE,WAAW,KAAK,SAAS;YACzB,WAAW,KAAK,SAAS;YACzB,WAAW,KAAK,WAAW,EAC3B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,6CAA6C,QAAQ,eAAe,SAAS,IAAI;gBAC/E,WAAW,QAAQ,MAAM,WAAW,SAAS,QAAQ,eAAe,WAAW,IAAI;gBACnF,kDAAkD,CACrD,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,MAAM,YAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { ArkosConfig, RouterConfig } from \"../../exports\";\nimport fs from \"fs\";\n\n/**\n * Applies strict routing rules to module configuration\n */\nexport function applyStrictRoutingRules<T extends string>(\n appModule: T,\n arkosConfig: ArkosConfig,\n moduleConfig?: RouterConfig<T>\n): RouterConfig<T> {\n const strictMode = arkosConfig?.routers?.strict || false;\n let config: any = moduleConfig ? { ...moduleConfig } : {};\n appModule = appModule.toLowerCase() as T;\n\n const allEndpoints =\n appModule === \"auth\"\n ? [\n \"getMe\",\n \"updateMe\",\n \"deleteMe\",\n \"login\",\n \"logout\",\n \"signup\",\n \"updatePassword\",\n \"findManyAuthAction\",\n ]\n : appModule === \"file-upload\"\n ? [\"findFile\", \"uploadFile\", \"updateFile\", \"deleteFile\"]\n : [\n \"createOne\",\n \"findOne\",\n \"updateOne\",\n \"deleteOne\",\n \"createMany\",\n \"findMany\",\n \"updateMany\",\n \"deleteMany\",\n ];\n\n const hadBooleanDisable = typeof config.disable === \"boolean\";\n if (hadBooleanDisable) {\n const disableValue = config.disable;\n config.disable = {};\n\n for (const endpoint of allEndpoints) {\n config.disable[endpoint] = disableValue;\n\n if (!config[endpoint]) {\n config[endpoint] = {};\n }\n config[endpoint].disabled = disableValue;\n }\n\n return config as RouterConfig<T>;\n }\n\n if (strictMode === true) {\n const strictDefaults: Record<string, boolean> =\n appModule === \"auth\"\n ? {\n getMe: true,\n updateMe: true,\n deleteMe: true,\n login: true,\n logout: true,\n signup: true,\n updatePassword: true,\n findManyAuthAction: true,\n }\n : appModule === \"file-upload\"\n ? {\n findFile: true,\n uploadFile: true,\n updateFile: true,\n deleteFile: true,\n }\n : {\n createOne: true,\n findOne: true,\n updateOne: true,\n deleteOne: true,\n createMany: true,\n findMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n applyDisabledFlags(config, allEndpoints, strictDefaults);\n } else if (\n strictMode === \"no-bulk\" &&\n ![\"auth\", \"file-upload\"].includes(appModule.toLowerCase())\n ) {\n const noBulkDefaults: Record<string, boolean> = {\n createMany: true,\n updateMany: true,\n deleteMany: true,\n };\n\n applyDisabledFlags(config, allEndpoints, noBulkDefaults);\n }\n\n return config as RouterConfig<T>;\n}\n\nfunction applyDisabledFlags(\n config: any,\n allEndpoints: string[],\n defaults: Record<string, boolean>\n): void {\n if (!config.disable || typeof config.disable === \"boolean\") {\n config.disable = {};\n }\n\n for (const endpoint of allEndpoints) {\n const defaultDisabled = defaults[endpoint];\n const userDisableOverride = config.disable[endpoint];\n const endpointDisabled = config[endpoint]?.disabled;\n\n let finalDisabled: boolean | undefined;\n\n if (endpointDisabled !== undefined) {\n finalDisabled = endpointDisabled;\n } else if (userDisableOverride !== undefined) {\n finalDisabled = userDisableOverride;\n } else if (defaultDisabled !== undefined) {\n finalDisabled = defaultDisabled;\n }\n\n if (finalDisabled !== undefined) {\n config.disable[endpoint] = finalDisabled;\n\n if (!config[endpoint]) {\n config[endpoint] = {};\n }\n config[endpoint].disabled = finalDisabled;\n }\n }\n}\n\nexport function validateRouterConfigConsistency(\n appModule: string,\n config: Record<string, any>\n): void {\n if (!config.disable || typeof config.disable === \"boolean\") return;\n\n const endpoints = Object.keys(config.disable) as any[];\n\n for (const endpoint of endpoints) {\n const oldWayValue = (config.disable as any)[endpoint];\n const newWayValue = (config as any)[endpoint]?.disabled;\n\n if (\n oldWayValue !== undefined &&\n newWayValue !== undefined &&\n oldWayValue !== newWayValue\n ) {\n throw new Error(\n `Conflicting disabled values for endpoint \"${endpoint}\" of module ${appModule}: ` +\n `disable.${endpoint} = ${oldWayValue}, but ${endpoint}.disabled = ${newWayValue}. ` +\n `Please use only one method to disable endpoints.`\n );\n }\n }\n}\n\nexport async function pathExists(path: string) {\n try {\n await fs.promises.stat(path);\n return true;\n } catch (err) {\n return false;\n }\n}\n"]}
@@ -70,13 +70,15 @@ function getAuthenticationConfig(endpoint, modelName, authConfigs) {
70
70
  }
71
71
  return false;
72
72
  }
73
- function createRouteConfig(endpoint, routeName, path, routerConfig, modelNameInKebab, authConfigs, validationSchema) {
73
+ function createRouteConfig(arkosConfig, endpoint, routeName, path, routerConfig, modelNameInKebab, authConfigs, validationSchema) {
74
74
  let config = {
75
75
  path: `/${routeName}${path}`,
76
76
  disabled: (0, base_router_helpers_1.isEndpointDisabled)(routerConfig, endpoint),
77
- authentication: typeof authConfigs === "boolean"
78
- ? authConfigs
79
- : getAuthenticationConfig(endpoint, modelNameInKebab, authConfigs),
77
+ ...(arkosConfig.authentication?.mode && {
78
+ authentication: typeof authConfigs === "boolean"
79
+ ? authConfigs
80
+ : getAuthenticationConfig(endpoint, modelNameInKebab, authConfigs),
81
+ }),
80
82
  validation: validationSchema ? { body: validationSchema } : undefined,
81
83
  experimental: { openapi: false },
82
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"routers.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/routers.helpers.ts"],"names":[],"mappings":";;;;;;AAoDA,0DAuCC;AAaD,8CAwBC;AAhID,0DAAkC;AAClC,gGAEuD;AAEvD,+DAAkD;AAMlD,8FAA0F;AAC1F,0EAA2C;AA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AE,IAAI,SAAS,GAAG,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAA,wCAAkB,EAAC,YAAY,EAAE,QAAQ,CAAC;QACpD,cAAc,EACZ,OAAO,WAAW,KAAK,SAAS;YAC9B,CAAC,CAAC,WAAW;YACb,CAAC,CAAC,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,WAAW,CAAC;QACtE,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,SAAS;QACrE,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;KACjC,CAAC;IAEF,MAAM,cAAc,GAAI,YAAoB,CAAC,QAAQ,CAAC,CAAC;IACvD,IAAI,cAAc;QAAE,MAAM,GAAG,IAAA,0BAAS,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAE/D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import pluralize from \"pluralize\";\nimport catchAsync, {\n CatchAsyncReturnType,\n} from \"../../modules/error-handler/utils/catch-async\";\nimport { AccessAction, AuthConfigs } from \"../../types/auth\";\nimport { kebabCase } from \"./change-case.helpers\";\nimport {\n AuthRouterEndpoint,\n RouterConfig,\n RouterEndpoint,\n} from \"../../types/router-config\";\nimport { isEndpointDisabled } from \"../../modules/base/utils/helpers/base.router.helpers\";\nimport deepmerge from \"./deepmerge.helper\";\nimport { ArkosRouteConfig } from \"../arkos-router/types\";\n\nfunction throwErrorIfInterceptorIsNotAFunction(middleware: any) {\n if (middleware && typeof middleware !== \"function\")\n throw Error(\n `Validation Error: Invalid interceptor of type ${typeof middleware}, they must be a function or an array of function. checkout https://arkosjs.com/docs/core-concepts/interceptor-middlewares`\n );\n}\n\nexport const safeCatchAsync = (\n middleware: any,\n options: { type: \"error\" | \"normal\" } = { type: \"normal\" }\n) => {\n if (middleware && typeof middleware !== \"function\")\n throw Error(\n `Validation Error: Invalid interceptor of type ${typeof middleware}, they must be a function or an array of function. checkout https://arkosjs.com/docs/core-concepts/interceptor-middlewares`\n );\n\n return middleware ? catchAsync(middleware, options) : undefined;\n};\n\nexport const processMiddleware = (\n middleware: any,\n options: { type: \"error\" | \"normal\" } = { type: \"normal\" }\n) => {\n if (!middleware) return [];\n if (Array.isArray(middleware)) {\n return middleware\n .filter((mw) => !!mw)\n .map((mw) => {\n throwErrorIfInterceptorIsNotAFunction(mw);\n return safeCatchAsync(mw, options);\n }) as CatchAsyncReturnType[];\n } else {\n throwErrorIfInterceptorIsNotAFunction(middleware);\n return [safeCatchAsync(middleware, options)] as CatchAsyncReturnType[];\n }\n};\n\nexport function getAuthenticationConfig(\n endpoint: RouterEndpoint | AuthRouterEndpoint,\n modelName: string,\n authConfigs?: AuthConfigs\n) {\n const actionMap: Record<any, AccessAction> = {\n createOne: \"Create\",\n findOneAuthAction: \"View\",\n findManyAuthAction: \"View\",\n findMany: \"View\",\n createMany: \"Create\",\n updateMany: \"Update\",\n deleteMany: \"Delete\",\n findOne: \"View\",\n updateOne: \"Update\",\n deleteOne: \"Delete\",\n };\n\n const action = actionMap[endpoint];\n const authenticationControl = authConfigs?.authenticationControl;\n\n if (authenticationControl === true) return true;\n else if (\n (authenticationControl &&\n typeof authenticationControl === \"object\" &&\n (authenticationControl[action] === true ||\n authenticationControl[action] !== false)) ||\n (!authenticationControl && authenticationControl !== false)\n ) {\n return {\n resource: kebabCase(pluralize.singular(modelName)),\n action: action,\n rule: Array.isArray(authConfigs?.accessControl)\n ? authConfigs?.accessControl\n : (authConfigs?.accessControl || {})?.[action],\n };\n }\n\n return false;\n}\n\n/**\n * Creates a route configuration object for a specific endpoint\n * @param endpoint - The router endpoint type\n * @param routeName - The pluralized route name (e.g., \"users\")\n * @param path - The path suffix for the route (e.g., \"\", \"/:id\", \"/many\")\n * @param routerConfig - The router configuration object\n * @param modelNameInKebab - The model name in kebab-case\n * @param authConfigs - Authentication configurations\n * @param validationSchema - Optional validation schema for the endpoint\n * @returns Route configuration object\n */\nexport function createRouteConfig(\n endpoint: RouterEndpoint | AuthRouterEndpoint,\n routeName: string,\n path: string,\n routerConfig: RouterConfig<any>,\n modelNameInKebab: string,\n authConfigs: any,\n validationSchema?: any\n) {\n let config: ArkosRouteConfig = {\n path: `/${routeName}${path}`,\n disabled: isEndpointDisabled(routerConfig, endpoint),\n authentication:\n typeof authConfigs === \"boolean\"\n ? authConfigs\n : getAuthenticationConfig(endpoint, modelNameInKebab, authConfigs),\n validation: validationSchema ? { body: validationSchema } : undefined,\n experimental: { openapi: false },\n };\n\n const endpointConfig = (routerConfig as any)[endpoint];\n if (endpointConfig) config = deepmerge(config, endpointConfig);\n\n return config;\n}\n"]}
1
+ {"version":3,"file":"routers.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/routers.helpers.ts"],"names":[],"mappings":";;;;;;AAsDA,0DAuCC;AAaD,8CA2BC;AArID,0DAAkC;AAClC,gGAEuD;AAEvD,+DAAkD;AAMlD,8FAA0F;AAC1F,0EAA2C;AAK3C,SAAS,qCAAqC,CAAC,UAAe;IAC5D,IAAI,UAAU,IAAI,OAAO,UAAU,KAAK,UAAU;QAChD,MAAM,KAAK,CACT,iDAAiD,OAAO,UAAU,4HAA4H,CAC/L,CAAC;AACN,CAAC;AAEM,MAAM,cAAc,GAAG,CAC5B,UAAe,EACf,UAAwC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAC1D,EAAE;IACF,IAAI,UAAU,IAAI,OAAO,UAAU,KAAK,UAAU;QAChD,MAAM,KAAK,CACT,iDAAiD,OAAO,UAAU,4HAA4H,CAC/L,CAAC;IAEJ,OAAO,UAAU,CAAC,CAAC,CAAC,IAAA,qBAAU,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB;AAEK,MAAM,iBAAiB,GAAG,CAC/B,UAAe,EACf,UAAwC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAC1D,EAAE;IACF,I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C;IAE/D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import pluralize from \"pluralize\";\nimport catchAsync, {\n CatchAsyncReturnType,\n} from \"../../modules/error-handler/utils/catch-async\";\nimport { AccessAction, AuthConfigs } from \"../../types/auth\";\nimport { kebabCase } from \"./change-case.helpers\";\nimport {\n AuthRouterEndpoint,\n RouterConfig,\n RouterEndpoint,\n} from \"../../types/router-config\";\nimport { isEndpointDisabled } from \"../../modules/base/utils/helpers/base.router.helpers\";\nimport deepmerge from \"./deepmerge.helper\";\nimport { ArkosRouteConfig } from \"../arkos-router/types\";\nimport { getArkosConfig } from \"./arkos-config.helpers\";\nimport { ArkosConfig } from \"../../exports\";\n\nfunction throwErrorIfInterceptorIsNotAFunction(middleware: any) {\n if (middleware && typeof middleware !== \"function\")\n throw Error(\n `Validation Error: Invalid interceptor of type ${typeof middleware}, they must be a function or an array of function. checkout https://arkosjs.com/docs/core-concepts/interceptor-middlewares`\n );\n}\n\nexport const safeCatchAsync = (\n middleware: any,\n options: { type: \"error\" | \"normal\" } = { type: \"normal\" }\n) => {\n if (middleware && typeof middleware !== \"function\")\n throw Error(\n `Validation Error: Invalid interceptor of type ${typeof middleware}, they must be a function or an array of function. checkout https://arkosjs.com/docs/core-concepts/interceptor-middlewares`\n );\n\n return middleware ? catchAsync(middleware, options) : undefined;\n};\n\nexport const processMiddleware = (\n middleware: any,\n options: { type: \"error\" | \"normal\" } = { type: \"normal\" }\n) => {\n if (!middleware) return [];\n if (Array.isArray(middleware)) {\n return middleware\n .filter((mw) => !!mw)\n .map((mw) => {\n throwErrorIfInterceptorIsNotAFunction(mw);\n return safeCatchAsync(mw, options);\n }) as CatchAsyncReturnType[];\n } else {\n throwErrorIfInterceptorIsNotAFunction(middleware);\n return [safeCatchAsync(middleware, options)] as CatchAsyncReturnType[];\n }\n};\n\nexport function getAuthenticationConfig(\n endpoint: RouterEndpoint | AuthRouterEndpoint,\n modelName: string,\n authConfigs?: AuthConfigs\n) {\n const actionMap: Record<any, AccessAction> = {\n createOne: \"Create\",\n findOneAuthAction: \"View\",\n findManyAuthAction: \"View\",\n findMany: \"View\",\n createMany: \"Create\",\n updateMany: \"Update\",\n deleteMany: \"Delete\",\n findOne: \"View\",\n updateOne: \"Update\",\n deleteOne: \"Delete\",\n };\n\n const action = actionMap[endpoint];\n const authenticationControl = authConfigs?.authenticationControl;\n\n if (authenticationControl === true) return true;\n else if (\n (authenticationControl &&\n typeof authenticationControl === \"object\" &&\n (authenticationControl[action] === true ||\n authenticationControl[action] !== false)) ||\n (!authenticationControl && authenticationControl !== false)\n ) {\n return {\n resource: kebabCase(pluralize.singular(modelName)),\n action: action,\n rule: Array.isArray(authConfigs?.accessControl)\n ? authConfigs?.accessControl\n : (authConfigs?.accessControl || {})?.[action],\n };\n }\n\n return false;\n}\n\n/**\n * Creates a route configuration object for a specific endpoint\n * @param endpoint - The router endpoint type\n * @param routeName - The pluralized route name (e.g., \"users\")\n * @param path - The path suffix for the route (e.g., \"\", \"/:id\", \"/many\")\n * @param routerConfig - The router configuration object\n * @param modelNameInKebab - The model name in kebab-case\n * @param authConfigs - Authentication configurations\n * @param validationSchema - Optional validation schema for the endpoint\n * @returns Route configuration object\n */\nexport function createRouteConfig(\n arkosConfig: ArkosConfig,\n endpoint: RouterEndpoint | AuthRouterEndpoint,\n routeName: string,\n path: string,\n routerConfig: RouterConfig<any>,\n modelNameInKebab: string,\n authConfigs: any,\n validationSchema?: any\n) {\n let config: ArkosRouteConfig = {\n path: `/${routeName}${path}`,\n disabled: isEndpointDisabled(routerConfig, endpoint),\n ...(arkosConfig.authentication?.mode && {\n authentication:\n typeof authConfigs === \"boolean\"\n ? authConfigs\n : getAuthenticationConfig(endpoint, modelNameInKebab, authConfigs),\n }),\n validation: validationSchema ? { body: validationSchema } : undefined,\n experimental: { openapi: false },\n };\n\n const endpointConfig = (routerConfig as any)[endpoint];\n if (endpointConfig) config = deepmerge(config, endpointConfig);\n\n return config;\n}\n"]}
@@ -10,7 +10,7 @@ import routerValidator from "../base/utils/router-validator.js";
10
10
  import { getUserFileExtension } from "../../utils/helpers/fs.helpers.js";
11
11
  import ArkosRouter from "../../utils/arkos-router/index.js";
12
12
  const router = ArkosRouter();
13
- export function getAuthRouter(arkosConfigs) {
13
+ export function getAuthRouter(arkosConfig) {
14
14
  const { interceptors, dtos, schemas, prismaQueryOptions, router: customRouterModule, authConfigs, } = getModuleComponents("auth") || {};
15
15
  const routerConfig = customRouterModule?.config || {};
16
16
  const customRouter = customRouterModule?.default;
@@ -24,7 +24,7 @@ export function getAuthRouter(arkosConfigs) {
24
24
  if (routerConfig?.disable === true)
25
25
  return router;
26
26
  const getValidationSchemaOrDto = (key) => {
27
- const validationConfigs = arkosConfigs?.validation;
27
+ const validationConfigs = arkosConfig?.validation;
28
28
  if (validationConfigs?.resolver === "class-validator")
29
29
  return dtos?.[key];
30
30
  else if (validationConfigs?.resolver === "zod")
@@ -32,13 +32,13 @@ export function getAuthRouter(arkosConfigs) {
32
32
  return undefined;
33
33
  };
34
34
  if (!isEndpointDisabled(routerConfig, "getMe")) {
35
- router.get(createRouteConfig("getMe", "users", "/me", routerConfig, "auth", true), addPrismaQueryOptionsToRequest(prismaQueryOptions, "getMe"), ...processMiddleware(interceptors?.beforeGetMe), authController.getMe, ...processMiddleware(interceptors?.afterGetMe), sendResponse, ...processMiddleware(interceptors?.onGetMeError, { type: "error" }));
35
+ router.get(createRouteConfig(arkosConfig, "getMe", "users", "/me", routerConfig, "auth", true), addPrismaQueryOptionsToRequest(prismaQueryOptions, "getMe"), ...processMiddleware(interceptors?.beforeGetMe), authController.getMe, ...processMiddleware(interceptors?.afterGetMe), sendResponse, ...processMiddleware(interceptors?.onGetMeError, { type: "error" }));
36
36
  }
37
37
  if (!isEndpointDisabled(routerConfig, "updateMe")) {
38
- router.patch(createRouteConfig("updateMe", "users", "/me", routerConfig, "auth", true, getValidationSchemaOrDto("updateMe")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMe"), ...processMiddleware(interceptors?.beforeUpdateMe), authController.updateMe, ...processMiddleware(interceptors?.afterUpdateMe), sendResponse, ...processMiddleware(interceptors?.onUpdateMeError, { type: "error" }));
38
+ router.patch(createRouteConfig(arkosConfig, "updateMe", "users", "/me", routerConfig, "auth", true, getValidationSchemaOrDto("updateMe")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMe"), ...processMiddleware(interceptors?.beforeUpdateMe), authController.updateMe, ...processMiddleware(interceptors?.afterUpdateMe), sendResponse, ...processMiddleware(interceptors?.onUpdateMeError, { type: "error" }));
39
39
  }
40
40
  if (!isEndpointDisabled(routerConfig, "deleteMe")) {
41
- router.delete(createRouteConfig("deleteMe", "users", "/me", routerConfig, "auth", true), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMe"), ...processMiddleware(interceptors?.beforeDeleteMe), authController.deleteMe, ...processMiddleware(interceptors?.afterDeleteMe), sendResponse, ...processMiddleware(interceptors?.onDeleteMeError, { type: "error" }));
41
+ router.delete(createRouteConfig(arkosConfig, "deleteMe", "users", "/me", routerConfig, "auth", true), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMe"), ...processMiddleware(interceptors?.beforeDeleteMe), authController.deleteMe, ...processMiddleware(interceptors?.afterDeleteMe), sendResponse, ...processMiddleware(interceptors?.onDeleteMeError, { type: "error" }));
42
42
  }
43
43
  if (!isEndpointDisabled(routerConfig, "login") ||
44
44
  !isEndpointDisabled(routerConfig, "logout") ||
@@ -54,29 +54,29 @@ export function getAuthRouter(arkosConfigs) {
54
54
  message: "Too many requests, please try again later",
55
55
  });
56
56
  },
57
- }, arkosConfigs?.authentication?.rateLimit || {})));
57
+ }, arkosConfig?.authentication?.rateLimit || {})));
58
58
  }
59
59
  if (!isEndpointDisabled(routerConfig, "login")) {
60
- router.post(createRouteConfig("login", "auth", "/login", routerConfig, "auth", false, getValidationSchemaOrDto("login")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "login"), ...processMiddleware(interceptors?.beforeLogin), authController.login, ...processMiddleware(interceptors?.afterLogin), sendResponse, ...processMiddleware(interceptors?.onLoginError, { type: "error" }));
60
+ router.post(createRouteConfig(arkosConfig, "login", "auth", "/login", routerConfig, "auth", false, getValidationSchemaOrDto("login")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "login"), ...processMiddleware(interceptors?.beforeLogin), authController.login, ...processMiddleware(interceptors?.afterLogin), sendResponse, ...processMiddleware(interceptors?.onLoginError, { type: "error" }));
61
61
  }
62
62
  if (!isEndpointDisabled(routerConfig, "logout")) {
63
- router.delete(createRouteConfig("logout", "auth", "/logout", routerConfig, "auth", true), ...processMiddleware(interceptors?.beforeLogout), authController.logout, ...processMiddleware(interceptors?.afterLogout), sendResponse, ...processMiddleware(interceptors?.onLogoutError, { type: "error" }));
63
+ router.delete(createRouteConfig(arkosConfig, "logout", "auth", "/logout", routerConfig, "auth", true), ...processMiddleware(interceptors?.beforeLogout), authController.logout, ...processMiddleware(interceptors?.afterLogout), sendResponse, ...processMiddleware(interceptors?.onLogoutError, { type: "error" }));
64
64
  }
65
65
  if (!isEndpointDisabled(routerConfig, "signup")) {
66
- router.post(createRouteConfig("signup", "auth", "/signup", routerConfig, "auth", false, getValidationSchemaOrDto("signup")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "signup"), ...processMiddleware(interceptors?.beforeSignup), authController.signup, ...processMiddleware(interceptors?.afterSignup), sendResponse, ...processMiddleware(interceptors?.onSignupError, { type: "error" }));
66
+ router.post(createRouteConfig(arkosConfig, "signup", "auth", "/signup", routerConfig, "auth", false, getValidationSchemaOrDto("signup")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "signup"), ...processMiddleware(interceptors?.beforeSignup), authController.signup, ...processMiddleware(interceptors?.afterSignup), sendResponse, ...processMiddleware(interceptors?.onSignupError, { type: "error" }));
67
67
  }
68
68
  if (!isEndpointDisabled(routerConfig, "updatePassword")) {
69
- router.post(createRouteConfig("updatePassword", "auth", "/update-password", routerConfig, "auth", true, getValidationSchemaOrDto("updatePassword")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updatePassword"), ...processMiddleware(interceptors?.beforeUpdatePassword), authController.updatePassword, ...processMiddleware(interceptors?.afterUpdatePassword), sendResponse, ...processMiddleware(interceptors?.onUpdatePasswordError, {
69
+ router.post(createRouteConfig(arkosConfig, "updatePassword", "auth", "/update-password", routerConfig, "auth", true, getValidationSchemaOrDto("updatePassword")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updatePassword"), ...processMiddleware(interceptors?.beforeUpdatePassword), authController.updatePassword, ...processMiddleware(interceptors?.afterUpdatePassword), sendResponse, ...processMiddleware(interceptors?.onUpdatePasswordError, {
70
70
  type: "error",
71
71
  }));
72
72
  }
73
73
  if (!isEndpointDisabled(routerConfig, "findManyAuthAction")) {
74
- router.get(createRouteConfig("findManyAuthAction", "auth-actions", "", routerConfig, "auth", authConfigs), ...processMiddleware(interceptors?.beforeFindManyAuthAction), authController.findManyAuthAction, ...processMiddleware(interceptors?.afterFindManyAuthAction), sendResponse, ...processMiddleware(interceptors?.onFindManyAuthActionError, {
74
+ router.get(createRouteConfig(arkosConfig, "findManyAuthAction", "auth-actions", "", routerConfig, "auth", authConfigs), ...processMiddleware(interceptors?.beforeFindManyAuthAction), authController.findManyAuthAction, ...processMiddleware(interceptors?.afterFindManyAuthAction), sendResponse, ...processMiddleware(interceptors?.onFindManyAuthActionError, {
75
75
  type: "error",
76
76
  }));
77
77
  }
78
78
  if (!isEndpointDisabled(routerConfig, "findOneAuthAction")) {
79
- router.get(createRouteConfig("findOneAuthAction", "auth-actions", "/:resourceName", routerConfig, "auth", authConfigs), ...processMiddleware(interceptors?.beforeFindOneAuthAction), authController.findOneAuthAction, ...processMiddleware(interceptors?.afterFindOneAuthAction), sendResponse, ...processMiddleware(interceptors?.onFindOneAuthActionError, {
79
+ router.get(createRouteConfig(arkosConfig, "findOneAuthAction", "auth-actions", "/:resourceName", routerConfig, "auth", authConfigs), ...processMiddleware(interceptors?.beforeFindOneAuthAction), authController.findOneAuthAction, ...processMiddleware(interceptors?.afterFindOneAuthAction), sendResponse, ...processMiddleware(interceptors?.onFindOneAuthActionError, {
80
80
  type: "error",
81
81
  }));
82
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.router.js","sourceRoot":"","sources":["../../../../src/modules/auth/auth.router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,8BAA8B,EAC9B,YAAY,GACb,MAAM,0BAA0B,CAAC;AAElC,OAAO,SAAS,MAAM,sCAAsC,CAAC;AAE7D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;AAE7B,MAAM,UAAU,aAAa,CAAC,YAAyB;IACrD,MAAM,EACJ,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,kBAAkB,EAClB,MAAM,EAAE,kBAAkB,EAC1B,WAAW,GACZ,GAAG,mBAAmB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAEtC,MAAM,YAAY,GAAG,kBAAkB,EAAE,MAAM,IAAI,EAAE,CAAC;IACtD,MAAM,YAAY,GAAG,kBAAkB,EAAE,OAAiB,CAAC;IAE3D,IAAI,YAAY,IAAI,kBAAkB,EAAE,CAAC;QACvC,IAAI,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC;YAC/C,MAAM,CAAC,GAAG,CAA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,CAAC,YAAY,EAAE,uBAAuB,CAAC,EAC3D,YAAY,EACZ,GAAG,iBAAiB,CAAC,YAAY,EAAE,yBAAyB,EAAE;YAC5D,IAAI,EAAE,OAAO;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IAGD,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE,mBAAmB,CAAC,EAAE,CAAC;QAC3D,MAAM,CAAC,GAAG,CACR,iBAAiB,CACf,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,MAAM,EACN,WAAW,CACZ,EACD,GAAG,iBAAiB,CAAC,YAAY,EAAE,uBAAuB,CAAC,EAC3D,cAAc,CAAC,iBAAiB,EAChC,GAAG,iBAAiB,CAAC,YAAY,EAAE,sBAAsB,CAAC,EAC1D,YAAY,EACZ,GAAG,iBAAiB,CAAC,YAAY,EAAE,wBAAwB,EAAE;YAC3D,IAAI,EAAE,OAAO;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IAED,eAAe,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAa,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Router } from \"express\";\nimport { authControllerFactory } from \"./auth.controller\";\nimport rateLimit from \"express-rate-limit\";\nimport { getModuleComponents } from \"../../utils/dynamic-loader\";\nimport {\n addPrismaQueryOptionsToRequest,\n sendResponse,\n} from \"../base/base.middlewares\";\nimport { ArkosConfig } from \"../../types/new-arkos-config\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport { AuthPrismaQueryOptions } from \"../../types\";\nimport {\n processMiddleware,\n createRouteConfig,\n} from \"../../utils/helpers/routers.helpers\";\nimport { isEndpointDisabled } from \"../base/utils/helpers/base.router.helpers\";\nimport debuggerService from \"../debugger/debugger.service\";\nimport routerValidator from \"../base/utils/router-validator\";\nimport { getUserFileExtension } from \"../../utils/helpers/fs.helpers\";\nimport ArkosRouter from \"../../utils/arkos-router\";\n\nconst router = ArkosRouter();\n\nexport function getAuthRouter(arkosConfigs: ArkosConfig) {\n const {\n interceptors,\n dtos,\n schemas,\n prismaQueryOptions,\n router: customRouterModule,\n authConfigs,\n } = getModuleComponents(\"auth\") || {};\n\n const routerConfig = customRouterModule?.config || {};\n const customRouter = customRouterModule?.default as Router;\n\n if (customRouter && customRouterModule) {\n if (routerValidator.isExpressRouter(customRouter))\n router.use(`/auth`, customRouter);\n else\n throw Error(\n `ValidationError: The exported router from auth.router.${getUserFileExtension()} is not a valid express or arkos Router.`\n );\n }\n\n const authController = authControllerFactory(interceptors);\n\n if (routerConfig?.disable === true) return router;\n\n const getValidationSchemaOrDto = (\n key: \"updateMe\" | \"updatePassword\" | \"login\" | \"signup\"\n ) => {\n const validationConfigs = arkosConfigs?.validation;\n if (validationConfigs?.resolver === \"class-validator\") return dtos?.[key];\n else if (validationConfigs?.resolver === \"zod\") return schemas?.[key];\n\n return undefined;\n };\n\n // GET /users/me - Get current user\n if (!isEndpointDisabled(routerConfig, \"getMe\")) {\n router.get(\n createRouteConfig(\"getMe\", \"users\", \"/me\", routerConfig, \"auth\", true),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"getMe\"\n ),\n ...processMiddleware(interceptors?.beforeGetMe),\n authController.getMe,\n ...processMiddleware(interceptors?.afterGetMe),\n sendResponse,\n ...processMiddleware(interceptors?.onGetMeError, { type: \"error\" })\n );\n }\n\n // PATCH /users/me - Update current user\n if (!isEndpointDisabled(routerConfig, \"updateMe\")) {\n router.patch(\n createRouteConfig(\n \"updateMe\",\n \"users\",\n \"/me\",\n routerConfig,\n \"auth\",\n true,\n getValidationSchemaOrDto(\"updateMe\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"updateMe\"\n ),\n ...processMiddleware(interceptors?.beforeUpdateMe),\n authController.updateMe,\n ...processMiddleware(interceptors?.afterUpdateMe),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdateMeError, { type: \"error\" })\n );\n }\n\n // DELETE /users/me - Delete current user\n if (!isEndpointDisabled(routerConfig, \"deleteMe\")) {\n router.delete(\n createRouteConfig(\"deleteMe\", \"users\", \"/me\", routerConfig, \"auth\", true),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"deleteMe\"\n ),\n ...processMiddleware(interceptors?.beforeDeleteMe),\n authController.deleteMe,\n ...processMiddleware(interceptors?.afterDeleteMe),\n sendResponse,\n ...processMiddleware(interceptors?.onDeleteMeError, { type: \"error\" })\n );\n }\n\n // Apply rate limiting to auth routes\n if (\n !isEndpointDisabled(routerConfig, \"login\") ||\n !isEndpointDisabled(routerConfig, \"logout\") ||\n !isEndpointDisabled(routerConfig, \"signup\") ||\n !isEndpointDisabled(routerConfig, \"updatePassword\")\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: (_, res) => {\n res.status(429).json({\n message: \"Too many requests, please try again later\",\n });\n },\n },\n arkosConfigs?.authentication?.rateLimit || {}\n )\n )\n );\n }\n\n // POST /auth/login - Login\n if (!isEndpointDisabled(routerConfig, \"login\")) {\n router.post(\n createRouteConfig(\n \"login\",\n \"auth\",\n \"/login\",\n routerConfig,\n \"auth\",\n false,\n getValidationSchemaOrDto(\"login\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"login\"\n ),\n ...processMiddleware(interceptors?.beforeLogin),\n authController.login,\n ...processMiddleware(interceptors?.afterLogin),\n sendResponse,\n ...processMiddleware(interceptors?.onLoginError, { type: \"error\" })\n );\n }\n\n // DELETE /auth/logout - Logout\n if (!isEndpointDisabled(routerConfig, \"logout\")) {\n router.delete(\n createRouteConfig(\n \"logout\",\n \"auth\",\n \"/logout\",\n routerConfig,\n \"auth\",\n true\n ),\n ...processMiddleware(interceptors?.beforeLogout),\n authController.logout,\n ...processMiddleware(interceptors?.afterLogout),\n sendResponse,\n ...processMiddleware(interceptors?.onLogoutError, { type: \"error\" })\n );\n }\n\n // POST /auth/signup - Signup\n if (!isEndpointDisabled(routerConfig, \"signup\")) {\n router.post(\n createRouteConfig(\n \"signup\",\n \"auth\",\n \"/signup\",\n routerConfig,\n \"auth\",\n false,\n getValidationSchemaOrDto(\"signup\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"signup\"\n ),\n ...processMiddleware(interceptors?.beforeSignup),\n authController.signup,\n ...processMiddleware(interceptors?.afterSignup),\n sendResponse,\n ...processMiddleware(interceptors?.onSignupError, { type: \"error\" })\n );\n }\n\n // POST /auth/update-password - Update password\n if (!isEndpointDisabled(routerConfig, \"updatePassword\")) {\n router.post(\n createRouteConfig(\n \"updatePassword\",\n \"auth\",\n \"/update-password\",\n routerConfig,\n \"auth\",\n true,\n getValidationSchemaOrDto(\"updatePassword\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"updatePassword\"\n ),\n ...processMiddleware(interceptors?.beforeUpdatePassword),\n authController.updatePassword,\n ...processMiddleware(interceptors?.afterUpdatePassword),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdatePasswordError, {\n type: \"error\",\n })\n );\n }\n\n // GET /auth-actions - Find many auth actions\n if (!isEndpointDisabled(routerConfig, \"findManyAuthAction\")) {\n router.get(\n createRouteConfig(\n \"findManyAuthAction\",\n \"auth-actions\",\n \"\",\n routerConfig,\n \"auth\",\n authConfigs\n ),\n ...processMiddleware(interceptors?.beforeFindManyAuthAction),\n authController.findManyAuthAction,\n ...processMiddleware(interceptors?.afterFindManyAuthAction),\n sendResponse,\n ...processMiddleware(interceptors?.onFindManyAuthActionError, {\n type: \"error\",\n })\n );\n }\n\n // GET /auth-actions/:resourceName - Find one auth action\n if (!isEndpointDisabled(routerConfig, \"findOneAuthAction\")) {\n router.get(\n createRouteConfig(\n \"findOneAuthAction\",\n \"auth-actions\",\n \"/:resourceName\",\n routerConfig,\n \"auth\",\n authConfigs\n ),\n ...processMiddleware(interceptors?.beforeFindOneAuthAction),\n authController.findOneAuthAction,\n ...processMiddleware(interceptors?.afterFindOneAuthAction),\n sendResponse,\n ...processMiddleware(interceptors?.onFindOneAuthActionError, {\n type: \"error\",\n })\n );\n }\n\n debuggerService.logModuleFinalRouter(\"auth\", router as any);\n return router;\n}\n"]}
1
+ {"version":3,"file":"auth.router.js","sourceRoot":"","sources":["../../../../src/modules/auth/auth.router.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,8BAA8B,EAC9B,YAAY,GACb,MAAM,0BAA0B,CAAC;AAElC,OAAO,SAAS,MAAM,sCAAsC,CAAC;AAE7D,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;AAE7B,MAAM,UAAU,aAAa,CAAC,WAAwB;IACpD,MAAM,EACJ,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,kBAAkB,EAClB,MAAM,EAAE,kBAAkB,EAC1B,WAAW,GACZ,GAAG,mBAAmB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAEtC,MAAM,YAAY,GAAG,kBAAkB,EAAE,MAAM,IAAI,EAAE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,oBAAoB,CAAC,EAAE,CAAC;QAC5D,MAAM,CAAC,GAAG,CACR,iBAAiB,CACf,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,EAAE,EACF,YAAY,EACZ,MAAM,EACN,WAAW,CACZ,EACD,GAAG,iBAAiB,CAAC,YAAY,EAAE,wBAAwB,CAAC,EAC5D,cAAc,CAAC,kBAAkB,EACjC,GAAG,iBAAiB,CAAC,YAAY,EAAE,uBAAuB,CAAC,EAC3D,YAAY,EACZ,GAAG,iBAAiB,CAAC,YAAY,EAAE,yBAAyB,EAAE;YAC5D,IAAI,EAAE,OAAO;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IAGD,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE,mBAAmB,CAAC,EAAE,CAAC;QAC3D,MAAM,CAAC,GAAG,CACR,iBAAiB,CACf,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,MAAM,EACN,WAAW,CACZ,EACD,GAAG,iBAAiB,CAAC,YAAY,EAAE,uBAAuB,CAAC,EAC3D,cAAc,CAAC,iBAAiB,EAChC,GAAG,iBAAiB,CAAC,YAAY,EAAE,sBAAsB,CAAC,EAC1D,YAAY,EACZ,GAAG,iBAAiB,CAAC,YAAY,EAAE,wBAAwB,EAAE;YAC3D,IAAI,EAAE,OAAO;SACd,CAAC,CACH,CAAC;IACJ,CAAC;IAED,eAAe,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAa,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Router } from \"express\";\nimport { authControllerFactory } from \"./auth.controller\";\nimport rateLimit from \"express-rate-limit\";\nimport { getModuleComponents } from \"../../utils/dynamic-loader\";\nimport {\n addPrismaQueryOptionsToRequest,\n sendResponse,\n} from \"../base/base.middlewares\";\nimport { ArkosConfig } from \"../../types/new-arkos-config\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport { AuthPrismaQueryOptions } from \"../../types\";\nimport {\n processMiddleware,\n createRouteConfig,\n} from \"../../utils/helpers/routers.helpers\";\nimport { isEndpointDisabled } from \"../base/utils/helpers/base.router.helpers\";\nimport debuggerService from \"../debugger/debugger.service\";\nimport routerValidator from \"../base/utils/router-validator\";\nimport { getUserFileExtension } from \"../../utils/helpers/fs.helpers\";\nimport ArkosRouter from \"../../utils/arkos-router\";\n\nconst router = ArkosRouter();\n\nexport function getAuthRouter(arkosConfig: ArkosConfig) {\n const {\n interceptors,\n dtos,\n schemas,\n prismaQueryOptions,\n router: customRouterModule,\n authConfigs,\n } = getModuleComponents(\"auth\") || {};\n\n const routerConfig = customRouterModule?.config || {};\n const customRouter = customRouterModule?.default as Router;\n\n if (customRouter && customRouterModule) {\n if (routerValidator.isExpressRouter(customRouter))\n router.use(`/auth`, customRouter);\n else\n throw Error(\n `ValidationError: The exported router from auth.router.${getUserFileExtension()} is not a valid express or arkos Router.`\n );\n }\n\n const authController = authControllerFactory(interceptors);\n\n if (routerConfig?.disable === true) return router;\n\n const getValidationSchemaOrDto = (\n key: \"updateMe\" | \"updatePassword\" | \"login\" | \"signup\"\n ) => {\n const validationConfigs = arkosConfig?.validation;\n if (validationConfigs?.resolver === \"class-validator\") return dtos?.[key];\n else if (validationConfigs?.resolver === \"zod\") return schemas?.[key];\n\n return undefined;\n };\n\n // GET /users/me - Get current user\n if (!isEndpointDisabled(routerConfig, \"getMe\")) {\n router.get(\n createRouteConfig(\n arkosConfig,\n \"getMe\",\n \"users\",\n \"/me\",\n routerConfig,\n \"auth\",\n true\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"getMe\"\n ),\n ...processMiddleware(interceptors?.beforeGetMe),\n authController.getMe,\n ...processMiddleware(interceptors?.afterGetMe),\n sendResponse,\n ...processMiddleware(interceptors?.onGetMeError, { type: \"error\" })\n );\n }\n\n // PATCH /users/me - Update current user\n if (!isEndpointDisabled(routerConfig, \"updateMe\")) {\n router.patch(\n createRouteConfig(\n arkosConfig,\n \"updateMe\",\n \"users\",\n \"/me\",\n routerConfig,\n \"auth\",\n true,\n getValidationSchemaOrDto(\"updateMe\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"updateMe\"\n ),\n ...processMiddleware(interceptors?.beforeUpdateMe),\n authController.updateMe,\n ...processMiddleware(interceptors?.afterUpdateMe),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdateMeError, { type: \"error\" })\n );\n }\n\n // DELETE /users/me - Delete current user\n if (!isEndpointDisabled(routerConfig, \"deleteMe\")) {\n router.delete(\n createRouteConfig(\n arkosConfig,\n \"deleteMe\",\n \"users\",\n \"/me\",\n routerConfig,\n \"auth\",\n true\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"deleteMe\"\n ),\n ...processMiddleware(interceptors?.beforeDeleteMe),\n authController.deleteMe,\n ...processMiddleware(interceptors?.afterDeleteMe),\n sendResponse,\n ...processMiddleware(interceptors?.onDeleteMeError, { type: \"error\" })\n );\n }\n\n // Apply rate limiting to auth routes\n if (\n !isEndpointDisabled(routerConfig, \"login\") ||\n !isEndpointDisabled(routerConfig, \"logout\") ||\n !isEndpointDisabled(routerConfig, \"signup\") ||\n !isEndpointDisabled(routerConfig, \"updatePassword\")\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: (_, res) => {\n res.status(429).json({\n message: \"Too many requests, please try again later\",\n });\n },\n },\n arkosConfig?.authentication?.rateLimit || {}\n )\n )\n );\n }\n\n // POST /auth/login - Login\n if (!isEndpointDisabled(routerConfig, \"login\")) {\n router.post(\n createRouteConfig(\n arkosConfig,\n \"login\",\n \"auth\",\n \"/login\",\n routerConfig,\n \"auth\",\n false,\n getValidationSchemaOrDto(\"login\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"login\"\n ),\n ...processMiddleware(interceptors?.beforeLogin),\n authController.login,\n ...processMiddleware(interceptors?.afterLogin),\n sendResponse,\n ...processMiddleware(interceptors?.onLoginError, { type: \"error\" })\n );\n }\n\n // DELETE /auth/logout - Logout\n if (!isEndpointDisabled(routerConfig, \"logout\")) {\n router.delete(\n createRouteConfig(\n arkosConfig,\n \"logout\",\n \"auth\",\n \"/logout\",\n routerConfig,\n \"auth\",\n true\n ),\n ...processMiddleware(interceptors?.beforeLogout),\n authController.logout,\n ...processMiddleware(interceptors?.afterLogout),\n sendResponse,\n ...processMiddleware(interceptors?.onLogoutError, { type: \"error\" })\n );\n }\n\n // POST /auth/signup - Signup\n if (!isEndpointDisabled(routerConfig, \"signup\")) {\n router.post(\n createRouteConfig(\n arkosConfig,\n \"signup\",\n \"auth\",\n \"/signup\",\n routerConfig,\n \"auth\",\n false,\n getValidationSchemaOrDto(\"signup\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"signup\"\n ),\n ...processMiddleware(interceptors?.beforeSignup),\n authController.signup,\n ...processMiddleware(interceptors?.afterSignup),\n sendResponse,\n ...processMiddleware(interceptors?.onSignupError, { type: \"error\" })\n );\n }\n\n // POST /auth/update-password - Update password\n if (!isEndpointDisabled(routerConfig, \"updatePassword\")) {\n router.post(\n createRouteConfig(\n arkosConfig,\n \"updatePassword\",\n \"auth\",\n \"/update-password\",\n routerConfig,\n \"auth\",\n true,\n getValidationSchemaOrDto(\"updatePassword\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as AuthPrismaQueryOptions<any>,\n \"updatePassword\"\n ),\n ...processMiddleware(interceptors?.beforeUpdatePassword),\n authController.updatePassword,\n ...processMiddleware(interceptors?.afterUpdatePassword),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdatePasswordError, {\n type: \"error\",\n })\n );\n }\n\n // GET /auth-actions - Find many auth actions\n if (!isEndpointDisabled(routerConfig, \"findManyAuthAction\")) {\n router.get(\n createRouteConfig(\n arkosConfig,\n \"findManyAuthAction\",\n \"auth-actions\",\n \"\",\n routerConfig,\n \"auth\",\n authConfigs\n ),\n ...processMiddleware(interceptors?.beforeFindManyAuthAction),\n authController.findManyAuthAction,\n ...processMiddleware(interceptors?.afterFindManyAuthAction),\n sendResponse,\n ...processMiddleware(interceptors?.onFindManyAuthActionError, {\n type: \"error\",\n })\n );\n }\n\n // GET /auth-actions/:resourceName - Find one auth action\n if (!isEndpointDisabled(routerConfig, \"findOneAuthAction\")) {\n router.get(\n createRouteConfig(\n arkosConfig,\n \"findOneAuthAction\",\n \"auth-actions\",\n \"/:resourceName\",\n routerConfig,\n \"auth\",\n authConfigs\n ),\n ...processMiddleware(interceptors?.beforeFindOneAuthAction),\n authController.findOneAuthAction,\n ...processMiddleware(interceptors?.afterFindOneAuthAction),\n sendResponse,\n ...processMiddleware(interceptors?.onFindOneAuthActionError, {\n type: \"error\",\n })\n );\n }\n\n debuggerService.logModuleFinalRouter(\"auth\", router as any);\n return router;\n}\n"]}
@@ -8,7 +8,7 @@ import routerValidator from "../router-validator.js";
8
8
  import { getUserFileExtension } from "../../../../utils/helpers/fs.helpers.js";
9
9
  import prismaSchemaParser from "../../../../utils/prisma/prisma-schema-parser.js";
10
10
  import debuggerService from "../../../debugger/debugger.service.js";
11
- export function setupRouters(router, arkosConfigs) {
11
+ export function setupRouters(router, arkosConfig) {
12
12
  return prismaSchemaParser.getModelsAsArrayOfStrings().map(async (model) => {
13
13
  const modelNameInKebab = kebabCase(model);
14
14
  const modelModules = getModuleComponents(modelNameInKebab) || {};
@@ -25,7 +25,7 @@ export function setupRouters(router, arkosConfigs) {
25
25
  layer.method.toLowerCase() === method.toLowerCase());
26
26
  };
27
27
  const getValidationSchemaOrDto = (key) => {
28
- const validationConfigs = arkosConfigs?.validation;
28
+ const validationConfigs = arkosConfig?.validation;
29
29
  if (validationConfigs?.resolver === "class-validator") {
30
30
  return dtos?.[key];
31
31
  }
@@ -41,28 +41,28 @@ export function setupRouters(router, arkosConfigs) {
41
41
  throw Error(`ValidationError: The exported router from ${modelNameInKebab}.router.${getUserFileExtension()} is not a valid express Router.`);
42
42
  }
43
43
  if (!hasCustomImplementation(`/${routeName}`, "post")) {
44
- router.post(createRouteConfig("createOne", routeName, "", routerConfig, modelNameInKebab, authConfigs, getValidationSchemaOrDto("create")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "createOne"), ...processMiddleware(interceptors?.beforeCreateOne), controller.createOne, ...processMiddleware(interceptors?.afterCreateOne), sendResponse, ...processMiddleware(interceptors?.onCreateOneError, { type: "error" }));
44
+ router.post(createRouteConfig(arkosConfig, "createOne", routeName, "", routerConfig, modelNameInKebab, authConfigs, getValidationSchemaOrDto("create")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "createOne"), ...processMiddleware(interceptors?.beforeCreateOne), controller.createOne, ...processMiddleware(interceptors?.afterCreateOne), sendResponse, ...processMiddleware(interceptors?.onCreateOneError, { type: "error" }));
45
45
  }
46
46
  if (!hasCustomImplementation(`/${routeName}`, "get")) {
47
- router.get(createRouteConfig("findMany", routeName, "", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "findMany"), ...processMiddleware(interceptors?.beforeFindMany), controller.findMany, ...processMiddleware(interceptors?.afterFindMany), sendResponse, ...processMiddleware(interceptors?.onFindManyError, { type: "error" }));
47
+ router.get(createRouteConfig(arkosConfig, "findMany", routeName, "", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "findMany"), ...processMiddleware(interceptors?.beforeFindMany), controller.findMany, ...processMiddleware(interceptors?.afterFindMany), sendResponse, ...processMiddleware(interceptors?.onFindManyError, { type: "error" }));
48
48
  }
49
49
  if (!hasCustomImplementation(`/${routeName}/many`, "post")) {
50
- router.post(createRouteConfig("createMany", routeName, "/many", routerConfig, modelNameInKebab, authConfigs, getValidationSchemaOrDto("createMany")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "createMany"), ...processMiddleware(interceptors?.beforeCreateMany), controller.createMany, ...processMiddleware(interceptors?.afterCreateMany), sendResponse, ...processMiddleware(interceptors?.onCreateManyError, { type: "error" }));
50
+ router.post(createRouteConfig(arkosConfig, "createMany", routeName, "/many", routerConfig, modelNameInKebab, authConfigs, getValidationSchemaOrDto("createMany")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "createMany"), ...processMiddleware(interceptors?.beforeCreateMany), controller.createMany, ...processMiddleware(interceptors?.afterCreateMany), sendResponse, ...processMiddleware(interceptors?.onCreateManyError, { type: "error" }));
51
51
  }
52
52
  if (!hasCustomImplementation(`/${routeName}/many`, "patch")) {
53
- router.patch(createRouteConfig("updateMany", routeName, "/many", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMany"), ...processMiddleware(interceptors?.beforeUpdateMany), controller.updateMany, ...processMiddleware(interceptors?.afterUpdateMany), sendResponse, ...processMiddleware(interceptors?.onUpdateManyError, { type: "error" }));
53
+ router.patch(createRouteConfig(arkosConfig, "updateMany", routeName, "/many", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMany"), ...processMiddleware(interceptors?.beforeUpdateMany), controller.updateMany, ...processMiddleware(interceptors?.afterUpdateMany), sendResponse, ...processMiddleware(interceptors?.onUpdateManyError, { type: "error" }));
54
54
  }
55
55
  if (!hasCustomImplementation(`/${routeName}/many`, "delete")) {
56
- router.delete(createRouteConfig("deleteMany", routeName, "/many", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMany"), ...processMiddleware(interceptors?.beforeDeleteMany), controller.deleteMany, ...processMiddleware(interceptors?.afterDeleteMany), sendResponse, ...processMiddleware(interceptors?.onDeleteManyError, { type: "error" }));
56
+ router.delete(createRouteConfig(arkosConfig, "deleteMany", routeName, "/many", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMany"), ...processMiddleware(interceptors?.beforeDeleteMany), controller.deleteMany, ...processMiddleware(interceptors?.afterDeleteMany), sendResponse, ...processMiddleware(interceptors?.onDeleteManyError, { type: "error" }));
57
57
  }
58
58
  if (!hasCustomImplementation(`/${routeName}/:id`, "get")) {
59
- router.get(createRouteConfig("findOne", routeName, "/:id", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "findOne"), ...processMiddleware(interceptors?.beforeFindOne), controller.findOne, ...processMiddleware(interceptors?.afterFindOne), sendResponse, ...processMiddleware(interceptors?.onFindOneError, { type: "error" }));
59
+ router.get(createRouteConfig(arkosConfig, "findOne", routeName, "/:id", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "findOne"), ...processMiddleware(interceptors?.beforeFindOne), controller.findOne, ...processMiddleware(interceptors?.afterFindOne), sendResponse, ...processMiddleware(interceptors?.onFindOneError, { type: "error" }));
60
60
  }
61
61
  if (!hasCustomImplementation(`/${routeName}/:id`, "patch")) {
62
- router.patch(createRouteConfig("updateOne", routeName, "/:id", routerConfig, modelNameInKebab, authConfigs, getValidationSchemaOrDto("update")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateOne"), ...processMiddleware(interceptors?.beforeUpdateOne), controller.updateOne, ...processMiddleware(interceptors?.afterUpdateOne), sendResponse, ...processMiddleware(interceptors?.onUpdateOneError, { type: "error" }));
62
+ router.patch(createRouteConfig(arkosConfig, "updateOne", routeName, "/:id", routerConfig, modelNameInKebab, authConfigs, getValidationSchemaOrDto("update")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateOne"), ...processMiddleware(interceptors?.beforeUpdateOne), controller.updateOne, ...processMiddleware(interceptors?.afterUpdateOne), sendResponse, ...processMiddleware(interceptors?.onUpdateOneError, { type: "error" }));
63
63
  }
64
64
  if (!hasCustomImplementation(`/${routeName}/:id`, "delete")) {
65
- router.delete(createRouteConfig("deleteOne", routeName, "/:id", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteOne"), ...processMiddleware(interceptors?.beforeDeleteOne), controller.deleteOne, ...processMiddleware(interceptors?.afterDeleteOne), sendResponse, ...processMiddleware(interceptors?.onDeleteOneError, { type: "error" }));
65
+ router.delete(createRouteConfig(arkosConfig, "deleteOne", routeName, "/:id", routerConfig, modelNameInKebab, authConfigs), addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteOne"), ...processMiddleware(interceptors?.beforeDeleteOne), controller.deleteOne, ...processMiddleware(interceptors?.afterDeleteOne), sendResponse, ...processMiddleware(interceptors?.onDeleteOneError, { type: "error" }));
66
66
  }
67
67
  debuggerService.logModuleFinalRouter(modelNameInKebab, router);
68
68
  });
@@ -1 +1 @@
1
- {"version":3,"file":"base.router.helpers.js","sourceRoot":"","sources":["../../../../../../src/modules/base/utils/helpers/base.router.helpers.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAOtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,8BAA8B,EAC9B,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AACnD,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,kBAAkB,MAAM,+CAA+C,CAAC;AAC/E,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAGjE,MAAM,UAAU,YAAY,CAAC,MAAoB,EAAE,YAAyB;IAC1E,OAAO,kBAAkB,CAAC,yBAAyB,EAAE,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,EACjB,QAAgB;IAEhB,IAAI,CAAC,YAAY,EAAE,MAAM;QAAE,OAAO,KAAK,CAAC;IAExC,MAAM,eAAe,GAAG,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;IACtD,IAAI,eAAe,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IACzC,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;QAAE,OAAO,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE9E,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { Router } from \"express\";\nimport pluralize from \"pluralize\";\nimport { ArkosConfig, RouterConfig } from \"../../../../exports\";\nimport { kebabCase } from \"../../../../exports/utils\";\nimport { PrismaQueryOptions } from \"../../../../types\";\nimport {\n AuthRouterEndpoint,\n FileUploadRouterEndpoint,\n RouterEndpoint,\n} from \"../../../../types/router-config\";\nimport { getModuleComponents } from \"../../../../utils/dynamic-loader\";\nimport { BaseController } from \"../../base.controller\";\nimport {\n addPrismaQueryOptionsToRequest,\n sendResponse,\n} from \"../../base.middlewares\";\nimport {\n createRouteConfig,\n processMiddleware,\n} from \"../../../../utils/helpers/routers.helpers\";\nimport routerValidator from \"../router-validator\";\nimport { getUserFileExtension } from \"../../../../utils/helpers/fs.helpers\";\nimport prismaSchemaParser from \"../../../../utils/prisma/prisma-schema-parser\";\nimport debuggerService from \"../../../debugger/debugger.service\";\nimport { IArkosRouter } from \"../../../../utils/arkos-router/types\";\n\nexport function setupRouters(router: IArkosRouter, arkosConfigs: ArkosConfig) {\n return prismaSchemaParser.getModelsAsArrayOfStrings().map(async (model) => {\n const modelNameInKebab = kebabCase(model);\n const modelModules = getModuleComponents(modelNameInKebab) || {};\n\n const {\n interceptors,\n authConfigs,\n prismaQueryOptions,\n router: customRouterModule,\n dtos,\n schemas,\n } = modelModules;\n\n const routeName = pluralize.plural(modelNameInKebab);\n const controller = new BaseController(model);\n\n const routerConfig: RouterConfig<any> = customRouterModule?.config || {};\n\n const customRouter = customRouterModule?.default as Router;\n const hasCustomImplementation = (path: string, method: string) => {\n return customRouter?.stack?.some(\n (layer) =>\n (layer.path === `/api/${path}` ||\n layer.path === `api/${path}` ||\n layer.path === `api/${path}/` ||\n layer.path === `/api/${path}/`) &&\n layer.method.toLowerCase() === method.toLowerCase()\n );\n };\n\n const getValidationSchemaOrDto = (\n key: \"create\" | \"update\" | \"createMany\" | \"updateMany\"\n ) => {\n const validationConfigs = arkosConfigs?.validation;\n if (validationConfigs?.resolver === \"class-validator\") {\n return (dtos as any)?.[key];\n } else if (validationConfigs?.resolver === \"zod\") {\n return (schemas as any)?.[key];\n }\n return undefined;\n };\n\n if (customRouter && customRouterModule) {\n if (routerValidator.isExpressRouter(customRouter))\n router.use(`/${routeName}`, customRouter);\n else\n throw Error(\n `ValidationError: The exported router from ${modelNameInKebab}.router.${getUserFileExtension()} is not a valid express Router.`\n );\n }\n\n // CREATE ONE\n if (!hasCustomImplementation(`/${routeName}`, \"post\")) {\n router.post(\n createRouteConfig(\n \"createOne\",\n routeName,\n \"\",\n routerConfig,\n modelNameInKebab,\n authConfigs,\n getValidationSchemaOrDto(\"create\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"createOne\"\n ),\n ...processMiddleware(interceptors?.beforeCreateOne),\n controller.createOne,\n ...processMiddleware(interceptors?.afterCreateOne),\n sendResponse,\n ...processMiddleware(interceptors?.onCreateOneError, { type: \"error\" })\n );\n }\n\n // FIND MANY\n if (!hasCustomImplementation(`/${routeName}`, \"get\")) {\n router.get(\n createRouteConfig(\n \"findMany\",\n routeName,\n \"\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"findMany\"\n ),\n ...processMiddleware(interceptors?.beforeFindMany),\n controller.findMany,\n ...processMiddleware(interceptors?.afterFindMany),\n sendResponse,\n ...processMiddleware(interceptors?.onFindManyError, { type: \"error\" })\n );\n }\n\n // CREATE MANY\n if (!hasCustomImplementation(`/${routeName}/many`, \"post\")) {\n router.post(\n createRouteConfig(\n \"createMany\",\n routeName,\n \"/many\",\n routerConfig,\n modelNameInKebab,\n authConfigs,\n getValidationSchemaOrDto(\"createMany\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"createMany\"\n ),\n ...processMiddleware(interceptors?.beforeCreateMany),\n controller.createMany,\n ...processMiddleware(interceptors?.afterCreateMany),\n sendResponse,\n ...processMiddleware(interceptors?.onCreateManyError, { type: \"error\" })\n );\n }\n\n // UPDATE MANY\n if (!hasCustomImplementation(`/${routeName}/many`, \"patch\")) {\n router.patch(\n createRouteConfig(\n \"updateMany\",\n routeName,\n \"/many\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"updateMany\"\n ),\n ...processMiddleware(interceptors?.beforeUpdateMany),\n controller.updateMany,\n ...processMiddleware(interceptors?.afterUpdateMany),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdateManyError, { type: \"error\" })\n );\n }\n\n // DELETE MANY\n if (!hasCustomImplementation(`/${routeName}/many`, \"delete\")) {\n router.delete(\n createRouteConfig(\n \"deleteMany\",\n routeName,\n \"/many\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"deleteMany\"\n ),\n ...processMiddleware(interceptors?.beforeDeleteMany),\n controller.deleteMany,\n ...processMiddleware(interceptors?.afterDeleteMany),\n sendResponse,\n ...processMiddleware(interceptors?.onDeleteManyError, { type: \"error\" })\n );\n }\n\n // FIND ONE\n if (!hasCustomImplementation(`/${routeName}/:id`, \"get\")) {\n router.get(\n createRouteConfig(\n \"findOne\",\n routeName,\n \"/:id\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"findOne\"\n ),\n ...processMiddleware(interceptors?.beforeFindOne),\n controller.findOne,\n ...processMiddleware(interceptors?.afterFindOne),\n sendResponse,\n ...processMiddleware(interceptors?.onFindOneError, { type: \"error\" })\n );\n }\n\n // UPDATE ONE\n if (!hasCustomImplementation(`/${routeName}/:id`, \"patch\")) {\n router.patch(\n createRouteConfig(\n \"updateOne\",\n routeName,\n \"/:id\",\n routerConfig,\n modelNameInKebab,\n authConfigs,\n getValidationSchemaOrDto(\"update\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"updateOne\"\n ),\n ...processMiddleware(interceptors?.beforeUpdateOne),\n controller.updateOne,\n ...processMiddleware(interceptors?.afterUpdateOne),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdateOneError, { type: \"error\" })\n );\n }\n\n // DELETE ONE\n if (!hasCustomImplementation(`/${routeName}/:id`, \"delete\")) {\n router.delete(\n createRouteConfig(\n \"deleteOne\",\n routeName,\n \"/:id\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"deleteOne\"\n ),\n ...processMiddleware(interceptors?.beforeDeleteOne),\n controller.deleteOne,\n ...processMiddleware(interceptors?.afterDeleteOne),\n sendResponse,\n ...processMiddleware(interceptors?.onDeleteOneError, { type: \"error\" })\n );\n }\n\n debuggerService.logModuleFinalRouter(modelNameInKebab, router as any);\n });\n}\n\nexport function isEndpointDisabled(\n routerConfig: RouterConfig<any>,\n endpoint: RouterEndpoint | AuthRouterEndpoint | FileUploadRouterEndpoint\n): boolean {\n if (!routerConfig?.disable) return false;\n\n if (routerConfig.disable === true) return true;\n\n if (typeof routerConfig.disable === \"object\")\n return routerConfig.disable[endpoint as never] === true;\n\n return false;\n}\n\nexport function isParentEndpointAllowed(\n routerConfig: any,\n endpoint: string\n): boolean {\n if (!routerConfig?.parent) return false;\n\n const parentEndpoints = routerConfig.parent.endpoints;\n if (parentEndpoints === \"*\") return true;\n if (Array.isArray(parentEndpoints)) return parentEndpoints.includes(endpoint);\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"base.router.helpers.js","sourceRoot":"","sources":["../../../../../../src/modules/base/utils/helpers/base.router.helpers.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAOtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,8BAA8B,EAC9B,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AACnD,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,kBAAkB,MAAM,+CAA+C,CAAC;AAC/E,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAGjE,MAAM,UAAU,YAAY,CAAC,MAAoB,EAAE,WAAwB;IACzE,OAAO,kBAAkB,CAAC,yBAAyB,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACxE,MAAM,gBAAgB,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,YAAY,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAEjE,MAAM,EACJ,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EACJ,OAAO,GACR,GAAG,YAAY,CAAC;QAEjB,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG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IAAI,CAAC;AACd,CAAC","sourcesContent":["import { Router } from \"express\";\nimport pluralize from \"pluralize\";\nimport { ArkosConfig, RouterConfig } from \"../../../../exports\";\nimport { kebabCase } from \"../../../../exports/utils\";\nimport { PrismaQueryOptions } from \"../../../../types\";\nimport {\n AuthRouterEndpoint,\n FileUploadRouterEndpoint,\n RouterEndpoint,\n} from \"../../../../types/router-config\";\nimport { getModuleComponents } from \"../../../../utils/dynamic-loader\";\nimport { BaseController } from \"../../base.controller\";\nimport {\n addPrismaQueryOptionsToRequest,\n sendResponse,\n} from \"../../base.middlewares\";\nimport {\n createRouteConfig,\n processMiddleware,\n} from \"../../../../utils/helpers/routers.helpers\";\nimport routerValidator from \"../router-validator\";\nimport { getUserFileExtension } from \"../../../../utils/helpers/fs.helpers\";\nimport prismaSchemaParser from \"../../../../utils/prisma/prisma-schema-parser\";\nimport debuggerService from \"../../../debugger/debugger.service\";\nimport { IArkosRouter } from \"../../../../utils/arkos-router/types\";\n\nexport function setupRouters(router: IArkosRouter, arkosConfig: ArkosConfig) {\n return prismaSchemaParser.getModelsAsArrayOfStrings().map(async (model) => {\n const modelNameInKebab = kebabCase(model);\n const modelModules = getModuleComponents(modelNameInKebab) || {};\n\n const {\n interceptors,\n authConfigs,\n prismaQueryOptions,\n router: customRouterModule,\n dtos,\n schemas,\n } = modelModules;\n\n const routeName = pluralize.plural(modelNameInKebab);\n const controller = new BaseController(model);\n\n const routerConfig: RouterConfig<any> = customRouterModule?.config || {};\n\n const customRouter = customRouterModule?.default as Router;\n const hasCustomImplementation = (path: string, method: string) => {\n return customRouter?.stack?.some(\n (layer) =>\n (layer.path === `/api/${path}` ||\n layer.path === `api/${path}` ||\n layer.path === `api/${path}/` ||\n layer.path === `/api/${path}/`) &&\n layer.method.toLowerCase() === method.toLowerCase()\n );\n };\n\n const getValidationSchemaOrDto = (\n key: \"create\" | \"update\" | \"createMany\" | \"updateMany\"\n ) => {\n const validationConfigs = arkosConfig?.validation;\n if (validationConfigs?.resolver === \"class-validator\") {\n return (dtos as any)?.[key];\n } else if (validationConfigs?.resolver === \"zod\") {\n return (schemas as any)?.[key];\n }\n return undefined;\n };\n\n if (customRouter && customRouterModule) {\n if (routerValidator.isExpressRouter(customRouter))\n router.use(`/${routeName}`, customRouter);\n else\n throw Error(\n `ValidationError: The exported router from ${modelNameInKebab}.router.${getUserFileExtension()} is not a valid express Router.`\n );\n }\n\n // CREATE ONE\n if (!hasCustomImplementation(`/${routeName}`, \"post\")) {\n router.post(\n createRouteConfig(\n arkosConfig,\n \"createOne\",\n routeName,\n \"\",\n routerConfig,\n modelNameInKebab,\n authConfigs,\n getValidationSchemaOrDto(\"create\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"createOne\"\n ),\n ...processMiddleware(interceptors?.beforeCreateOne),\n controller.createOne,\n ...processMiddleware(interceptors?.afterCreateOne),\n sendResponse,\n ...processMiddleware(interceptors?.onCreateOneError, { type: \"error\" })\n );\n }\n\n // FIND MANY\n if (!hasCustomImplementation(`/${routeName}`, \"get\")) {\n router.get(\n createRouteConfig(\n arkosConfig,\n \"findMany\",\n routeName,\n \"\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"findMany\"\n ),\n ...processMiddleware(interceptors?.beforeFindMany),\n controller.findMany,\n ...processMiddleware(interceptors?.afterFindMany),\n sendResponse,\n ...processMiddleware(interceptors?.onFindManyError, { type: \"error\" })\n );\n }\n\n // CREATE MANY\n if (!hasCustomImplementation(`/${routeName}/many`, \"post\")) {\n router.post(\n createRouteConfig(\n arkosConfig,\n \"createMany\",\n routeName,\n \"/many\",\n routerConfig,\n modelNameInKebab,\n authConfigs,\n getValidationSchemaOrDto(\"createMany\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"createMany\"\n ),\n ...processMiddleware(interceptors?.beforeCreateMany),\n controller.createMany,\n ...processMiddleware(interceptors?.afterCreateMany),\n sendResponse,\n ...processMiddleware(interceptors?.onCreateManyError, { type: \"error\" })\n );\n }\n\n // UPDATE MANY\n if (!hasCustomImplementation(`/${routeName}/many`, \"patch\")) {\n router.patch(\n createRouteConfig(\n arkosConfig,\n \"updateMany\",\n routeName,\n \"/many\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"updateMany\"\n ),\n ...processMiddleware(interceptors?.beforeUpdateMany),\n controller.updateMany,\n ...processMiddleware(interceptors?.afterUpdateMany),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdateManyError, { type: \"error\" })\n );\n }\n\n // DELETE MANY\n if (!hasCustomImplementation(`/${routeName}/many`, \"delete\")) {\n router.delete(\n createRouteConfig(\n arkosConfig,\n \"deleteMany\",\n routeName,\n \"/many\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"deleteMany\"\n ),\n ...processMiddleware(interceptors?.beforeDeleteMany),\n controller.deleteMany,\n ...processMiddleware(interceptors?.afterDeleteMany),\n sendResponse,\n ...processMiddleware(interceptors?.onDeleteManyError, { type: \"error\" })\n );\n }\n\n // FIND ONE\n if (!hasCustomImplementation(`/${routeName}/:id`, \"get\")) {\n router.get(\n createRouteConfig(\n arkosConfig,\n \"findOne\",\n routeName,\n \"/:id\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"findOne\"\n ),\n ...processMiddleware(interceptors?.beforeFindOne),\n controller.findOne,\n ...processMiddleware(interceptors?.afterFindOne),\n sendResponse,\n ...processMiddleware(interceptors?.onFindOneError, { type: \"error\" })\n );\n }\n\n // UPDATE ONE\n if (!hasCustomImplementation(`/${routeName}/:id`, \"patch\")) {\n router.patch(\n createRouteConfig(\n arkosConfig,\n \"updateOne\",\n routeName,\n \"/:id\",\n routerConfig,\n modelNameInKebab,\n authConfigs,\n getValidationSchemaOrDto(\"update\")\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"updateOne\"\n ),\n ...processMiddleware(interceptors?.beforeUpdateOne),\n controller.updateOne,\n ...processMiddleware(interceptors?.afterUpdateOne),\n sendResponse,\n ...processMiddleware(interceptors?.onUpdateOneError, { type: \"error\" })\n );\n }\n\n // DELETE ONE\n if (!hasCustomImplementation(`/${routeName}/:id`, \"delete\")) {\n router.delete(\n createRouteConfig(\n arkosConfig,\n \"deleteOne\",\n routeName,\n \"/:id\",\n routerConfig,\n modelNameInKebab,\n authConfigs\n ),\n addPrismaQueryOptionsToRequest<any>(\n prismaQueryOptions as PrismaQueryOptions<any>,\n \"deleteOne\"\n ),\n ...processMiddleware(interceptors?.beforeDeleteOne),\n controller.deleteOne,\n ...processMiddleware(interceptors?.afterDeleteOne),\n sendResponse,\n ...processMiddleware(interceptors?.onDeleteOneError, { type: \"error\" })\n );\n }\n\n debuggerService.logModuleFinalRouter(modelNameInKebab, router as any);\n });\n}\n\nexport function isEndpointDisabled(\n routerConfig: RouterConfig<any>,\n endpoint: RouterEndpoint | AuthRouterEndpoint | FileUploadRouterEndpoint\n): boolean {\n if (!routerConfig?.disable) return false;\n\n if (routerConfig.disable === true) return true;\n\n if (typeof routerConfig.disable === \"object\")\n return routerConfig.disable[endpoint as never] === true;\n\n return false;\n}\n\nexport function isParentEndpointAllowed(\n routerConfig: any,\n endpoint: string\n): boolean {\n if (!routerConfig?.parent) return false;\n\n const parentEndpoints = routerConfig.parent.endpoints;\n if (parentEndpoints === \"*\") return true;\n if (Array.isArray(parentEndpoints)) return parentEndpoints.includes(endpoint);\n\n return true;\n}\n"]}