arkos 1.2.12-beta → 1.2.13-beta

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 (87) hide show
  1. package/dist/cjs/modules/auth/auth.router.js +9 -83
  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 -94
  4. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  5. package/dist/cjs/modules/error-handler/error-handler.controller.js +2 -0
  6. package/dist/cjs/modules/error-handler/error-handler.controller.js.map +1 -1
  7. package/dist/cjs/modules/error-handler/utils/catch-async.js.map +1 -1
  8. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +6 -0
  9. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  10. package/dist/cjs/modules/file-upload/file-upload.router.js +9 -21
  11. package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
  12. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +7 -0
  13. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
  14. package/dist/cjs/modules/swagger/swagger.router.js +4 -3
  15. package/dist/cjs/modules/swagger/swagger.router.js.map +1 -1
  16. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +3 -2
  17. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  18. package/dist/cjs/server.js +4 -2
  19. package/dist/cjs/server.js.map +1 -1
  20. package/dist/cjs/utils/cli/dev.js +18 -16
  21. package/dist/cjs/utils/cli/dev.js.map +1 -1
  22. package/dist/cjs/utils/cli/generate.js +1 -1
  23. package/dist/cjs/utils/cli/generate.js.map +1 -1
  24. package/dist/cjs/utils/cli/start.js +1 -1
  25. package/dist/cjs/utils/cli/start.js.map +1 -1
  26. package/dist/cjs/utils/cli/utils/cli.helpers.js +1 -1
  27. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js +1 -1
  28. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -1
  29. package/dist/cjs/utils/features/api.features.js +9 -3
  30. package/dist/cjs/utils/features/api.features.js.map +1 -1
  31. package/dist/cjs/utils/helpers/global.helpers.js +4 -22
  32. package/dist/cjs/utils/helpers/global.helpers.js.map +1 -1
  33. package/dist/cjs/utils/helpers/models.helpers.js +25 -9
  34. package/dist/cjs/utils/helpers/models.helpers.js.map +1 -1
  35. package/dist/cjs/utils/helpers/routers.helpers.js +21 -0
  36. package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -0
  37. package/dist/cjs/utils/sheu.js +101 -125
  38. package/dist/cjs/utils/sheu.js.map +1 -1
  39. package/dist/esm/modules/auth/auth.router.js +9 -83
  40. package/dist/esm/modules/auth/auth.router.js.map +1 -1
  41. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +10 -94
  42. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +1 -1
  43. package/dist/esm/modules/error-handler/error-handler.controller.js +2 -0
  44. package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
  45. package/dist/esm/modules/error-handler/utils/catch-async.js.map +1 -1
  46. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +5 -0
  47. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
  48. package/dist/esm/modules/file-upload/file-upload.router.js +9 -21
  49. package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
  50. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +6 -0
  51. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
  52. package/dist/esm/modules/swagger/swagger.router.js +4 -3
  53. package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
  54. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +3 -2
  55. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +1 -1
  56. package/dist/esm/server.js +4 -2
  57. package/dist/esm/server.js.map +1 -1
  58. package/dist/esm/utils/cli/dev.js +18 -16
  59. package/dist/esm/utils/cli/dev.js.map +1 -1
  60. package/dist/esm/utils/cli/generate.js +1 -1
  61. package/dist/esm/utils/cli/generate.js.map +1 -1
  62. package/dist/esm/utils/cli/start.js +1 -1
  63. package/dist/esm/utils/cli/start.js.map +1 -1
  64. package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
  65. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +1 -1
  66. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js.map +1 -1
  67. package/dist/esm/utils/features/api.features.js +9 -3
  68. package/dist/esm/utils/features/api.features.js.map +1 -1
  69. package/dist/esm/utils/helpers/global.helpers.js +4 -22
  70. package/dist/esm/utils/helpers/global.helpers.js.map +1 -1
  71. package/dist/esm/utils/helpers/models.helpers.js +24 -9
  72. package/dist/esm/utils/helpers/models.helpers.js.map +1 -1
  73. package/dist/esm/utils/helpers/routers.helpers.js +16 -0
  74. package/dist/esm/utils/helpers/routers.helpers.js.map +1 -0
  75. package/dist/esm/utils/sheu.js +101 -125
  76. package/dist/esm/utils/sheu.js.map +1 -1
  77. package/dist/types/modules/error-handler/utils/catch-async.d.ts +1 -0
  78. package/dist/types/modules/error-handler/utils/error-handler.helpers.d.ts +4 -0
  79. package/dist/types/modules/file-upload/file-upload.router.d.ts +1 -1
  80. package/dist/types/modules/file-upload/utils/helpers/file-upload.helpers.d.ts +2 -1
  81. package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +1 -1
  82. package/dist/types/server.d.ts +3 -0
  83. package/dist/types/utils/features/api.features.d.ts +1 -0
  84. package/dist/types/utils/helpers/models.helpers.d.ts +7 -4
  85. package/dist/types/utils/helpers/routers.helpers.d.ts +2 -0
  86. package/dist/types/utils/sheu.d.ts +66 -21
  87. package/package.json +2 -3
@@ -1 +1 @@
1
- {"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/models.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ACtB,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,SAAS;qBAChB,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;wBAClB,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,SAAS;qBAChB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,iCAAyB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC;AAUD,SAAgB,uBAAuB,CACrC,SAAiB;IAEjB,SAAS,GAAG,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC;IAElC,IAAI,CAAC,CAAC,SAAS,IAAI,iCAAyB,CAAC;QAAE,OAAO;IACtD,OAAO,iCAAyB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC;AAOD,SAAS,SAAS;IAChB,OAAO,cAAM,CAAC;AAChB,CAAC;AAOD,SAAgB,uBAAuB;IACrC,OAAO,4BAAoB,CAAC;AAC9B,CAAC;AAMD,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,gCAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\nimport { AuthConfigs } from \"../../types/auth\";\nimport { killServerChildProcess } from \"../cli/utils/cli.helpers\";\n\n// Must be exported to not cause problems on cjs\nlet prismaModelsModules: Record<\n string,\n Awaited<ReturnType<typeof importPrismaModelModules>>\n> = {};\n\nexport function getModelModules(modelName: string) {\n return prismaModelsModules[kebabCase(modelName)];\n}\n\nexport function getFileModelModulesFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n service: `${kebabModelName}.service.${ext}`,\n controller: `${kebabModelName}.controller.${ext}`,\n middlewares: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createMany: `create-many-${kebabModelName}.dto.${ext}`,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateMany: `update-many-${kebabModelName}.dto.${ext}`,\n findOne: `find-one-${kebabModelName}.dto.${ext}`,\n findMany: `find-many-${kebabModelName}.dto.${ext}`,\n query: `query-${kebabModelName}.dto.${ext}`,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createMany: `create-many-${kebabModelName}.schema.${ext}`,\n update: `update-${kebabModelName}.schema.${ext}`,\n updateMany: `update-many-${kebabModelName}.schema.${ext}`,\n findOne: `find-one-${kebabModelName}.schema.${ext}`,\n findMany: `find-many-${kebabModelName}.schema.${ext}`,\n query: `query-${kebabModelName}.schema.${ext}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\",\n result: Record<string, any>\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Skip if directory doesn't exist\n try {\n await fs.promises.access(subdir).catch(() => {\n return; // Directory doesn't exist\n });\n\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n try {\n const module = await importModule(filePath).catch(() => null);\n if (module) result[type][key] = module.default;\n } catch (error) {\n // Silent fail - file might not exist\n console.error(error);\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\n console.error(error);\n }\n}\n\ntype importPrismaModelModulesReturnType = {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: any;\n prismaQueryOptionsNew?: any;\n router?: any;\n dtos: Record<string, any>;\n schemas: Record<string, any>;\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {importPrismaModelModulesReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {importPrismaModelModulesReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n key: string,\n module: any,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"middlewares\" || key === \"router\") {\n result[key] = module;\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importPrismaModelModules(\n modelName: string\n): Promise<importPrismaModelModulesReturnType> {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const result: importPrismaModelModulesReturnType = {\n dtos: {},\n schemas: {},\n };\n\n if (getModelModules(modelName)) return getModelModules(modelName);\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Batch process core files\n await Promise.all(\n Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n const filePath = path.join(moduleDir, fileName);\n try {\n const module = await importModule(filePath).catch((err) => {\n if (!err.message.includes(\"Cannot find module\")) {\n console.error(`Failed to import ${fileName}: \\n`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n });\n\n if (module) {\n // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to result\n assignModuleToResult(key, module, result);\n }\n } catch (err: any) {\n if (err.message.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n })\n );\n\n await Promise.all([\n processSubdir(modelName, \"dtos\", result),\n processSubdir(modelName, \"schemas\", result),\n ]);\n\n // Removed because caused problems with cached ZObjects\n // Cache the result making shallow copy to not cause problems after build\n // prismaModelsModules[modelName] = JSON.parse(JSON.stringify(result));\n prismaModelsModules[modelName] = result;\n\n return result;\n}\n\nexport type ModelFieldDefition = {\n name: string;\n type: string;\n isUnique: boolean;\n};\n\n/**\n * Represents the structure of relation fields for Prisma models.\n * It includes both singular (one-to-one) and list (one-to-many) relationships.\n *\n * @typedef {Object} RelationFields\n * @property {Array<{name: string, type: string}>} singular - List of singular relationships.\n * @property {Array<{name: string, type: string}>} list - List of list relationships.\n */\nexport type RelationFields = {\n singular: Omit<ModelFieldDefition, \"isUnique\">[];\n list: Omit<ModelFieldDefition, \"isUnique\">[];\n};\n\n/**\n * Reads the Prisma schema files and extracts all model definitions,\n * identifying their relations (one-to-one and one-to-many).\n */\nexport const prismaModelRelationFields: Record<string, RelationFields> = {};\n\nexport function getAllPrismaFiles(dirPath: string, fileList: string[] = []) {\n const files = fs.readdirSync(dirPath);\n\n files?.forEach((file) => {\n const filePath = path.join(dirPath, file);\n const stat = fs.statSync(filePath);\n\n // Skip migrations folder\n if (stat.isDirectory() && file !== \"migrations\") {\n fileList = getAllPrismaFiles(filePath, fileList);\n } else if (stat.isFile() && file.endsWith(\".prisma\")) {\n fileList.push(filePath);\n }\n });\n\n return fileList;\n}\n\nconst modelRegex = /model\\s+(\\w+)\\s*{/g;\nexport const models: string[] = [];\nexport let prismaSchemasContent: string;\nexport const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels() {\n const prismaContent: string[] = [];\n\n const files = getAllPrismaFiles(\"./prisma\");\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\");\n\n if (!prismaContent?.includes?.(content)) prismaContent.push(content);\n }\n\n // Gather the content of all *.prisma files into single one\n const content = prismaContent\n .join(\"\\n\")\n .replace(modelRegex, (_, modelName) => {\n if (!models?.includes?.(modelName))\n models.push(camelCase(modelName.trim()));\n return `model ${modelName} {`;\n });\n\n const copiedContent = content;\n prismaSchemasContent = content;\n\n for (const model of models) {\n const modelName = pascalCase(model);\n\n const modelStart = copiedContent.indexOf(`model ${modelName} {`);\n const modelEnd = copiedContent.indexOf(\"}\", modelStart);\n const modelDefinition = copiedContent.slice(modelStart, modelEnd);\n\n const relations: RelationFields = {\n singular: [],\n list: [],\n };\n const lines = modelDefinition.split(\"\\n\");\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n if (\n !trimmedLine ||\n trimmedLine.startsWith(\"model\") ||\n trimmedLine.startsWith(\"//\") ||\n trimmedLine.startsWith(\"/*\")\n )\n continue;\n\n const [fieldName, type] = trimmedLine.split(/\\s+/);\n const isUnique = trimmedLine?.includes?.(\"@unique\");\n\n if (isUnique) {\n const existingFields = prismaModelsUniqueFields[model] || [];\n\n const alreadyExists = existingFields.some(\n (field) =>\n field.name === fieldName &&\n field.type === type &&\n field.isUnique === isUnique\n );\n\n if (!alreadyExists) {\n prismaModelsUniqueFields[model] = [\n ...existingFields,\n { name: fieldName, type, isUnique },\n ];\n }\n }\n\n const cleanType = type?.replace(\"[]\", \"\").replace(\"?\", \"\");\n\n if (\n trimmedLine?.includes?.(\"@relation\") ||\n trimmedLine.match(/\\s+\\w+(\\[\\])?(\\s+@|$)/) ||\n models?.includes?.(camelCase(cleanType || \"\"))\n ) {\n const enumStart = copiedContent.indexOf(`enum ${cleanType} {`);\n const typeStart = copiedContent.indexOf(`type ${cleanType} {`);\n\n if (\n !cleanType ||\n enumStart >= 0 ||\n typeStart >= 0 ||\n cleanType === \"String\" ||\n cleanType === \"Int\" ||\n cleanType === \"Float\" ||\n cleanType === \"Boolean\" ||\n cleanType === \"DateTime\" ||\n cleanType === \"Bytes\" ||\n cleanType === \"Decimal\" ||\n cleanType === \"BigInt\" ||\n cleanType === \"Json\"\n ) {\n continue;\n }\n\n if (!type?.includes?.(\"[]\")) {\n relations.singular.push({\n name: fieldName,\n type: cleanType,\n });\n } else {\n relations.list.push({\n name: fieldName,\n type: cleanType,\n });\n }\n }\n\n prismaModelRelationFields[modelName] = relations;\n }\n }\n}\n\n// initializePrismaModels();\n\n/**\n * Retrieves the relations for a given Prisma model.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\").\n * @returns {RelationFields|undefined} The relation fields for the model, or `undefined` if no relations are found.\n */\nexport function getPrismaModelRelations(\n modelName: string\n): RelationFields | undefined {\n modelName = pascalCase(modelName);\n\n if (!(modelName in prismaModelRelationFields)) return;\n return prismaModelRelationFields[modelName];\n}\n\n/**\n * Retrieves all the model names from the Prisma schema.\n *\n * @returns {string[]} An array of model names (e.g., [\"User\", \"Post\"]).\n */\nfunction getModels(): string[] {\n return models;\n}\n\n/**\n * Returns all content of all .prisma files gathered together\n *\n * @returns {string}\n */\nexport function getPrismaSchemasContent(): string {\n return prismaSchemasContent;\n}\n\n/** Retuns a given model unique fields\n * @param {string} modelName - The name of model in PascalCase\n * @returns {string[]} An array of all unique fields,\n */\nfunction getModelUniqueFields(modelName: string): ModelFieldDefition[] {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
1
+ {"version":3,"file":"models.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/models.helpers.ts"],"names":[],"mappings":";;;;;;AAkBA,0CAEC;AAED,0CAEC;AAED,4EAmDC;AAED,sCAkCC;AAsBD,8DA8CC;AAQD,oDAcC;AASD,4DAiEC;AA2BD,8CAgBC;AAQD,wDA+GC;AAQD,0DAOC;AAgBD,0DAEC;AAUQ,8BAAS;AAAE,oDAAoB;AAlexC,gDAAwB;AACxB,4CAAoB;AACpB,iFAIiD;AACjD,6CAAyD;AACzD,qDAAgD;AAEhD,0DAAkE;AAMlE,IAAI,mBAAmB,GAAgC,EAAE,CAAC;AAE1D,SAAgB,eAAe,CAAC,SAAiB,EAAE,OAAoB;IACrE,mBAAmB,CAAC,IAAA,+BAAS,EAAC,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC;AACtD,CA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C,IAAI,CAAC,EAAE,CAAC;oBAC5B,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC;wBACtB,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,SAAS;qBAChB,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;wBAClB,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,SAAS;qBAChB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,iCAAyB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC;AAQD,SAAgB,uBAAuB,CACrC,SAAiB;IAEjB,SAAS,GAAG,IAAA,gCAAU,EAAC,SAAS,CAAC,CAAC;IAElC,IAAI,CAAC,CAAC,SAAS,IAAI,iCAAyB,CAAC;QAAE,OAAO;IACtD,OAAO,iCAAyB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC;AAOD,SAAS,SAAS;IAChB,OAAO,cAAM,CAAC;AAChB,CAAC;AAOD,SAAgB,uBAAuB;IACrC,OAAO,4BAAoB,CAAC;AAC9B,CAAC;AAMD,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,gCAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { crd, getUserFileExtension } from \"./fs.helpers\";\nimport { importModule } from \"./global.helpers\";\nimport { AuthConfigs } from \"../../types/auth\";\nimport { killServerChildProcess } from \"../cli/utils/cli.helpers\";\nimport { ArkosConfig } from \"../../exports\";\n\ntype ModeModules = Awaited<ReturnType<typeof importPrismaModelModules>>;\n\n// Must be exported to not cause problems on cjs\nlet prismaModelsModules: Record<string, ModeModules> = {};\n\nexport function setModelModules(modelName: string, modules: ModeModules) {\n prismaModelsModules[kebabCase(modelName)] = modules;\n}\n\nexport function getModelModules(modelName: string) {\n return prismaModelsModules[kebabCase(modelName)];\n}\n\nexport function getFileModelModulesFileStructure(modelName: string) {\n const kebabModelName = kebabCase(modelName).toLowerCase();\n const isAuthModule = modelName.toLowerCase() === \"auth\";\n const ext = getUserFileExtension();\n\n return {\n core: {\n service: `${kebabModelName}.service.${ext}`,\n controller: `${kebabModelName}.controller.${ext}`,\n middlewares: `${kebabModelName}.middlewares.${ext}`,\n authConfigs: `${kebabModelName}.auth-configs.${ext}`,\n authConfigsNew: `${kebabModelName}.auth.${ext}`,\n prismaQueryOptions: `${kebabModelName}.prisma-query-options.${ext}`,\n prismaQueryOptionsNew: `${kebabModelName}.query.${ext}`,\n router: `${kebabModelName}.router.${ext}`,\n },\n dtos: isAuthModule\n ? {\n login: `login.dto.${ext}`,\n signup: `signup.dto.${ext}`,\n updateMe: `update-me.dto.${ext}`,\n updatePassword: `update-password.dto.${ext}`,\n }\n : {\n model: `${kebabModelName}.dto.${ext}`,\n create: `create-${kebabModelName}.dto.${ext}`,\n createMany: `create-many-${kebabModelName}.dto.${ext}`,\n update: `update-${kebabModelName}.dto.${ext}`,\n updateMany: `update-many-${kebabModelName}.dto.${ext}`,\n findOne: `find-one-${kebabModelName}.dto.${ext}`,\n findMany: `find-many-${kebabModelName}.dto.${ext}`,\n query: `query-${kebabModelName}.dto.${ext}`,\n },\n schemas: isAuthModule\n ? {\n login: `login.schema.${ext}`,\n signup: `signup.schema.${ext}`,\n updateMe: `update-me.schema.${ext}`,\n updatePassword: `update-password.schema.${ext}`,\n }\n : {\n model: `${kebabModelName}.schema.${ext}`,\n create: `create-${kebabModelName}.schema.${ext}`,\n createMany: `create-many-${kebabModelName}.schema.${ext}`,\n update: `update-${kebabModelName}.schema.${ext}`,\n updateMany: `update-many-${kebabModelName}.schema.${ext}`,\n findOne: `find-one-${kebabModelName}.schema.${ext}`,\n findMany: `find-many-${kebabModelName}.schema.${ext}`,\n query: `query-${kebabModelName}.schema.${ext}`,\n },\n };\n}\n\nexport async function processSubdir(\n modelName: string,\n type: \"dtos\" | \"schemas\"\n) {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const subdir = path.join(moduleDir, type);\n const fileStructure = getFileModelModulesFileStructure(modelName);\n const result: Record<string, any> = {};\n\n // Skip if directory doesn't exist\n try {\n await fs.promises.access(subdir).catch(() => {\n return; // Directory doesn't exist\n });\n\n await Promise.all(\n Object.entries(fileStructure[type]).map(async ([key, fileName]) => {\n const filePath = path.join(subdir, fileName);\n try {\n const module = await importModule(filePath).catch(() => null);\n if (module) result[key] = module.default;\n } catch (error) {\n // Silent fail - file might not exist\n console.error(error);\n }\n })\n );\n } catch (error) {\n // Directory doesn't exist, continue silently\n console.error(error);\n }\n\n return result;\n}\n\ntype importPrismaModelModulesReturnType = {\n service?: any;\n controller?: any;\n middlewares?: any;\n authConfigs?: AuthConfigs;\n authConfigsNew?: AuthConfigs;\n prismaQueryOptions?: any;\n prismaQueryOptionsNew?: any;\n router?: any;\n dtos?: Record<string, any>;\n schemas?: Record<string, any>;\n};\n\n/**\n * Validates naming convention conflicts for prismaQueryOptions and authConfigs\n * @param {string} key - The current file key being processed\n * @param {string} fileName - The filename being imported\n * @param {importPrismaModelModulesReturnType} result - The current result object\n * @throws {Error} When conflicting naming conventions are detected\n */\nexport function validateNamingConventions(\n key: string,\n fileName: string,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"prisma-query-options\",\n \"query\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"prismaQueryOptionsNew\") {\n if (result.prismaQueryOptions) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"query\",\n \"prisma-query-options\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigs\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth-configs\",\n \"auth\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n } else if (key === \"authConfigsNew\") {\n if (result.authConfigs) {\n killServerChildProcess();\n throw new Error(\n `\\n Cannot use both ${fileName} and ${fileName.replace(\n \"auth\",\n \"auth-configs\"\n )} at once, please choose only one name convention. \\n`\n );\n }\n }\n}\n\n/**\n * Processes and assigns module to the result object based on the key\n * @param {string} key - The file key being processed\n * @param {any} module - The imported module\n * @param {importPrismaModelModulesReturnType} result - The result object to modify\n */\nexport function assignModuleToResult(\n key: string,\n module: any,\n result: importPrismaModelModulesReturnType\n): void {\n if (key === \"prismaQueryOptions\" || key === \"prismaQueryOptionsNew\") {\n result.prismaQueryOptions = module.default || module;\n } else if (key === \"authConfigs\" || key === \"authConfigsNew\") {\n result.authConfigs = module.default || module;\n } else if (key === \"middlewares\" || key === \"router\") {\n result[key] = module;\n } else {\n result[key as keyof typeof result] = module.default || module;\n }\n}\n\n/**\n * Dynamically imports model-specific modules for a given model with optimized file handling.\n * Includes special handling for the Auth module.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\", \"Post\", \"Auth\").\n * @returns {Promise<Object>} An object containing the imported modules\n */\nexport async function importPrismaModelModules(\n modelName: string,\n arkosConfig: ArkosConfig\n): Promise<importPrismaModelModulesReturnType> {\n const moduleDir = path.resolve(crd(), \"src\", \"modules\", kebabCase(modelName));\n\n const result: importPrismaModelModulesReturnType = {\n dtos: {},\n schemas: {},\n };\n\n if (getModelModules(modelName)) return getModelModules(modelName);\n\n const fileStructure = getFileModelModulesFileStructure(modelName);\n\n // Batch process core files\n await Promise.all(\n Object.entries(fileStructure.core).map(async ([key, fileName]) => {\n const filePath = path.join(moduleDir, fileName);\n try {\n const module = await importModule(filePath).catch((err) => {\n if (!err.message.includes(\"Cannot find module\")) {\n console.error(`Failed to import ${fileName}: \\n`);\n console.error(err);\n killServerChildProcess();\n process.exit(1);\n }\n });\n\n if (module) {\n // Validate naming conventions before assignment\n validateNamingConventions(key, fileName, result);\n\n // Assign module to result\n assignModuleToResult(key, module, result);\n }\n } catch (err: any) {\n if (err.message.includes(\"Cannot use both\")) throw err;\n console.error(err);\n killServerChildProcess();\n }\n })\n );\n\n const validationSubdir = arkosConfig.validation?.resolver\n ? arkosConfig.validation.resolver === \"zod\"\n ? \"schemas\"\n : \"dtos\"\n : null;\n\n let validators = {};\n if (validationSubdir)\n validators = await processSubdir(modelName, validationSubdir);\n\n // Removed because caused problems with cached ZObjects\n // Cache the result making shallow copy to not cause problems after build\n prismaModelsModules[modelName] = {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n\n return {\n ...result,\n ...(validationSubdir && { [validationSubdir]: validators }),\n };\n}\n\nexport type ModelFieldDefition = {\n name: string;\n type: string;\n isUnique: boolean;\n};\n\n/**\n * Represents the structure of relation fields for Prisma models.\n * It includes both singular (one-to-one) and list (one-to-many) relationships.\n *\n * @typedef {Object} RelationFields\n * @property {Array<{name: string, type: string}>} singular - List of singular relationships.\n * @property {Array<{name: string, type: string}>} list - List of list relationships.\n */\nexport type RelationFields = {\n singular: Omit<ModelFieldDefition, \"isUnique\">[];\n list: Omit<ModelFieldDefition, \"isUnique\">[];\n};\n\n/**\n * Reads the Prisma schema files and extracts all model definitions,\n * identifying their relations (one-to-one and one-to-many).\n */\nexport const prismaModelRelationFields: Record<string, RelationFields> = {};\n\nexport function getAllPrismaFiles(dirPath: string, fileList: string[] = []) {\n const files = fs.readdirSync(dirPath);\n\n files?.forEach((file) => {\n const filePath = path.join(dirPath, file);\n const stat = fs.statSync(filePath);\n\n // Skip migrations folder\n if (stat.isDirectory() && file !== \"migrations\") {\n fileList = getAllPrismaFiles(filePath, fileList);\n } else if (stat.isFile() && file.endsWith(\".prisma\")) {\n fileList.push(filePath);\n }\n });\n\n return fileList;\n}\n\nconst modelRegex = /model\\s+(\\w+)\\s*{/g;\nexport const models: string[] = [];\nexport let prismaSchemasContent: string;\nexport const prismaModelsUniqueFields: Record<string, ModelFieldDefition[]> =\n [] as any;\n\nexport function initializePrismaModels() {\n const prismaContent: string[] = [];\n\n const files = getAllPrismaFiles(\"./prisma\");\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\");\n\n if (!prismaContent?.includes?.(content)) prismaContent.push(content);\n }\n\n // Gather the content of all *.prisma files into single one\n const content = prismaContent\n .join(\"\\n\")\n .replace(modelRegex, (_, modelName) => {\n if (!models?.includes?.(modelName))\n models.push(camelCase(modelName.trim()));\n return `model ${modelName} {`;\n });\n\n const copiedContent = content;\n prismaSchemasContent = content;\n\n for (const model of models) {\n const modelName = pascalCase(model);\n\n const modelStart = copiedContent.indexOf(`model ${modelName} {`);\n const modelEnd = copiedContent.indexOf(\"}\", modelStart);\n const modelDefinition = copiedContent.slice(modelStart, modelEnd);\n\n const relations: RelationFields = {\n singular: [],\n list: [],\n };\n const lines = modelDefinition.split(\"\\n\");\n\n for (const line of lines) {\n const trimmedLine = line.trim();\n\n if (\n !trimmedLine ||\n trimmedLine.startsWith(\"model\") ||\n trimmedLine.startsWith(\"//\") ||\n trimmedLine.startsWith(\"/*\")\n )\n continue;\n\n const [fieldName, type] = trimmedLine.split(/\\s+/);\n const isUnique = trimmedLine?.includes?.(\"@unique\");\n\n if (isUnique) {\n const existingFields = prismaModelsUniqueFields[model] || [];\n\n const alreadyExists = existingFields.some(\n (field) =>\n field.name === fieldName &&\n field.type === type &&\n field.isUnique === isUnique\n );\n\n if (!alreadyExists) {\n prismaModelsUniqueFields[model] = [\n ...existingFields,\n { name: fieldName, type, isUnique },\n ];\n }\n }\n\n const cleanType = type?.replace(\"[]\", \"\").replace(\"?\", \"\");\n\n if (\n trimmedLine?.includes?.(\"@relation\") ||\n trimmedLine.match(/\\s+\\w+(\\[\\])?(\\s+@|$)/) ||\n models?.includes?.(camelCase(cleanType || \"\"))\n ) {\n const enumStart = copiedContent.indexOf(`enum ${cleanType} {`);\n const typeStart = copiedContent.indexOf(`type ${cleanType} {`);\n\n if (\n !cleanType ||\n enumStart >= 0 ||\n typeStart >= 0 ||\n cleanType === \"String\" ||\n cleanType === \"Int\" ||\n cleanType === \"Float\" ||\n cleanType === \"Boolean\" ||\n cleanType === \"DateTime\" ||\n cleanType === \"Bytes\" ||\n cleanType === \"Decimal\" ||\n cleanType === \"BigInt\" ||\n cleanType === \"Json\"\n ) {\n continue;\n }\n\n if (!type?.includes?.(\"[]\")) {\n relations.singular.push({\n name: fieldName,\n type: cleanType,\n });\n } else {\n relations.list.push({\n name: fieldName,\n type: cleanType,\n });\n }\n }\n\n prismaModelRelationFields[modelName] = relations;\n }\n }\n}\n\n/**\n * Retrieves the relations for a given Prisma model.\n *\n * @param {string} modelName - The name of the model (e.g., \"User\").\n * @returns {RelationFields|undefined} The relation fields for the model, or `undefined` if no relations are found.\n */\nexport function getPrismaModelRelations(\n modelName: string\n): RelationFields | undefined {\n modelName = pascalCase(modelName);\n\n if (!(modelName in prismaModelRelationFields)) return;\n return prismaModelRelationFields[modelName];\n}\n\n/**\n * Retrieves all the model names from the Prisma schema.\n *\n * @returns {string[]} An array of model names (e.g., [\"User\", \"Post\"]).\n */\nfunction getModels(): string[] {\n return models;\n}\n\n/**\n * Returns all content of all .prisma files gathered together\n *\n * @returns {string}\n */\nexport function getPrismaSchemasContent(): string {\n return prismaSchemasContent;\n}\n\n/** Retuns a given model unique fields\n * @param {string} modelName - The name of model in PascalCase\n * @returns {string[]} An array of all unique fields,\n */\nfunction getModelUniqueFields(modelName: string): ModelFieldDefition[] {\n return prismaModelsUniqueFields[modelName];\n}\n\nexport { getModels, getModelUniqueFields };\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processMiddleware = exports.safeCatchAsync = void 0;
4
+ const error_handler_1 = require("../../exports/error-handler");
5
+ const safeCatchAsync = (middleware) => {
6
+ return middleware ? (0, error_handler_1.catchAsync)(middleware) : undefined;
7
+ };
8
+ exports.safeCatchAsync = safeCatchAsync;
9
+ const processMiddleware = (middleware) => {
10
+ if (!middleware)
11
+ return [];
12
+ if (Array.isArray(middleware)) {
13
+ return middleware
14
+ .filter((mw) => !!mw)
15
+ .map((mw) => (0, exports.safeCatchAsync)(mw));
16
+ }
17
+ else
18
+ return [(0, exports.safeCatchAsync)(middleware)];
19
+ };
20
+ exports.processMiddleware = processMiddleware;
21
+ //# sourceMappingURL=routers.helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routers.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/routers.helpers.ts"],"names":[],"mappings":";;;AAAA,+DAAyD;AAGlD,MAAM,cAAc,GAAG,CAAC,UAAe,EAAE,EAAE;IAChD,OAAO,UAAU,CAAC,CAAC,CAAC,IAAA,0BAAU,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB;AAGK,MAAM,iBAAiB,GAAG,CAAC,UAAe,EAAE,EAAE;IACnD,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,UAAU;aACd,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAA,sBAAc,EAAC,EAAE,CAAC,CAA2B,CAAC;IAC/D,CAAC;;QAAM,OAAO,CAAC,IAAA,sBAAc,EAAC,UAAU,CAAC,CAA2B,CAAC;AACvE,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B","sourcesContent":["import { catchAsync } from \"../../exports/error-handler\";\nimport { CatchAsyncReturnType } from \"../../modules/error-handler/utils/catch-async\";\n\nexport const safeCatchAsync = (middleware: any) => {\n return middleware ? catchAsync(middleware) : undefined;\n};\n\n// Helper function to handle middleware arrays or single functions\nexport const processMiddleware = (middleware: any) => {\n if (!middleware) return [];\n\n if (Array.isArray(middleware)) {\n return middleware\n .filter((mw) => !!mw)\n .map((mw) => safeCatchAsync(mw)) as CatchAsyncReturnType[];\n } else return [safeCatchAsync(middleware)] as CatchAsyncReturnType[];\n};\n"]}
@@ -1,143 +1,119 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class Sheu {
4
- constructor() {
5
- this.codes = [];
6
- }
7
- _apply(text) {
8
- const openCodes = this.codes.join("");
9
- return `${openCodes}${text}\x1b[0m`;
10
- }
11
- _chain() {
12
- const newInstance = new Sheu();
13
- newInstance.codes = [...this.codes];
14
- return newInstance;
15
- }
16
- red(text) {
17
- if (text !== undefined) {
18
- return `\x1b[31m${text}\x1b[0m`;
19
- }
20
- const instance = this._chain();
21
- instance.codes.push("\x1b[31m");
22
- return instance;
23
- }
24
- blue(text) {
25
- if (text !== undefined) {
26
- return `\x1b[34m${text}\x1b[0m`;
27
- }
28
- const instance = this._chain();
29
- instance.codes.push("\x1b[34m");
30
- return instance;
31
- }
32
- green(text) {
33
- if (text !== undefined) {
34
- return `\x1b[32m${text}\x1b[0m`;
35
- }
36
- const instance = this._chain();
37
- instance.codes.push("\x1b[32m");
38
- return instance;
39
- }
40
- yellow(text) {
41
- if (text !== undefined) {
42
- return `\x1b[33m${text}\x1b[0m`;
43
- }
44
- const instance = this._chain();
45
- instance.codes.push("\x1b[33m");
46
- return instance;
47
- }
48
- cyan(text) {
49
- if (text !== undefined) {
50
- return `\x1b[36m${text}\x1b[0m`;
51
- }
52
- const instance = this._chain();
53
- instance.codes.push("\x1b[36m");
54
- return instance;
55
- }
56
- magenta(text) {
57
- if (text !== undefined) {
58
- return `\x1b[35m${text}\x1b[0m`;
4
+ getTimestamp() {
5
+ return new Date().toTimeString().split(" ")[0];
6
+ }
7
+ formatText(text = "", options = {}) {
8
+ const label = options?.label
9
+ ? text
10
+ ? options?.label + " "
11
+ : options?.label
12
+ : "";
13
+ let result = `${label}${text}`;
14
+ if (options.timestamp) {
15
+ const timestamp = this.getTimestamp();
16
+ if (options.timestamp === true)
17
+ result = `${label}\x1b[90m${timestamp}\x1b[0m ${text}`;
18
+ else if (typeof options.timestamp === "string") {
19
+ const colorCode = this.getColorCode(options.timestamp);
20
+ result = `${label}${colorCode}${timestamp}\x1b[0m ${text}`;
21
+ }
59
22
  }
60
- const instance = this._chain();
61
- instance.codes.push("\x1b[35m");
62
- return instance;
63
- }
64
- white(text) {
65
- if (text !== undefined) {
66
- return `\x1b[37m${text}\x1b[0m`;
67
- }
68
- const instance = this._chain();
69
- instance.codes.push("\x1b[37m");
70
- return instance;
71
- }
72
- black(text) {
73
- if (text !== undefined) {
74
- return `\x1b[30m${text}\x1b[0m`;
75
- }
76
- const instance = this._chain();
77
- instance.codes.push("\x1b[30m");
78
- return instance;
79
- }
80
- gray(text) {
81
- if (text !== undefined) {
82
- return `\x1b[90m${text}\x1b[0m`;
83
- }
84
- const instance = this._chain();
85
- instance.codes.push("\x1b[90m");
86
- return instance;
87
- }
88
- orange(text) {
89
- if (text !== undefined) {
90
- return `\x1b[91m${text}\x1b[0m`;
91
- }
92
- const instance = this._chain();
93
- instance.codes.push("\x1b[91m");
94
- return instance;
95
- }
96
- bold(text) {
97
- if (text !== undefined) {
98
- return `\x1b[1m${text}\x1b[0m`;
99
- }
100
- const instance = this._chain();
101
- instance.codes.push("\x1b[1m");
102
- return instance;
103
- }
104
- apply(text) {
105
- return this._apply(text);
106
- }
107
- info(message) {
23
+ if (options.bold)
24
+ result = `\x1b[1m${result}\x1b[0m`;
25
+ return result;
26
+ }
27
+ getColorCode(color) {
28
+ const colorMap = {
29
+ red: "\x1b[31m",
30
+ blue: "\x1b[34m",
31
+ green: "\x1b[32m",
32
+ yellow: "\x1b[33m",
33
+ cyan: "\x1b[36m",
34
+ magenta: "\x1b[35m",
35
+ white: "\x1b[37m",
36
+ black: "\x1b[30m",
37
+ gray: "\x1b[90m",
38
+ orange: "\x1b[91m",
39
+ };
40
+ return colorMap[color] || "\x1b[90m";
41
+ }
42
+ red(text, options) {
43
+ const coloredText = `\x1b[31m${text}\x1b[0m`;
44
+ return this.formatText(coloredText, options || {});
45
+ }
46
+ blue(text, options) {
47
+ const coloredText = `\x1b[34m${text}\x1b[0m`;
48
+ return this.formatText(coloredText, options || {});
49
+ }
50
+ green(text, options) {
51
+ const coloredText = `\x1b[32m${text}\x1b[0m`;
52
+ return this.formatText(coloredText, options || {});
53
+ }
54
+ yellow(text, options) {
55
+ const coloredText = `\x1b[33m${text}\x1b[0m`;
56
+ return this.formatText(coloredText, options || {});
57
+ }
58
+ cyan(text, options) {
59
+ const coloredText = `\x1b[36m${text}\x1b[0m`;
60
+ return this.formatText(coloredText, options || {});
61
+ }
62
+ magenta(text, options) {
63
+ const coloredText = `\x1b[35m${text}\x1b[0m`;
64
+ return this.formatText(coloredText, options || {});
65
+ }
66
+ white(text, options) {
67
+ const coloredText = `\x1b[37m${text}\x1b[0m`;
68
+ return this.formatText(coloredText, options || {});
69
+ }
70
+ black(text, options) {
71
+ const coloredText = `\x1b[30m${text}\x1b[0m`;
72
+ return this.formatText(coloredText, options || {});
73
+ }
74
+ gray(text, options) {
75
+ const coloredText = `\x1b[90m${text}\x1b[0m`;
76
+ return this.formatText(coloredText, options || {});
77
+ }
78
+ orange(text, options) {
79
+ const coloredText = `\x1b[91m${text}\x1b[0m`;
80
+ return this.formatText(coloredText, options || {});
81
+ }
82
+ bold(text, options) {
83
+ const boldText = `\x1b[1m${text}\x1b[0m`;
84
+ return this.formatText(boldText, { ...options, bold: false });
85
+ }
86
+ info(message, options) {
108
87
  const label = `[\x1b[36mINFO\x1b[0m]`;
109
- const content = message ? `${label} ${message}` : label;
110
- console.info(content);
111
- return content;
88
+ const result = this.formatText(message, { ...options, label });
89
+ console.info(result);
90
+ return result;
112
91
  }
113
- error(message) {
92
+ error(message, options) {
114
93
  const label = `[\x1b[31mERROR\x1b[0m]`;
115
- const content = message ? `${label} ${message}` : label;
116
- console.info(content);
117
- return content;
94
+ const result = this.formatText(message, { ...options, label });
95
+ console.error(result);
96
+ return result;
118
97
  }
119
- ready(message) {
98
+ ready(message, options) {
120
99
  const label = `[\x1b[32mREADY\x1b[0m]`;
121
- const content = message ? `${label} ${message}` : label;
122
- console.info(content);
123
- return content;
100
+ const result = this.formatText(message, { ...options, label });
101
+ console.info(result);
102
+ return result;
124
103
  }
125
- done(message) {
104
+ done(message, options) {
126
105
  const label = `[\x1b[32mDONE\x1b[0m]`;
127
- const content = message ? `${label} ${message}` : label;
128
- console.info(content);
129
- return content;
106
+ const result = this.formatText(message, { ...options, label });
107
+ console.info(result);
108
+ return result;
130
109
  }
131
- warn(message) {
110
+ warn(message, options) {
132
111
  const label = `[\x1b[33mWARN\x1b[0m]`;
133
- console.info(message ? `${label} ${message}` : label);
112
+ const result = this.formatText(message, { ...options, label });
113
+ console.warn(result);
114
+ return result;
134
115
  }
135
116
  }
136
117
  const sheu = new Sheu();
137
- Object.getOwnPropertyNames(Sheu.prototype).forEach((method) => {
138
- if (method !== "constructor" && method !== "_apply" && method !== "_chain") {
139
- sheu[method] = Sheu.prototype[method].bind(new Sheu());
140
- }
141
- });
142
118
  exports.default = sheu;
143
119
  //# sourceMappingURL=sheu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sheu.js","sourceRoot":"","sources":["../../../src/utils/sheu.ts"],"names":[],"mappings":";;AAIA,MAAM,IAAI;IAGR;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IAOD,MAAM,CAAC,IAAY;QACjB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtC,OAAO,GAAG,SAAS,GAAG,IAAI,SAAS,CAAC;IACtC,CAAC;IAMD,MAAM;QACJ,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;QAC/B,WAAW,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,KA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AAO,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC;IACjB,CAAC;IAOD,IAAI,CAAC,OAAgB;QACnB,MAAM,KAAK,GAAG,uBAAuB,CAAC;QACtC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC;IACjB,CAAC;IAOD,IAAI,CAAC,OAAgB;QACnB,MAAM,KAAK,GAAG,uBAAuB,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;CACF;AAGD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;AAGxB,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;IAC5D,IAAI,MAAM,KAAK,aAAa,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1E,IAAY,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAsB,CAAC,CAAC,IAAI,CACjE,IAAI,IAAI,EAAE,CACX,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,kBAAe,IAAI,CAAC","sourcesContent":["/**\n * Sheu - Terminal color utility class for styling console output\n * Provides chainable methods for colors and text formatting\n */\nclass Sheu {\n codes: string[];\n\n constructor() {\n this.codes = [];\n }\n\n /**\n * Apply text to the current styling codes\n * @param {string} text - The text to style\n * @returns {string} The styled text with ANSI codes\n */\n _apply(text: string): string {\n const openCodes = this.codes.join(\"\");\n return `${openCodes}${text}\\x1b[0m`;\n }\n\n /**\n * Create a new instance with the current codes\n * @returns {Sheu} New Sheu instance\n */\n _chain(): Sheu {\n const newInstance = new Sheu();\n newInstance.codes = [...this.codes];\n return newInstance;\n }\n\n /**\n * Red color (Tailwind red-500: #ef4444)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n red(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[31m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[31m\");\n return instance;\n }\n\n /**\n * Blue color (Tailwind blue-500: #3b82f6)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n blue(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[34m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[34m\");\n return instance;\n }\n\n /**\n * Green color (Tailwind green-500: #22c55e)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n green(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[32m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[32m\");\n return instance;\n }\n\n /**\n * Yellow color (Tailwind yellow-500: #eab308)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n yellow(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[33m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[33m\");\n return instance;\n }\n\n /**\n * Cyan color (Tailwind cyan-500: #06b6d4)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n cyan(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[36m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[36m\");\n return instance;\n }\n\n /**\n * Magenta color (Tailwind fuchsia-500: #d946ef)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n magenta(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[35m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[35m\");\n return instance;\n }\n\n /**\n * White color (Tailwind white: #ffffff)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n white(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[37m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[37m\");\n return instance;\n }\n\n /**\n * Black color (Tailwind black: #000000)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n black(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[30m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[30m\");\n return instance;\n }\n\n /**\n * Gray color (Tailwind gray-500: #6b7280)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n gray(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[90m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[90m\");\n return instance;\n }\n\n /**\n * Orange color (Tailwind orange-500: #f97316)\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n orange(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[91m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[91m\");\n return instance;\n }\n\n /**\n * Bold text formatting\n * @param {string} [text] - Optional text to style immediately\n * @returns {string|Sheu} Styled text or chainable instance\n */\n bold(text?: string): string | Sheu {\n if (text !== undefined) {\n return `\\x1b[1m${text}\\x1b[0m`;\n }\n const instance = this._chain();\n instance.codes.push(\"\\x1b[1m\");\n return instance;\n }\n\n /**\n * Apply all accumulated styles to text\n * @param {string} text - The text to style\n * @returns {string} The styled text\n */\n apply(text: string): string {\n return this._apply(text);\n }\n\n /**\n * Info label with cyan color [INFO]\n * @param {string} [message] - Optional message to append\n * @returns {string} Formatted info label\n */\n info(message?: string): string {\n const label = `[\\x1b[36mINFO\\x1b[0m]`;\n const content = message ? `${label} ${message}` : label;\n console.info(content);\n return content;\n }\n\n /**\n * Error label with red color [ERROR]\n * @param {string} [message] - Optional message to append\n * @returns {string} Formatted error label\n */\n error(message?: string): string {\n const label = `[\\x1b[31mERROR\\x1b[0m]`;\n const content = message ? `${label} ${message}` : label;\n console.info(content);\n return content;\n }\n\n /**\n * Ready label with green color [READY]\n * @param {string} [message] - Optional message to append\n * @returns {string} Formatted ready label\n */\n ready(message?: string): string {\n const label = `[\\x1b[32mREADY\\x1b[0m]`;\n const content = message ? `${label} ${message}` : label;\n console.info(content);\n return content;\n }\n\n /**\n * Done label with green color [DONE]\n * @param {string} [message] - Optional message to append\n * @returns {string} Formatted done label\n */\n done(message?: string): string {\n const label = `[\\x1b[32mDONE\\x1b[0m]`;\n const content = message ? `${label} ${message}` : label;\n console.info(content);\n return content;\n }\n\n /**\n * Warning label with yellow color [WARN]\n * @param {string} [message] - Optional message to append\n * @returns void\n */\n warn(message?: string) {\n const label = `[\\x1b[33mWARN\\x1b[0m]`;\n console.info(message ? `${label} ${message}` : label);\n }\n}\n\n// Create default instance\nconst sheu = new Sheu();\n\n// Add static methods to the default instance for direct usage\nObject.getOwnPropertyNames(Sheu.prototype).forEach((method) => {\n if (method !== \"constructor\" && method !== \"_apply\" && method !== \"_chain\") {\n (sheu as any)[method] = Sheu.prototype[method as keyof Object].bind(\n new Sheu()\n );\n }\n});\n\nexport default sheu;\n"]}
1
+ {"version":3,"file":"sheu.js","sourceRoot":"","sources":["../../../src/utils/sheu.ts"],"names":[],"mappings":";;AAGA,MAAM,IAAI;IAIA,YAAY;QAClB,O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AC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;IAKD,KAAK,CACH,OAAe,EACf,OAA0D;QAE1D,MAAM,KAAK,GAAG,wBAAwB,CAAC;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IAKD,IAAI,CACF,OAAe,EACf,OAA0D;QAE1D,MAAM,KAAK,GAAG,uBAAuB,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IAKD,IAAI,CACF,OAAe,EACf,OAA0D;QAE1D,MAAM,KAAK,GAAG,uBAAuB,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;AAExB,kBAAe,IAAI,CAAC","sourcesContent":["/**\n * Sheu - Simplified terminal color utility for styling console output\n */\nclass Sheu {\n /**\n * Get current timestamp in HH:MM:SS format\n */\n private getTimestamp(): string {\n return new Date().toTimeString().split(\" \")[0];\n }\n\n /**\n * Apply timestamp and bold formatting if requested\n */\n private formatText(\n text: string = \"\",\n options: {\n timestamp?: boolean | string;\n bold?: boolean;\n label?: string;\n } = {}\n ): string {\n const label = options?.label\n ? text\n ? options?.label + \" \"\n : options?.label\n : \"\";\n let result = `${label}${text}`;\n\n // Apply timestamp if requested\n if (options.timestamp) {\n const timestamp = this.getTimestamp();\n if (options.timestamp === true)\n result = `${label}\\x1b[90m${timestamp}\\x1b[0m ${text}`;\n else if (typeof options.timestamp === \"string\") {\n const colorCode = this.getColorCode(options.timestamp);\n result = `${label}${colorCode}${timestamp}\\x1b[0m ${text}`;\n }\n }\n\n if (options.bold) result = `\\x1b[1m${result}\\x1b[0m`;\n\n return result;\n }\n\n /**\n * Get ANSI color code for color name\n */\n private getColorCode(color: string): string {\n const colorMap: { [key: string]: string } = {\n red: \"\\x1b[31m\",\n blue: \"\\x1b[34m\",\n green: \"\\x1b[32m\",\n yellow: \"\\x1b[33m\",\n cyan: \"\\x1b[36m\",\n magenta: \"\\x1b[35m\",\n white: \"\\x1b[37m\",\n black: \"\\x1b[30m\",\n gray: \"\\x1b[90m\",\n orange: \"\\x1b[91m\",\n };\n return colorMap[color] || \"\\x1b[90m\"; // Default to gray if color not found\n }\n\n /**\n * Red color\n */\n red(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[31m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Blue color\n */\n blue(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[34m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Green color\n */\n green(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[32m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Yellow color\n */\n yellow(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[33m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Cyan color\n */\n cyan(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[36m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Magenta color\n */\n magenta(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[35m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * White color\n */\n white(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[37m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Black color\n */\n black(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[30m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Gray color\n */\n gray(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[90m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Orange color\n */\n orange(\n text: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[91m${text}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Bold text formatting\n */\n bold(text: string, options?: { timestamp?: boolean | string }): string {\n const boldText = `\\x1b[1m${text}\\x1b[0m`;\n return this.formatText(boldText, { ...options, bold: false }); // Don't double-bold\n }\n\n /**\n * Info label with cyan color [INFO]\n */\n info(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[36mINFO\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.info(result);\n return result;\n }\n\n /**\n * Error label with red color [ERROR]\n */\n error(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[31mERROR\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.error(result);\n return result;\n }\n\n /**\n * Ready label with green color [READY]\n */\n ready(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[32mREADY\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.info(result);\n return result;\n }\n\n /**\n * Done label with green color [DONE]\n */\n done(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[32mDONE\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.info(result);\n return result;\n }\n\n /**\n * Warning label with yellow color [WARN]\n */\n warn(\n message: string,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[33mWARN\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.warn(result);\n return result;\n }\n}\n\nconst sheu = new Sheu();\n\nexport default sheu;\n"]}
@@ -5,10 +5,10 @@ import rateLimit from "express-rate-limit";
5
5
  import { importPrismaModelModules } from "../../utils/helpers/models.helpers.js";
6
6
  import { addPrismaQueryOptionsToRequest, handleRequestBodyValidationAndTransformation, sendResponse, } from "../base/base.middlewares.js";
7
7
  import deepmerge from "../../utils/helpers/deepmerge.helper.js";
8
- import catchAsync from "../error-handler/utils/catch-async.js";
8
+ import { processMiddleware } from "../../utils/helpers/routers.helpers.js";
9
9
  const router = Router();
10
10
  export async function getAuthRouter(arkosConfigs) {
11
- const { middlewares, dtos, schemas, prismaQueryOptions } = await importPrismaModelModules("auth");
11
+ const { middlewares, dtos, schemas, prismaQueryOptions } = await importPrismaModelModules("auth", arkosConfigs);
12
12
  const authController = await authControllerFactory(middlewares);
13
13
  const getValidationSchemaOrDto = (key) => {
14
14
  const validationConfigs = arkosConfigs?.validation;
@@ -20,43 +20,10 @@ export async function getAuthRouter(arkosConfigs) {
20
20
  }
21
21
  return undefined;
22
22
  };
23
- const safeCatchAsync = (middleware) => {
24
- return middleware ? catchAsync(middleware) : undefined;
25
- };
26
23
  router
27
- .get("/users/me", authService.authenticate, addPrismaQueryOptionsToRequest(prismaQueryOptions, "getMe"), ...[
28
- safeCatchAsync(middlewares?.beforeGetMe) || authController.getMe,
29
- safeCatchAsync(middlewares?.beforeGetMe)
30
- ? authController.getMe
31
- : safeCatchAsync(middlewares?.afterGetMe) || sendResponse,
32
- safeCatchAsync(middlewares?.beforeGetMe) &&
33
- safeCatchAsync(middlewares?.afterGetMe)
34
- ? safeCatchAsync(middlewares?.afterGetMe)
35
- : sendResponse,
36
- sendResponse,
37
- ].filter((middleware) => !!middleware))
38
- .patch("/users/me", authService.authenticate, handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updateMe")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMe"), ...[
39
- safeCatchAsync(middlewares?.beforeUpdateMe) || authController.updateMe,
40
- safeCatchAsync(middlewares?.beforeUpdateMe)
41
- ? authController.updateMe
42
- : safeCatchAsync(middlewares?.afterUpdateMe) || sendResponse,
43
- safeCatchAsync(middlewares?.beforeUpdateMe) &&
44
- safeCatchAsync(middlewares?.afterUpdateMe)
45
- ? safeCatchAsync(middlewares?.afterUpdateMe)
46
- : sendResponse,
47
- sendResponse,
48
- ].filter((middleware) => !!middleware))
49
- .delete("/users/me", authService.authenticate, addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMe"), ...[
50
- safeCatchAsync(middlewares?.beforeDeleteMe) || authController.deleteMe,
51
- safeCatchAsync(middlewares?.beforeDeleteMe)
52
- ? authController.deleteMe
53
- : safeCatchAsync(middlewares?.afterDeleteMe) || sendResponse,
54
- safeCatchAsync(middlewares?.beforeDeleteMe) &&
55
- safeCatchAsync(middlewares?.afterDeleteMe)
56
- ? safeCatchAsync(middlewares?.afterDeleteMe)
57
- : sendResponse,
58
- sendResponse,
59
- ].filter((middleware) => !!middleware));
24
+ .get("/users/me", authService.authenticate, addPrismaQueryOptionsToRequest(prismaQueryOptions, "getMe"), ...processMiddleware(middlewares?.beforeGetMe), authController.getMe, ...processMiddleware(middlewares?.afterGetMe), sendResponse)
25
+ .patch("/users/me", authService.authenticate, handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updateMe")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updateMe"), ...processMiddleware(middlewares?.beforeUpdateMe), authController.updateMe, ...processMiddleware(middlewares?.afterUpdateMe), sendResponse)
26
+ .delete("/users/me", authService.authenticate, addPrismaQueryOptionsToRequest(prismaQueryOptions, "deleteMe"), ...processMiddleware(middlewares?.beforeDeleteMe), authController.deleteMe, ...processMiddleware(middlewares?.afterDeleteMe), sendResponse);
60
27
  router.use("/auth", rateLimit(deepmerge({
61
28
  windowMs: 5000,
62
29
  limit: 10,
@@ -68,51 +35,10 @@ export async function getAuthRouter(arkosConfigs) {
68
35
  });
69
36
  },
70
37
  }, arkosConfigs?.authentication?.requestRateLimitOptions || {})));
71
- router.post("/auth/login", handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("login")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "login"), ...[
72
- safeCatchAsync(middlewares?.beforeLogin) || authController.login,
73
- safeCatchAsync(middlewares?.beforeLogin)
74
- ? authController.login
75
- : safeCatchAsync(middlewares?.afterLogin) || sendResponse,
76
- safeCatchAsync(middlewares?.beforeLogin) &&
77
- safeCatchAsync(middlewares?.afterLogin)
78
- ? safeCatchAsync(middlewares?.afterLogin)
79
- : sendResponse,
80
- sendResponse,
81
- ].filter((middleware) => !!middleware));
82
- router.delete("/auth/logout", authService.authenticate, ...[
83
- safeCatchAsync(middlewares?.beforeLogout) || authController.logout,
84
- safeCatchAsync(middlewares?.beforeLogout)
85
- ? authController.logout
86
- : safeCatchAsync(middlewares?.afterLogout) || sendResponse,
87
- safeCatchAsync(middlewares?.beforeLogout) &&
88
- safeCatchAsync(middlewares?.afterLogout)
89
- ? safeCatchAsync(middlewares?.afterLogout)
90
- : sendResponse,
91
- sendResponse,
92
- ].filter((middleware) => !!middleware));
93
- router.post("/auth/signup", handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("signup")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "signup"), ...[
94
- safeCatchAsync(middlewares?.beforeSignup) || authController.signup,
95
- safeCatchAsync(middlewares?.beforeSignup)
96
- ? authController.signup
97
- : safeCatchAsync(middlewares?.afterSignup) || sendResponse,
98
- safeCatchAsync(middlewares?.beforeSignup) &&
99
- safeCatchAsync(middlewares?.afterSignup)
100
- ? safeCatchAsync(middlewares?.afterSignup)
101
- : sendResponse,
102
- sendResponse,
103
- ].filter((middleware) => !!middleware));
104
- router.post("/auth/update-password", authService.authenticate, handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updatePassword")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updatePassword"), ...[
105
- safeCatchAsync(middlewares?.beforeUpdatePassword) ||
106
- authController.updatePassword,
107
- safeCatchAsync(middlewares?.beforeUpdatePassword)
108
- ? authController.updatePassword
109
- : safeCatchAsync(middlewares?.afterUpdatePassword) || sendResponse,
110
- safeCatchAsync(middlewares?.beforeUpdatePassword) &&
111
- safeCatchAsync(middlewares?.afterUpdatePassword)
112
- ? safeCatchAsync(middlewares?.afterUpdatePassword)
113
- : sendResponse,
114
- sendResponse,
115
- ].filter((middleware) => !!middleware));
38
+ router.post("/auth/login", handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("login")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "login"), ...processMiddleware(middlewares?.beforeLogin), authController.login, ...processMiddleware(middlewares?.afterLogin), sendResponse);
39
+ router.delete("/auth/logout", authService.authenticate, ...processMiddleware(middlewares?.beforeLogout), authController.logout, ...processMiddleware(middlewares?.afterLogout), sendResponse);
40
+ router.post("/auth/signup", handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("signup")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "signup"), ...processMiddleware(middlewares?.beforeSignup), authController.signup, ...processMiddleware(middlewares?.afterSignup), sendResponse);
41
+ router.post("/auth/update-password", authService.authenticate, handleRequestBodyValidationAndTransformation(getValidationSchemaOrDto("updatePassword")), addPrismaQueryOptionsToRequest(prismaQueryOptions, "updatePassword"), ...processMiddleware(middlewares?.beforeUpdatePassword), authController.updatePassword, ...processMiddleware(middlewares?.afterUpdatePassword), sendResponse);
116
42
  return router;
117
43
  }
118
44
  //# sourceMappingURL=auth.router.js.map