arkos 1.4.0-canary.26 → 1.4.0-canary.28

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.
package/dist/cjs/app.js CHANGED
@@ -156,16 +156,16 @@ async function bootstrap(arkosConfig) {
156
156
  }
157
157
  exports.app.use(knowModulesRouter);
158
158
  exports.app.use("/api", (0, base_router_1.getAvailableResourcesAndRoutesRouter)());
159
- if (arkosConfig.swagger &&
160
- (process.env.ARKOS_BUILD !== "true" ||
161
- arkosConfig.swagger.enableAfterBuild === true))
162
- exports.app.use("/api", await (0, swagger_router_1.getSwaggerRouter)(arkosConfig, exports.app));
163
159
  if (routersConfig?.additional)
164
160
  routersConfig.additional.forEach((router) => {
165
161
  exports.app.use(router);
166
162
  });
163
+ if (arkosConfig.swagger &&
164
+ (process.env.ARKOS_BUILD !== "true" ||
165
+ arkosConfig.swagger.enableAfterBuild === true))
166
+ exports.app.use("/api", await (0, swagger_router_1.getSwaggerRouter)(arkosConfig, exports.app));
167
167
  exports.app.use("*", (req) => {
168
- throw new error_handler_1.AppError("Route not found", 404, { route: req.route }, "RouteNotFound");
168
+ throw new error_handler_1.AppError("Route not found", 404, { route: req.path }, "RouteNotFound");
169
169
  });
170
170
  if (!disabledMiddlewares?.includes?.("global-error-handler"))
171
171
  exports.app.use(replacedMiddlewares.globalErrorHandler || error_handler_controller_1.default);
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,8BAmLC;AA5MD,mDAA0C;AAC1C,gDAAwB;AACxB,kEAAyC;AACzC,4DAA2D;AAC3D,4DAGoC;AACpC,gHAA4E;AAC5E,2DAA+C;AAC/C,8DAAsC;AACtC,sEAAoE;AACpE,mEAAkE;AAClE,iFAA+E;AAE/E,+EAAmE;AACnE,wFAAyD;AACzD,qEAAoE;AACpE,2DAAiE;AACjE,2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AAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC3B,WAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAA,kDAAoC,GAAE,CAAC,CAAC;IAExD,IACE,WAAW,CAAC,OAAO;QACnB,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM;YACjC,WAAW,CAAC,OAAO,CAAC,gBAAgB,KAAK,IAAI,CAAC;QAEhD,WAAG,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,IAAA,iCAAgB,EAAC,WAAW,EAAE,WAAG,CAAC,CAAC,CAAC;IAE5D,IAAI,aAAa,EAAE,UAAU;QAC3B,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1C,WAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IAEL,WAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACnB,MAAM,IAAI,wBAAQ,CAChB,iBAAiB,EACjB,GAAG,EACH,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,EACpB,eAAe,CAChB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,mBAAmB,EAAE,QAAQ,EAAE,CAAC,sBAAsB,CAAC;QAC1D,WAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,kBAAkB,IAAI,kCAAY,CAAC,CAAC;IAElE,OAAO,WAAG,CAAC;AACb,CAAC","sourcesContent":["import express, { Router } from \"express\";\nimport cors from \"cors\";\nimport cookieParser from \"cookie-parser\";\nimport { getAuthRouter } from \"./modules/auth/auth.router\";\nimport {\n getPrismaModelsRouter,\n getAvailableResourcesAndRoutesRouter,\n} from \"./modules/base/base.router\";\nimport errorHandler from \"./modules/error-handler/error-handler.controller\";\nimport { rateLimit } from \"express-rate-limit\";\nimport compression from \"compression\";\nimport { handleRequestLogs } from \"./modules/base/base.middlewares\";\nimport { loadPrismaModule } from \"./utils/helpers/prisma.helpers\";\nimport { getFileUploadRouter } from \"./modules/file-upload/file-upload.router\";\nimport { ArkosConfig } from \"./types/arkos-config\";\nimport { queryParser } from \"./utils/helpers/query-parser.helpers\";\nimport deepmerge from \"./utils/helpers/deepmerge.helper\";\nimport { getSwaggerRouter } from \"./modules/swagger/swagger.router\";\nimport { loadAllModuleComponents } from \"./utils/dynamic-loader\";\nimport { AppError } from \"./exports/error-handler\";\nimport debuggerService from \"./modules/debugger/debugger.service\";\n\nexport const app: express.Express = express();\nconst knowModulesRouter = Router();\n\nexport async function bootstrap(\n arkosConfig: ArkosConfig\n): Promise<express.Express> {\n await Promise.all([\n loadPrismaModule(),\n loadAllModuleComponents(arkosConfig),\n arkosConfig?.configureApp && (await arkosConfig?.configureApp(app)),\n ]);\n\n const middlewaresConfig = arkosConfig?.middlewares;\n const disabledMiddlewares = middlewaresConfig?.disable || [];\n const replacedMiddlewares = middlewaresConfig?.replace || {};\n\n if (!disabledMiddlewares?.includes?.(\"compression\"))\n app.use(\n replacedMiddlewares.compression ||\n compression(arkosConfig?.compressionOptions)\n );\n\n if (!disabledMiddlewares?.includes?.(\"global-rate-limit\"))\n app.use(\n replacedMiddlewares.globalRateLimit ||\n rateLimit(\n deepmerge(\n {\n windowMs: 60 * 1000,\n limit: 300,\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?.globalRequestRateLimitOptions || {}\n )\n )\n );\n\n if (!disabledMiddlewares?.includes?.(\"cors\"))\n app.use(\n replacedMiddlewares.cors ||\n cors(\n arkosConfig?.cors?.customHandler\n ? arkosConfig.cors.customHandler\n : deepmerge(\n {\n origin: (\n origin: string,\n cb: (err: Error | null, allow?: boolean) => void\n ) => {\n const allowed = arkosConfig?.cors?.allowedOrigins;\n\n if (allowed === \"*\") cb(null, true);\n else if (Array.isArray(allowed))\n cb(null, !origin || allowed?.includes?.(origin));\n else if (typeof allowed === \"string\")\n cb(null, !origin || allowed === origin);\n else cb(null, false);\n },\n\n methods: [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\", \"OPTIONS\"],\n allowedHeaders: [\n \"Content-Type\",\n \"Authorization\",\n \"Connection\",\n ],\n credentials: true,\n },\n arkosConfig?.cors?.options || {}\n )\n )\n );\n\n if (!disabledMiddlewares?.includes?.(\"express-json\"))\n app.use(\n replacedMiddlewares.expressJson ||\n express.json(arkosConfig?.jsonBodyParserOptions)\n );\n\n if (!disabledMiddlewares?.includes?.(\"cookie-parser\"))\n app.use(\n replacedMiddlewares.cookieParser ||\n cookieParser(...[...(arkosConfig?.cookieParserParameters || [])])\n );\n\n if (!disabledMiddlewares?.includes?.(\"query-parser\"))\n app.use(\n replacedMiddlewares.queryParser ||\n queryParser(\n deepmerge(\n {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n },\n arkosConfig?.queryParserOptions || {}\n )\n )\n );\n\n if (!disabledMiddlewares?.includes?.(\"request-logger\"))\n app.use(replacedMiddlewares.requestLogger || handleRequestLogs);\n\n if (arkosConfig?.middlewares?.additional)\n arkosConfig.middlewares.additional.forEach((middleware) => {\n app.use(middleware);\n });\n\n app.use(debuggerService.logRequestInfo);\n\n const routersConfig = arkosConfig?.routers;\n const disabledRouters = routersConfig?.disable || [];\n const replacedRouters = routersConfig?.replace || {};\n\n if (!disabledRouters?.includes?.(\"welcome-endpoint\"))\n app.get(\n \"/api\",\n replacedRouters.welcomeEndpoint ||\n ((_, res) => {\n res.status(200).json({ message: arkosConfig.welcomeMessage });\n })\n );\n\n app.use(debuggerService.logRequestInfo);\n\n if (!disabledRouters?.includes?.(\"file-upload\")) {\n const fileUploadRouter = replacedRouters.fileUpload\n ? await replacedRouters.fileUpload(arkosConfig)\n : await getFileUploadRouter(arkosConfig);\n knowModulesRouter.use(fileUploadRouter);\n }\n\n if (\n !disabledRouters?.includes?.(\"auth-router\") &&\n arkosConfig.authentication\n ) {\n const authRouter = replacedRouters.authRouter\n ? await replacedRouters.authRouter(arkosConfig)\n : await getAuthRouter(arkosConfig);\n knowModulesRouter.use(\"/api\", authRouter);\n }\n\n if (!disabledRouters?.includes?.(\"prisma-models-router\")) {\n const modelsRouter = replacedRouters.prismaModelsRouter\n ? await replacedRouters.prismaModelsRouter(arkosConfig)\n : await getPrismaModelsRouter(arkosConfig);\n knowModulesRouter.use(\"/api\", modelsRouter);\n }\n\n app.use(knowModulesRouter);\n app.use(\"/api\", getAvailableResourcesAndRoutesRouter());\n\n if (\n arkosConfig.swagger &&\n (process.env.ARKOS_BUILD !== \"true\" ||\n arkosConfig.swagger.enableAfterBuild === true)\n )\n app.use(\"/api\", await getSwaggerRouter(arkosConfig, app));\n\n if (routersConfig?.additional)\n routersConfig.additional.forEach((router) => {\n app.use(router);\n });\n\n app.use(\"*\", (req) => {\n throw new AppError(\n \"Route not found\",\n 404,\n { route: req.route },\n \"RouteNotFound\"\n );\n });\n\n if (!disabledMiddlewares?.includes?.(\"global-error-handler\"))\n app.use(replacedMiddlewares.globalErrorHandler || errorHandler);\n\n return app;\n}\n"]}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,8BAuLC;AAhND,mDAA0C;AAC1C,gDAAwB;AACxB,kEAAyC;AACzC,4DAA2D;AAC3D,4DAGoC;AACpC,gHAA4E;AAC5E,2DAA+C;AAC/C,8DAAsC;AACtC,sEAAoE;AACpE,mEAAkE;AAClE,iFAA+E;AAE/E,+EAAmE;AACnE,wFAAyD;AACzD,qEAAoE;AACpE,2DAAiE;AACjE,2DAAmD;AACnD,2FAAkE;AAErD,QAAA,GAAG,GAAoB,IAAA,iBAAO,GAAE,CAAC;AAC9C,MAAM,iBAAiB,GAAG,IAAA,gBAAM,GAAE,CAAC;AAE5B,KAAK,UAAU,SAAS,CAC7B,WAAwB;IAExB,MAAM,OAAO,CAAC,GAAG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AAM,EAAE,EAAE;YAC1C,WAAG,CAAC,GAAG,CAAC,MAAa,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IAML,IACE,WAAW,CAAC,OAAO;QACnB,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,MAAM;YACjC,WAAW,CAAC,OAAO,CAAC,gBAAgB,KAAK,IAAI,CAAC;QAEhD,WAAG,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,IAAA,iCAAgB,EAAC,WAAW,EAAE,WAAG,CAAC,CAAC,CAAC;IAE5D,WAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACnB,MAAM,IAAI,wBAAQ,CAChB,iBAAiB,EACjB,GAAG,EACH,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,EACnB,eAAe,CAChB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,mBAAmB,EAAE,QAAQ,EAAE,CAAC,sBAAsB,CAAC;QAC1D,WAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,kBAAkB,IAAI,kCAAY,CAAC,CAAC;IAElE,OAAO,WAAG,CAAC;AACb,CAAC","sourcesContent":["import express, { Router } from \"express\";\nimport cors from \"cors\";\nimport cookieParser from \"cookie-parser\";\nimport { getAuthRouter } from \"./modules/auth/auth.router\";\nimport {\n getPrismaModelsRouter,\n getAvailableResourcesAndRoutesRouter,\n} from \"./modules/base/base.router\";\nimport errorHandler from \"./modules/error-handler/error-handler.controller\";\nimport { rateLimit } from \"express-rate-limit\";\nimport compression from \"compression\";\nimport { handleRequestLogs } from \"./modules/base/base.middlewares\";\nimport { loadPrismaModule } from \"./utils/helpers/prisma.helpers\";\nimport { getFileUploadRouter } from \"./modules/file-upload/file-upload.router\";\nimport { ArkosConfig } from \"./types/arkos-config\";\nimport { queryParser } from \"./utils/helpers/query-parser.helpers\";\nimport deepmerge from \"./utils/helpers/deepmerge.helper\";\nimport { getSwaggerRouter } from \"./modules/swagger/swagger.router\";\nimport { loadAllModuleComponents } from \"./utils/dynamic-loader\";\nimport { AppError } from \"./exports/error-handler\";\nimport debuggerService from \"./modules/debugger/debugger.service\";\n\nexport const app: express.Express = express();\nconst knowModulesRouter = Router();\n\nexport async function bootstrap(\n arkosConfig: ArkosConfig\n): Promise<express.Express> {\n await Promise.all([\n loadPrismaModule(),\n loadAllModuleComponents(arkosConfig),\n arkosConfig?.configureApp && (await arkosConfig?.configureApp(app)),\n ]);\n\n const middlewaresConfig = arkosConfig?.middlewares;\n const disabledMiddlewares = middlewaresConfig?.disable || [];\n const replacedMiddlewares = middlewaresConfig?.replace || {};\n\n if (!disabledMiddlewares?.includes?.(\"compression\"))\n app.use(\n replacedMiddlewares.compression ||\n compression(arkosConfig?.compressionOptions)\n );\n\n if (!disabledMiddlewares?.includes?.(\"global-rate-limit\"))\n app.use(\n replacedMiddlewares.globalRateLimit ||\n rateLimit(\n deepmerge(\n {\n windowMs: 60 * 1000,\n limit: 300,\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?.globalRequestRateLimitOptions || {}\n )\n )\n );\n\n if (!disabledMiddlewares?.includes?.(\"cors\"))\n app.use(\n replacedMiddlewares.cors ||\n cors(\n arkosConfig?.cors?.customHandler\n ? arkosConfig.cors.customHandler\n : deepmerge(\n {\n origin: (\n origin: string,\n cb: (err: Error | null, allow?: boolean) => void\n ) => {\n const allowed = arkosConfig?.cors?.allowedOrigins;\n\n if (allowed === \"*\") cb(null, true);\n else if (Array.isArray(allowed))\n cb(null, !origin || allowed?.includes?.(origin));\n else if (typeof allowed === \"string\")\n cb(null, !origin || allowed === origin);\n else cb(null, false);\n },\n\n methods: [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\", \"OPTIONS\"],\n allowedHeaders: [\n \"Content-Type\",\n \"Authorization\",\n \"Connection\",\n ],\n credentials: true,\n },\n arkosConfig?.cors?.options || {}\n )\n )\n );\n\n if (!disabledMiddlewares?.includes?.(\"express-json\"))\n app.use(\n replacedMiddlewares.expressJson ||\n express.json(arkosConfig?.jsonBodyParserOptions)\n );\n\n if (!disabledMiddlewares?.includes?.(\"cookie-parser\"))\n app.use(\n replacedMiddlewares.cookieParser ||\n cookieParser(...[...(arkosConfig?.cookieParserParameters || [])])\n );\n\n if (!disabledMiddlewares?.includes?.(\"query-parser\"))\n app.use(\n replacedMiddlewares.queryParser ||\n queryParser(\n deepmerge(\n {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n },\n arkosConfig?.queryParserOptions || {}\n )\n )\n );\n\n if (!disabledMiddlewares?.includes?.(\"request-logger\"))\n app.use(replacedMiddlewares.requestLogger || handleRequestLogs);\n\n if (arkosConfig?.middlewares?.additional)\n arkosConfig.middlewares.additional.forEach((middleware) => {\n app.use(middleware);\n });\n\n app.use(debuggerService.logRequestInfo);\n\n const routersConfig = arkosConfig?.routers;\n const disabledRouters = routersConfig?.disable || [];\n const replacedRouters = routersConfig?.replace || {};\n\n if (!disabledRouters?.includes?.(\"welcome-endpoint\"))\n app.get(\n \"/api\",\n replacedRouters.welcomeEndpoint ||\n ((_, res) => {\n res.status(200).json({ message: arkosConfig.welcomeMessage });\n })\n );\n\n app.use(debuggerService.logRequestInfo);\n\n if (!disabledRouters?.includes?.(\"file-upload\")) {\n const fileUploadRouter = replacedRouters.fileUpload\n ? await replacedRouters.fileUpload(arkosConfig)\n : await getFileUploadRouter(arkosConfig);\n knowModulesRouter.use(fileUploadRouter);\n }\n\n if (\n !disabledRouters?.includes?.(\"auth-router\") &&\n arkosConfig.authentication\n ) {\n const authRouter = replacedRouters.authRouter\n ? await replacedRouters.authRouter(arkosConfig)\n : await getAuthRouter(arkosConfig);\n knowModulesRouter.use(\"/api\", authRouter);\n }\n\n if (!disabledRouters?.includes?.(\"prisma-models-router\")) {\n const modelsRouter = replacedRouters.prismaModelsRouter\n ? await replacedRouters.prismaModelsRouter(arkosConfig)\n : await getPrismaModelsRouter(arkosConfig);\n knowModulesRouter.use(\"/api\", modelsRouter);\n }\n\n app.use(knowModulesRouter);\n app.use(\"/api\", getAvailableResourcesAndRoutesRouter());\n\n if (routersConfig?.additional)\n routersConfig.additional.forEach((router) => {\n app.use(router as any);\n });\n\n /**\n * Must be last called in order to be able to get all\n * routes built using ArkosRouter\n */\n if (\n arkosConfig.swagger &&\n (process.env.ARKOS_BUILD !== \"true\" ||\n arkosConfig.swagger.enableAfterBuild === true)\n )\n app.use(\"/api\", await getSwaggerRouter(arkosConfig, app));\n\n app.use(\"*\", (req) => {\n throw new AppError(\n \"Route not found\",\n 404,\n { route: req.path },\n \"RouteNotFound\"\n );\n });\n\n if (!disabledMiddlewares?.includes?.(\"global-error-handler\"))\n app.use(replacedMiddlewares.globalErrorHandler || errorHandler);\n\n return app;\n}\n"]}
@@ -88,9 +88,8 @@ class BaseService {
88
88
  return;
89
89
  const hookName = `${hookType === "error" ? "on" : hookType}${operationType.charAt(0).toUpperCase()}${operationType.slice(1)}${hookType === "error" ? "Error" : ""}`;
90
90
  const hook = serviceHooks[hookName];
91
- if (hook && typeof hook === "function") {
91
+ if (hook)
92
92
  await service_hooks_manager_1.default.handleHook(hook, params);
93
- }
94
93
  }
95
94
  buildHookParams(args, config) {
96
95
  const context = args[args.length - 1];
@@ -1 +1 @@
1
- {"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../../../src/modules/base/base.service.ts"],"names":[],"mappings":";;;;;;AAAA,iFAIiD;AACjD,+DAAiE;AACjE,4FAA6D;AAC7D,+EAG8C;AAC9C,uEAAuE;AACvE,wEAA+C;AAgC/C,0FAAgE;AAChE,mGAAyE;AA4DzE,MAAa,WAAW;IAKtB,YAAY,SAAiB;QAarB,qBAAgB,GAAG,CAAC,MAA8B,EAAE,EAAE;YAC5D,OAAO,KAAK,EAAE,GAAG,IAAW,EAAgB,EAAE;gBAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM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AC,gBAAgB,CAAC;YAC3B,aAAa,EAAE,YAAY;YAC3B,YAAY,EAAE,YAAY;YAC1B,eAAe,EAAE,SAAS;SAC3B,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,SAA6B,EAC7B,YAAuB,EACvB,OAA4B;QAE5B,OAAO,IAAI,CAAC,2BAA2B,CAAC;YACtC,aAAa,EAAE,aAAa;YAC5B,YAAY,EAAE,QAAQ;YACtB,uBAAuB,EAAE,IAAI;YAC7B,eAAe,EAAE,SAAS;SAC3B,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,WAAW,CACf,YAAwC,EACxC,OAA4B;QAE5B,OAAO,IAAI,CAAC,2BAA2B,CAAC;YACtC,aAAa,EAAE,aAAa;YAC5B,YAAY,EAAE,QAAQ;YACtB,eAAe,EAAE,SAAS;SAC3B,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;CACF;AAlmBD,kCAkmBC","sourcesContent":["import {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { getModuleComponents } from \"../../utils/dynamic-loader\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport {\n handleRelationFieldsInBody,\n ModelGroupRelationFields,\n} from \"./utils/helpers/base.service.helpers\";\nimport { getPrismaInstance } from \"../../utils/helpers/prisma.helpers\";\nimport authService from \"../auth/auth.service\";\nimport {\n ModelDelegate,\n CreateOneData,\n CreateOneOptions,\n CreateOneResult,\n CreateManyData,\n CreateManyOptions,\n CreateManyResult,\n CountFilters,\n FindManyFilters,\n FindManyOptions,\n FindManyResult,\n FindByIdOptions,\n FindByIdResult,\n FindOneFilters,\n FindOneOptions,\n FindOneResult,\n UpdateOneFilters,\n UpdateOneData,\n UpdateOneOptions,\n UpdateOneResult,\n UpdateManyFilters,\n UpdateManyData,\n UpdateManyOptions,\n UpdateManyResult,\n DeleteOneFilters,\n DeleteOneResult,\n DeleteManyFilters,\n DeleteManyResult,\n ServiceBaseContext,\n} from \"./types/base.service.types\";\nimport serviceHooksManager from \"./utils/service-hooks-manager\";\nimport prismaSchemaParser from \"../../utils/prisma/prisma-schema-parser\";\n\n/**\n * Base service class for handling CRUD operations on a specific model.\n * This class provides standard implementation of data operations that can be extended\n *\n * by model-specific service classes.\n *\n * @class BaseService\n *\n * @usage\n *\n * **Example:** creating a simple service\n *\n * ```ts\n * import prisma from '../../utils/prisma'\n *\n * const userService = new BaseService<typeof prisma.user>(\"user\")\n * ```\n *\n * **Example:** accessing request context in hooks\n *\n * ```ts\n * class ProductService extends BaseService<Product> {\n * async beforeCreateOne(data: CreateOneData<Product>, queryOptions?: CreateOneOptions<Product>, context?: ServiceBaseContext) {\n * // Access current user from request context\n * const userId = context?.user?.id;\n * if (userId) {\n * data.createdBy = userId;\n * }\n * }\n * }\n * ```\n *\n * @see {@link https://www.arkosjs.com/docs/api-reference/the-base-service-class}\n * @see {@link https://www.arkosjs.com/docs/guide/accessing-request-context-in-services}\n *\n */\nexport interface ServiceOperationHooks {\n beforeOperation?: (params: any) => void | Promise<void>;\n afterOperation?: (result: any, params: any) => void | Promise<void>;\n beforePrisma?: (prismaArgs: any, params: any) => any | Promise<any>;\n afterPrisma?: (result: any, params: any) => any | Promise<any>;\n}\n\ninterface ServiceOperationConfig {\n operationType: string;\n prismaMethod: string;\n requiresPasswordHashing?: boolean;\n relationFieldsHandling?: string[];\n returnsFallback?: any;\n customPrismaLogic?: (\n args: any[],\n prisma: any,\n config: ServiceOperationConfig,\n context: BaseService<any>\n ) => Promise<any>;\n hooks?: ServiceOperationHooks;\n}\n\nexport class BaseService<T extends ModelDelegate = any> {\n modelName: string;\n relationFields: ModelGroupRelationFields;\n prisma: any;\n\n constructor(modelName: string) {\n this.modelName = camelCase(modelName);\n const modelFields = prismaSchemaParser.getModelRelations(modelName);\n\n this.relationFields = {\n singular:\n modelFields?.filter((field) => field.isRelation && !field.isArray) ||\n [],\n list:\n modelFields?.filter((field) => field.isRelation && field.isArray) || [],\n };\n }\n\n private executeOperation = (config: ServiceOperationConfig) => {\n return async (...args: any[]): Promise<any> => {\n const context = args[args.length - 1] as ServiceBaseContext;\n\n try {\n await this.executeHooks(\n \"before\",\n config.operationType,\n this.buildHookParams(args, config),\n context\n );\n\n if (config.hooks?.beforeOperation)\n await config.hooks.beforeOperation(\n this.buildHookParams(args, config)\n );\n\n let processedArgs = await this.processArguments(args, config);\n\n if (config.hooks?.beforePrisma) {\n processedArgs = await config.hooks.beforePrisma(\n processedArgs,\n this.buildHookParams(args, config)\n );\n }\n\n const prisma = getPrismaInstance();\n let result: any;\n\n if (config.customPrismaLogic) {\n result = await config.customPrismaLogic(\n processedArgs,\n prisma,\n config,\n this\n );\n } else {\n const prismaArgs = this.buildPrismaArgs(processedArgs, config);\n result = await (prisma[this.modelName] as T)[\n config.prismaMethod as keyof T\n ](prismaArgs);\n }\n\n if (config.hooks?.afterPrisma) {\n result = await config.hooks.afterPrisma(\n result,\n this.buildHookParams(args, config)\n );\n }\n\n await this.executeHooks(\n \"after\",\n config.operationType,\n { ...this.buildHookParams(args, config), result },\n context\n );\n\n if (config.hooks?.afterOperation) {\n await config.hooks.afterOperation(\n result,\n this.buildHookParams(args, config)\n );\n }\n\n return result;\n } catch (err: any) {\n await this.executeHooks(\n \"error\",\n config.operationType,\n { ...this.buildHookParams(args, config), error: err },\n context\n );\n if (context?.throwOnError !== false) throw err;\n return config.returnsFallback;\n }\n };\n };\n\n private executeTransactionOperation = (config: ServiceOperationConfig) => {\n return async (...args: any[]): Promise<any> => {\n const context = args[args.length - 1] as ServiceBaseContext;\n\n try {\n await this.executeHooks(\n \"before\",\n config.operationType,\n this.buildTransactionHookParams(args, config),\n context\n );\n\n const prisma = getPrismaInstance();\n const results = await this.executeTransactionLogic(\n args,\n config,\n prisma\n );\n\n await this.executeHooks(\n \"after\",\n config.operationType,\n { ...this.buildTransactionHookParams(args, config), results },\n context\n );\n return results;\n } catch (err: any) {\n await this.executeHooks(\n \"error\",\n config.operationType,\n { ...this.buildTransactionHookParams(args, config), error: err },\n context\n );\n if (context?.throwOnError !== false) throw err;\n return config.returnsFallback;\n }\n };\n };\n\n private async executeHooks(\n hookType: \"before\" | \"after\" | \"error\",\n operationType: string,\n params: any,\n context?: ServiceBaseContext\n ): Promise<void> {\n const serviceHooks = getModuleComponents(this.modelName)?.hooks;\n\n if (!serviceHooks) return;\n\n const skipCondition =\n context?.skip === hookType ||\n context?.skip === \"all\" ||\n (Array.isArray(context?.skip) && context.skip.includes(hookType));\n\n if (skipCondition) return;\n\n const hookName = `${hookType === \"error\" ? \"on\" : hookType}${operationType.charAt(0).toUpperCase()}${operationType.slice(1)}${hookType === \"error\" ? \"Error\" : \"\"}`;\n const hook = serviceHooks[hookName as keyof typeof serviceHooks];\n\n if (hook && typeof hook === \"function\") {\n await serviceHooksManager.handleHook(hook, params);\n }\n }\n\n private buildHookParams(args: any[], config: ServiceOperationConfig): any {\n const context = args[args.length - 1];\n\n switch (config.operationType) {\n case \"createOne\":\n case \"createMany\":\n return { data: args[0], queryOptions: args[1], context };\n case \"findMany\":\n return { filters: args[0], queryOptions: args[1], context };\n case \"findById\":\n return { id: args[0], queryOptions: args[1], context };\n case \"findOne\":\n return { filters: args[0], queryOptions: args[1], context };\n case \"updateOne\":\n return {\n filters: args[0],\n data: args[1],\n queryOptions: args[2],\n context,\n };\n case \"updateMany\":\n return {\n filters: args[0],\n data: args[1],\n queryOptions: args[2],\n context,\n };\n case \"deleteOne\":\n return { filters: args[0], context };\n case \"deleteMany\":\n return { filters: args[0], context };\n case \"count\":\n return { filters: args[0], context };\n default:\n return { context };\n }\n }\n\n private buildTransactionHookParams(\n args: any[],\n config: ServiceOperationConfig\n ): any {\n const context = args[args.length - 1];\n\n switch (config.operationType) {\n case \"batchUpdate\":\n return { data: args[0], queryOptions: args[1], context };\n case \"batchDelete\":\n return { batchFilters: args[0], context };\n default:\n return { context };\n }\n }\n\n private async processArguments(\n args: any[],\n config: ServiceOperationConfig\n ): Promise<any[]> {\n let processedArgs = [...args];\n\n if (config.requiresPasswordHashing) {\n const dataIndex =\n config.operationType.includes(\"update\") &&\n config.operationType !== \"updateMany\"\n ? 1\n : 0;\n const data = processedArgs[dataIndex];\n\n if (this.shouldHashPassword(data)) {\n processedArgs[dataIndex] = await this.processPasswordHashing(data);\n }\n }\n\n return processedArgs;\n }\n\n private buildPrismaArgs(args: any[], config: ServiceOperationConfig): any {\n switch (config.operationType) {\n case \"createOne\":\n case \"createMany\":\n const data = config.relationFieldsHandling\n ? handleRelationFieldsInBody(\n args[0] as Record<string, any>,\n this.relationFields,\n config.relationFieldsHandling\n )\n : args[0];\n return deepmerge({ data }, args[1] || {});\n\n case \"findMany\":\n return deepmerge({ where: args[0] }, args[1] || {});\n\n case \"findById\":\n return deepmerge({ where: { id: args[0] } }, args[1] || {});\n\n case \"findOne\":\n return deepmerge({ where: args[0] }, args[1] || {});\n\n case \"updateOne\":\n const updateData = config.relationFieldsHandling\n ? handleRelationFieldsInBody(\n args[1] as Record<string, any>,\n this.relationFields\n )\n : args[1];\n return deepmerge({ where: args[0], data: updateData }, args[2] || {});\n\n case \"updateMany\":\n const firstMerge = deepmerge({ data: args[1] }, args[2] || {});\n return deepmerge({ where: args[0] }, firstMerge);\n\n case \"deleteOne\":\n case \"deleteMany\":\n return { where: args[0] };\n\n case \"count\":\n return { where: args[0] };\n\n default:\n return {};\n }\n }\n\n private async executeTransactionLogic(\n args: any[],\n config: ServiceOperationConfig,\n prisma: any\n ): Promise<any> {\n if (config.operationType === \"batchUpdate\") {\n const dataArray = args[0];\n const queryOptions = args[1];\n\n return await prisma.$transaction(async (tx: any) => {\n const updatePromises = dataArray.map(async (data: any) => {\n let processedData = data;\n if (this.shouldHashPassword(data)) {\n processedData = await this.processPasswordHashing(data);\n }\n\n const finalPrismaQueryParams = handleRelationFieldsInBody(\n {\n batchedData: {\n ...processedData,\n apiAction: \"update\",\n },\n } as Record<string, any>,\n {\n singular: [\n {\n ...prismaSchemaParser.getField({\n type: pascalCase(this.modelName),\n })!,\n name: \"batchedData\",\n },\n ],\n list: [],\n }\n );\n\n return await (tx[this.modelName] as T).update(\n deepmerge(\n finalPrismaQueryParams.batchedData?.update,\n queryOptions || {}\n ) as { where: any; data: any }\n );\n });\n\n return await Promise.all(updatePromises);\n });\n }\n\n if (config.operationType === \"batchDelete\") {\n const batchFilters = args[0];\n\n return await prisma.$transaction(async (tx: any) => {\n const deletePromises = batchFilters.map(async (filters: any) => {\n const filtersWithRelationFieldsHandled = handleRelationFieldsInBody(\n filters as Record<string, any>,\n this.relationFields\n );\n\n return await (tx[this.modelName] as T).delete({\n where: filtersWithRelationFieldsHandled,\n });\n });\n\n return await Promise.all(deletePromises);\n });\n }\n\n throw new Error(`Unknown transaction operation: ${config.operationType}`);\n }\n\n private shouldHashPassword(data: any): boolean {\n return kebabCase(this.modelName) === \"user\" && data?.password;\n }\n\n private async processPasswordHashing(data: any): Promise<any> {\n if (Array.isArray(data)) {\n const processedArray = [];\n for (let i = 0; i < data.length; i++) {\n const curr = data[i];\n if (\n \"password\" in curr &&\n !authService.isPasswordHashed(curr.password!)\n ) {\n processedArray[i] = {\n ...curr,\n password: await authService.hashPassword(curr.password!),\n };\n } else {\n processedArray[i] = curr;\n }\n }\n return processedArray;\n } else {\n if (data.password && !authService.isPasswordHashed(data.password)) {\n return {\n ...data,\n password: await authService.hashPassword(data.password),\n };\n }\n }\n return data;\n }\n\n async createOne<TOptions extends CreateOneOptions<T>>(\n data: CreateOneData<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<CreateOneResult<T>> {\n return this.executeOperation({\n operationType: \"createOne\",\n prismaMethod: \"create\",\n requiresPasswordHashing: true,\n relationFieldsHandling: [\"delete\", \"disconnect\", \"update\"],\n returnsFallback: undefined,\n })(data, queryOptions, context);\n }\n\n async createMany<TOptions extends CreateManyOptions<T>>(\n data: CreateManyData<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<CreateManyResult<T>> {\n return this.executeOperation({\n operationType: \"createMany\",\n prismaMethod: \"createMany\",\n requiresPasswordHashing: true,\n relationFieldsHandling: [\"delete\", \"disconnect\", \"update\"],\n returnsFallback: undefined,\n customPrismaLogic: async (args, prisma, _, serviceContext) => {\n const data = args[0];\n const queryOptions = args[1];\n const dataWithRelationFieldsHandled: any[] = [];\n\n if (Array.isArray(data)) {\n for (let i = 0; i < data.length; i++) {\n let curr = data[i];\n if (\"password\" in curr && serviceContext.modelName === \"user\") {\n if (!authService.isPasswordHashed(curr.password!)) {\n curr = {\n ...curr,\n password: await authService.hashPassword(curr.password!),\n };\n }\n }\n dataWithRelationFieldsHandled[i] = handleRelationFieldsInBody(\n curr as Record<string, any>,\n serviceContext.relationFields,\n [\"delete\", \"disconnect\", \"update\"]\n );\n }\n }\n\n return await (prisma[serviceContext.modelName] as T).createMany(\n deepmerge(\n { data: dataWithRelationFieldsHandled },\n queryOptions || {}\n ) as { data: any }\n );\n },\n })(data, queryOptions, context);\n }\n\n async count(\n filters?: CountFilters<T>,\n context?: ServiceBaseContext\n ): Promise<number> {\n return this.executeOperation({\n operationType: \"count\",\n prismaMethod: \"count\",\n returnsFallback: 0,\n })(filters, context);\n }\n\n async findMany<TOptions extends FindManyOptions<T>>(\n filters?: FindManyFilters<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<FindManyResult<T, TOptions>> {\n return this.executeOperation({\n operationType: \"findMany\",\n prismaMethod: \"findMany\",\n returnsFallback: [],\n })(filters, queryOptions, context);\n }\n\n async findById<TOptions extends FindByIdOptions<T>>(\n id: string | number,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<FindByIdResult<T>> {\n return this.executeOperation({\n operationType: \"findById\",\n prismaMethod: \"findUnique\",\n returnsFallback: undefined,\n })(id, queryOptions, context);\n }\n\n async findOne<TOptions extends FindOneOptions<T>>(\n filters: FindOneFilters<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<FindOneResult<T>> {\n return this.executeOperation({\n operationType: \"findOne\",\n prismaMethod: \"findFirst\",\n returnsFallback: undefined,\n customPrismaLogic: async (args, prisma, _, serviceContext) => {\n const filters = args[0];\n const queryOptions = args[1];\n\n if (\n Object.keys(filters as Record<string, any>).length === 1 &&\n \"id\" in (filters as Record<string, any>) &&\n (filters as any).id !== \"me\"\n ) {\n return await (prisma[serviceContext.modelName] as T).findUnique(\n deepmerge({ where: filters }, queryOptions || {})\n );\n } else {\n return await (prisma[serviceContext.modelName] as T).findFirst(\n deepmerge({ where: filters }, queryOptions || {})\n );\n }\n },\n })(filters, queryOptions, context);\n }\n\n async updateOne<TOptions extends UpdateOneOptions<T>>(\n filters: UpdateOneFilters<T>,\n data: UpdateOneData<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<UpdateOneResult<T>> {\n return this.executeOperation({\n operationType: \"updateOne\",\n prismaMethod: \"update\",\n requiresPasswordHashing: true,\n relationFieldsHandling: [],\n returnsFallback: undefined,\n })(filters, data, queryOptions, context);\n }\n\n async updateMany<TOptions extends UpdateManyOptions<T>>(\n filters: UpdateManyFilters<T>,\n data: UpdateManyData<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<UpdateManyResult<T>> {\n return this.executeOperation({\n operationType: \"updateMany\",\n prismaMethod: \"updateMany\",\n requiresPasswordHashing: true,\n returnsFallback: undefined,\n customPrismaLogic: async (args, prisma, _, serviceContext) => {\n const filters = args[0];\n const data = args[1];\n const queryOptions = args[2];\n\n let processedData = data;\n if (serviceContext.modelName === \"user\" && data?.password) {\n if (!authService.isPasswordHashed(data.password)) {\n processedData = {\n ...data,\n password: await authService.hashPassword(data.password),\n };\n }\n }\n\n const firstMerge = deepmerge(\n { data: processedData },\n queryOptions || {}\n );\n return await (prisma[serviceContext.modelName] as T).updateMany(\n deepmerge({ where: filters }, firstMerge) as {\n where: any;\n data: any;\n }\n );\n },\n })(filters, data, queryOptions, context);\n }\n\n async deleteOne(\n filters: DeleteOneFilters<T>,\n context?: ServiceBaseContext\n ): Promise<DeleteOneResult<T>> {\n return this.executeOperation({\n operationType: \"deleteOne\",\n prismaMethod: \"delete\",\n returnsFallback: undefined,\n })(filters, context);\n }\n\n async deleteMany(\n filters: DeleteManyFilters<T>,\n context?: ServiceBaseContext\n ): Promise<DeleteManyResult<T>> {\n return this.executeOperation({\n operationType: \"deleteMany\",\n prismaMethod: \"deleteMany\",\n returnsFallback: undefined,\n })(filters, context);\n }\n\n async batchUpdate<TOptions extends UpdateOneOptions<T>>(\n dataArray: UpdateOneData<T>[],\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<Array<UpdateOneResult<T>>> {\n return this.executeTransactionOperation({\n operationType: \"batchUpdate\",\n prismaMethod: \"update\",\n requiresPasswordHashing: true,\n returnsFallback: undefined,\n })(dataArray, queryOptions, context);\n }\n\n async batchDelete(\n batchFilters: Array<DeleteOneFilters<T>>,\n context?: ServiceBaseContext\n ): Promise<Array<DeleteOneResult<T>>> {\n return this.executeTransactionOperation({\n operationType: \"batchDelete\",\n prismaMethod: \"delete\",\n returnsFallback: undefined,\n })(batchFilters, context);\n }\n}\n"]}
1
+ {"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../../../src/modules/base/base.service.ts"],"names":[],"mappings":";;;;;;AAAA,iFAIiD;AACjD,+DAAiE;AACjE,4FAA6D;AAC7D,+EAG8C;AAC9C,uEAAuE;AACvE,wEAA+C;AAgC/C,0FAAgE;AAChE,mGAAyE;AA4DzE,MAAa,WAAW;IAKtB,YAAY,SAAiB;QAarB,qBAAgB,GAAG,CAAC,MAA8B,EAAE,EAAE;YAC5D,OAAO,KAAK,EAAE,GAAG,IAAW,EAAgB,EAAE;gBAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAuB,CAAC;gBAE5D,IAAI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S;SAC3B,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,SAA6B,EAC7B,YAAuB,EACvB,OAA4B;QAE5B,OAAO,IAAI,CAAC,2BAA2B,CAAC;YACtC,aAAa,EAAE,aAAa;YAC5B,YAAY,EAAE,QAAQ;YACtB,uBAAuB,EAAE,IAAI;YAC7B,eAAe,EAAE,SAAS;SAC3B,CAAC,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,WAAW,CACf,YAAwC,EACxC,OAA4B;QAE5B,OAAO,IAAI,CAAC,2BAA2B,CAAC;YACtC,aAAa,EAAE,aAAa;YAC5B,YAAY,EAAE,QAAQ;YACtB,eAAe,EAAE,SAAS;SAC3B,CAAC,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;CACF;AAhmBD,kCAgmBC","sourcesContent":["import {\n camelCase,\n kebabCase,\n pascalCase,\n} from \"../../utils/helpers/change-case.helpers\";\nimport { getModuleComponents } from \"../../utils/dynamic-loader\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport {\n handleRelationFieldsInBody,\n ModelGroupRelationFields,\n} from \"./utils/helpers/base.service.helpers\";\nimport { getPrismaInstance } from \"../../utils/helpers/prisma.helpers\";\nimport authService from \"../auth/auth.service\";\nimport {\n ModelDelegate,\n CreateOneData,\n CreateOneOptions,\n CreateOneResult,\n CreateManyData,\n CreateManyOptions,\n CreateManyResult,\n CountFilters,\n FindManyFilters,\n FindManyOptions,\n FindManyResult,\n FindByIdOptions,\n FindByIdResult,\n FindOneFilters,\n FindOneOptions,\n FindOneResult,\n UpdateOneFilters,\n UpdateOneData,\n UpdateOneOptions,\n UpdateOneResult,\n UpdateManyFilters,\n UpdateManyData,\n UpdateManyOptions,\n UpdateManyResult,\n DeleteOneFilters,\n DeleteOneResult,\n DeleteManyFilters,\n DeleteManyResult,\n ServiceBaseContext,\n} from \"./types/base.service.types\";\nimport serviceHooksManager from \"./utils/service-hooks-manager\";\nimport prismaSchemaParser from \"../../utils/prisma/prisma-schema-parser\";\n\n/**\n * Base service class for handling CRUD operations on a specific model.\n * This class provides standard implementation of data operations that can be extended\n *\n * by model-specific service classes.\n *\n * @class BaseService\n *\n * @usage\n *\n * **Example:** creating a simple service\n *\n * ```ts\n * import prisma from '../../utils/prisma'\n *\n * const userService = new BaseService<typeof prisma.user>(\"user\")\n * ```\n *\n * **Example:** accessing request context in hooks\n *\n * ```ts\n * class ProductService extends BaseService<Product> {\n * async beforeCreateOne(data: CreateOneData<Product>, queryOptions?: CreateOneOptions<Product>, context?: ServiceBaseContext) {\n * // Access current user from request context\n * const userId = context?.user?.id;\n * if (userId) {\n * data.createdBy = userId;\n * }\n * }\n * }\n * ```\n *\n * @see {@link https://www.arkosjs.com/docs/api-reference/the-base-service-class}\n * @see {@link https://www.arkosjs.com/docs/guide/accessing-request-context-in-services}\n *\n */\nexport interface ServiceOperationHooks {\n beforeOperation?: (params: any) => void | Promise<void>;\n afterOperation?: (result: any, params: any) => void | Promise<void>;\n beforePrisma?: (prismaArgs: any, params: any) => any | Promise<any>;\n afterPrisma?: (result: any, params: any) => any | Promise<any>;\n}\n\ninterface ServiceOperationConfig {\n operationType: string;\n prismaMethod: string;\n requiresPasswordHashing?: boolean;\n relationFieldsHandling?: string[];\n returnsFallback?: any;\n customPrismaLogic?: (\n args: any[],\n prisma: any,\n config: ServiceOperationConfig,\n context: BaseService<any>\n ) => Promise<any>;\n hooks?: ServiceOperationHooks;\n}\n\nexport class BaseService<T extends ModelDelegate = any> {\n modelName: string;\n relationFields: ModelGroupRelationFields;\n prisma: any;\n\n constructor(modelName: string) {\n this.modelName = camelCase(modelName);\n const modelFields = prismaSchemaParser.getModelRelations(modelName);\n\n this.relationFields = {\n singular:\n modelFields?.filter((field) => field.isRelation && !field.isArray) ||\n [],\n list:\n modelFields?.filter((field) => field.isRelation && field.isArray) || [],\n };\n }\n\n private executeOperation = (config: ServiceOperationConfig) => {\n return async (...args: any[]): Promise<any> => {\n const context = args[args.length - 1] as ServiceBaseContext;\n\n try {\n await this.executeHooks(\n \"before\",\n config.operationType,\n this.buildHookParams(args, config),\n context\n );\n\n if (config.hooks?.beforeOperation)\n await config.hooks.beforeOperation(\n this.buildHookParams(args, config)\n );\n\n let processedArgs = await this.processArguments(args, config);\n\n if (config.hooks?.beforePrisma) {\n processedArgs = await config.hooks.beforePrisma(\n processedArgs,\n this.buildHookParams(args, config)\n );\n }\n\n const prisma = getPrismaInstance();\n let result: any;\n\n if (config.customPrismaLogic) {\n result = await config.customPrismaLogic(\n processedArgs,\n prisma,\n config,\n this\n );\n } else {\n const prismaArgs = this.buildPrismaArgs(processedArgs, config);\n result = await (prisma[this.modelName] as T)[\n config.prismaMethod as keyof T\n ](prismaArgs);\n }\n\n if (config.hooks?.afterPrisma) {\n result = await config.hooks.afterPrisma(\n result,\n this.buildHookParams(args, config)\n );\n }\n\n await this.executeHooks(\n \"after\",\n config.operationType,\n { ...this.buildHookParams(args, config), result },\n context\n );\n\n if (config.hooks?.afterOperation) {\n await config.hooks.afterOperation(\n result,\n this.buildHookParams(args, config)\n );\n }\n\n return result;\n } catch (err: any) {\n await this.executeHooks(\n \"error\",\n config.operationType,\n { ...this.buildHookParams(args, config), error: err },\n context\n );\n if (context?.throwOnError !== false) throw err;\n return config.returnsFallback;\n }\n };\n };\n\n private executeTransactionOperation = (config: ServiceOperationConfig) => {\n return async (...args: any[]): Promise<any> => {\n const context = args[args.length - 1] as ServiceBaseContext;\n\n try {\n await this.executeHooks(\n \"before\",\n config.operationType,\n this.buildTransactionHookParams(args, config),\n context\n );\n\n const prisma = getPrismaInstance();\n const results = await this.executeTransactionLogic(\n args,\n config,\n prisma\n );\n\n await this.executeHooks(\n \"after\",\n config.operationType,\n { ...this.buildTransactionHookParams(args, config), results },\n context\n );\n return results;\n } catch (err: any) {\n await this.executeHooks(\n \"error\",\n config.operationType,\n { ...this.buildTransactionHookParams(args, config), error: err },\n context\n );\n if (context?.throwOnError !== false) throw err;\n return config.returnsFallback;\n }\n };\n };\n\n private async executeHooks(\n hookType: \"before\" | \"after\" | \"error\",\n operationType: string,\n params: any,\n context?: ServiceBaseContext\n ): Promise<void> {\n const serviceHooks = getModuleComponents(this.modelName)?.hooks;\n\n if (!serviceHooks) return;\n\n const skipCondition =\n context?.skip === hookType ||\n context?.skip === \"all\" ||\n (Array.isArray(context?.skip) && context.skip.includes(hookType));\n\n if (skipCondition) return;\n\n const hookName = `${hookType === \"error\" ? \"on\" : hookType}${operationType.charAt(0).toUpperCase()}${operationType.slice(1)}${hookType === \"error\" ? \"Error\" : \"\"}`;\n const hook = serviceHooks[hookName as keyof typeof serviceHooks];\n\n if (hook) await serviceHooksManager.handleHook(hook, params);\n }\n\n private buildHookParams(args: any[], config: ServiceOperationConfig): any {\n const context = args[args.length - 1];\n\n switch (config.operationType) {\n case \"createOne\":\n case \"createMany\":\n return { data: args[0], queryOptions: args[1], context };\n case \"findMany\":\n return { filters: args[0], queryOptions: args[1], context };\n case \"findById\":\n return { id: args[0], queryOptions: args[1], context };\n case \"findOne\":\n return { filters: args[0], queryOptions: args[1], context };\n case \"updateOne\":\n return {\n filters: args[0],\n data: args[1],\n queryOptions: args[2],\n context,\n };\n case \"updateMany\":\n return {\n filters: args[0],\n data: args[1],\n queryOptions: args[2],\n context,\n };\n case \"deleteOne\":\n return { filters: args[0], context };\n case \"deleteMany\":\n return { filters: args[0], context };\n case \"count\":\n return { filters: args[0], context };\n default:\n return { context };\n }\n }\n\n private buildTransactionHookParams(\n args: any[],\n config: ServiceOperationConfig\n ): any {\n const context = args[args.length - 1];\n\n switch (config.operationType) {\n case \"batchUpdate\":\n return { data: args[0], queryOptions: args[1], context };\n case \"batchDelete\":\n return { batchFilters: args[0], context };\n default:\n return { context };\n }\n }\n\n private async processArguments(\n args: any[],\n config: ServiceOperationConfig\n ): Promise<any[]> {\n let processedArgs = [...args];\n\n if (config.requiresPasswordHashing) {\n const dataIndex =\n config.operationType.includes(\"update\") &&\n config.operationType !== \"updateMany\"\n ? 1\n : 0;\n const data = processedArgs[dataIndex];\n\n if (this.shouldHashPassword(data)) {\n processedArgs[dataIndex] = await this.processPasswordHashing(data);\n }\n }\n\n return processedArgs;\n }\n\n private buildPrismaArgs(args: any[], config: ServiceOperationConfig): any {\n switch (config.operationType) {\n case \"createOne\":\n case \"createMany\":\n const data = config.relationFieldsHandling\n ? handleRelationFieldsInBody(\n args[0] as Record<string, any>,\n this.relationFields,\n config.relationFieldsHandling\n )\n : args[0];\n return deepmerge({ data }, args[1] || {});\n\n case \"findMany\":\n return deepmerge({ where: args[0] }, args[1] || {});\n\n case \"findById\":\n return deepmerge({ where: { id: args[0] } }, args[1] || {});\n\n case \"findOne\":\n return deepmerge({ where: args[0] }, args[1] || {});\n\n case \"updateOne\":\n const updateData = config.relationFieldsHandling\n ? handleRelationFieldsInBody(\n args[1] as Record<string, any>,\n this.relationFields\n )\n : args[1];\n return deepmerge({ where: args[0], data: updateData }, args[2] || {});\n\n case \"updateMany\":\n const firstMerge = deepmerge({ data: args[1] }, args[2] || {});\n return deepmerge({ where: args[0] }, firstMerge);\n\n case \"deleteOne\":\n case \"deleteMany\":\n return { where: args[0] };\n\n case \"count\":\n return { where: args[0] };\n\n default:\n return {};\n }\n }\n\n private async executeTransactionLogic(\n args: any[],\n config: ServiceOperationConfig,\n prisma: any\n ): Promise<any> {\n if (config.operationType === \"batchUpdate\") {\n const dataArray = args[0];\n const queryOptions = args[1];\n\n return await prisma.$transaction(async (tx: any) => {\n const updatePromises = dataArray.map(async (data: any) => {\n let processedData = data;\n if (this.shouldHashPassword(data)) {\n processedData = await this.processPasswordHashing(data);\n }\n\n const finalPrismaQueryParams = handleRelationFieldsInBody(\n {\n batchedData: {\n ...processedData,\n apiAction: \"update\",\n },\n } as Record<string, any>,\n {\n singular: [\n {\n ...prismaSchemaParser.getField({\n type: pascalCase(this.modelName),\n })!,\n name: \"batchedData\",\n },\n ],\n list: [],\n }\n );\n\n return await (tx[this.modelName] as T).update(\n deepmerge(\n finalPrismaQueryParams.batchedData?.update,\n queryOptions || {}\n ) as { where: any; data: any }\n );\n });\n\n return await Promise.all(updatePromises);\n });\n }\n\n if (config.operationType === \"batchDelete\") {\n const batchFilters = args[0];\n\n return await prisma.$transaction(async (tx: any) => {\n const deletePromises = batchFilters.map(async (filters: any) => {\n const filtersWithRelationFieldsHandled = handleRelationFieldsInBody(\n filters as Record<string, any>,\n this.relationFields\n );\n\n return await (tx[this.modelName] as T).delete({\n where: filtersWithRelationFieldsHandled,\n });\n });\n\n return await Promise.all(deletePromises);\n });\n }\n\n throw new Error(`Unknown transaction operation: ${config.operationType}`);\n }\n\n private shouldHashPassword(data: any): boolean {\n return kebabCase(this.modelName) === \"user\" && data?.password;\n }\n\n private async processPasswordHashing(data: any): Promise<any> {\n if (Array.isArray(data)) {\n const processedArray = [];\n for (let i = 0; i < data.length; i++) {\n const curr = data[i];\n if (\n \"password\" in curr &&\n !authService.isPasswordHashed(curr.password!)\n ) {\n processedArray[i] = {\n ...curr,\n password: await authService.hashPassword(curr.password!),\n };\n } else {\n processedArray[i] = curr;\n }\n }\n return processedArray;\n } else {\n if (data.password && !authService.isPasswordHashed(data.password)) {\n return {\n ...data,\n password: await authService.hashPassword(data.password),\n };\n }\n }\n return data;\n }\n\n async createOne<TOptions extends CreateOneOptions<T>>(\n data: CreateOneData<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<CreateOneResult<T>> {\n return this.executeOperation({\n operationType: \"createOne\",\n prismaMethod: \"create\",\n requiresPasswordHashing: true,\n relationFieldsHandling: [\"delete\", \"disconnect\", \"update\"],\n returnsFallback: undefined,\n })(data, queryOptions, context);\n }\n\n async createMany<TOptions extends CreateManyOptions<T>>(\n data: CreateManyData<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<CreateManyResult<T>> {\n return this.executeOperation({\n operationType: \"createMany\",\n prismaMethod: \"createMany\",\n requiresPasswordHashing: true,\n relationFieldsHandling: [\"delete\", \"disconnect\", \"update\"],\n returnsFallback: undefined,\n customPrismaLogic: async (args, prisma, _, serviceContext) => {\n const data = args[0];\n const queryOptions = args[1];\n const dataWithRelationFieldsHandled: any[] = [];\n\n if (Array.isArray(data)) {\n for (let i = 0; i < data.length; i++) {\n let curr = data[i];\n if (\"password\" in curr && serviceContext.modelName === \"user\") {\n if (!authService.isPasswordHashed(curr.password!)) {\n curr = {\n ...curr,\n password: await authService.hashPassword(curr.password!),\n };\n }\n }\n dataWithRelationFieldsHandled[i] = handleRelationFieldsInBody(\n curr as Record<string, any>,\n serviceContext.relationFields,\n [\"delete\", \"disconnect\", \"update\"]\n );\n }\n }\n\n return await (prisma[serviceContext.modelName] as T).createMany(\n deepmerge(\n { data: dataWithRelationFieldsHandled },\n queryOptions || {}\n ) as { data: any }\n );\n },\n })(data, queryOptions, context);\n }\n\n async count(\n filters?: CountFilters<T>,\n context?: ServiceBaseContext\n ): Promise<number> {\n return this.executeOperation({\n operationType: \"count\",\n prismaMethod: \"count\",\n returnsFallback: 0,\n })(filters, context);\n }\n\n async findMany<TOptions extends FindManyOptions<T>>(\n filters?: FindManyFilters<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<FindManyResult<T, TOptions>> {\n return this.executeOperation({\n operationType: \"findMany\",\n prismaMethod: \"findMany\",\n returnsFallback: [],\n })(filters, queryOptions, context);\n }\n\n async findById<TOptions extends FindByIdOptions<T>>(\n id: string | number,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<FindByIdResult<T>> {\n return this.executeOperation({\n operationType: \"findById\",\n prismaMethod: \"findUnique\",\n returnsFallback: undefined,\n })(id, queryOptions, context);\n }\n\n async findOne<TOptions extends FindOneOptions<T>>(\n filters: FindOneFilters<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<FindOneResult<T>> {\n return this.executeOperation({\n operationType: \"findOne\",\n prismaMethod: \"findFirst\",\n returnsFallback: undefined,\n customPrismaLogic: async (args, prisma, _, serviceContext) => {\n const filters = args[0];\n const queryOptions = args[1];\n\n if (\n Object.keys(filters as Record<string, any>).length === 1 &&\n \"id\" in (filters as Record<string, any>) &&\n (filters as any).id !== \"me\"\n ) {\n return await (prisma[serviceContext.modelName] as T).findUnique(\n deepmerge({ where: filters }, queryOptions || {})\n );\n } else {\n return await (prisma[serviceContext.modelName] as T).findFirst(\n deepmerge({ where: filters }, queryOptions || {})\n );\n }\n },\n })(filters, queryOptions, context);\n }\n\n async updateOne<TOptions extends UpdateOneOptions<T>>(\n filters: UpdateOneFilters<T>,\n data: UpdateOneData<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<UpdateOneResult<T>> {\n return this.executeOperation({\n operationType: \"updateOne\",\n prismaMethod: \"update\",\n requiresPasswordHashing: true,\n relationFieldsHandling: [],\n returnsFallback: undefined,\n })(filters, data, queryOptions, context);\n }\n\n async updateMany<TOptions extends UpdateManyOptions<T>>(\n filters: UpdateManyFilters<T>,\n data: UpdateManyData<T>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<UpdateManyResult<T>> {\n return this.executeOperation({\n operationType: \"updateMany\",\n prismaMethod: \"updateMany\",\n requiresPasswordHashing: true,\n returnsFallback: undefined,\n customPrismaLogic: async (args, prisma, _, serviceContext) => {\n const filters = args[0];\n const data = args[1];\n const queryOptions = args[2];\n\n let processedData = data;\n if (serviceContext.modelName === \"user\" && data?.password) {\n if (!authService.isPasswordHashed(data.password)) {\n processedData = {\n ...data,\n password: await authService.hashPassword(data.password),\n };\n }\n }\n\n const firstMerge = deepmerge(\n { data: processedData },\n queryOptions || {}\n );\n return await (prisma[serviceContext.modelName] as T).updateMany(\n deepmerge({ where: filters }, firstMerge) as {\n where: any;\n data: any;\n }\n );\n },\n })(filters, data, queryOptions, context);\n }\n\n async deleteOne(\n filters: DeleteOneFilters<T>,\n context?: ServiceBaseContext\n ): Promise<DeleteOneResult<T>> {\n return this.executeOperation({\n operationType: \"deleteOne\",\n prismaMethod: \"delete\",\n returnsFallback: undefined,\n })(filters, context);\n }\n\n async deleteMany(\n filters: DeleteManyFilters<T>,\n context?: ServiceBaseContext\n ): Promise<DeleteManyResult<T>> {\n return this.executeOperation({\n operationType: \"deleteMany\",\n prismaMethod: \"deleteMany\",\n returnsFallback: undefined,\n })(filters, context);\n }\n\n async batchUpdate<TOptions extends UpdateOneOptions<T>>(\n dataArray: UpdateOneData<T>[],\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<Array<UpdateOneResult<T>>> {\n return this.executeTransactionOperation({\n operationType: \"batchUpdate\",\n prismaMethod: \"update\",\n requiresPasswordHashing: true,\n returnsFallback: undefined,\n })(dataArray, queryOptions, context);\n }\n\n async batchDelete(\n batchFilters: Array<DeleteOneFilters<T>>,\n context?: ServiceBaseContext\n ): Promise<Array<DeleteOneResult<T>>> {\n return this.executeTransactionOperation({\n operationType: \"batchDelete\",\n prismaMethod: \"delete\",\n returnsFallback: undefined,\n })(batchFilters, context);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\nimport nodemailer from \"nodemailer\";\nimport { ModuleComponents } from \"../utils/dynamic-loader\";\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds](https://www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?: {\n /**\n * Defines whether to use strict request validation, it means in every request using `ArkosRouter()` you must pass the validation options with all options (e.g: query, params, body, etc.).\n *\n * **How It Works:**\n * - If it is true, Arkos will require all the options a stated above on the routes and if you don't pass it will throw an error.\n * **What if you don't want to pass a validator to some options?**\n * - You will need to pass `undefined` to the validator option (see example below), this way Arkos will throw an error if something is passed to `req.query` if you passed undefined as validator into `validation.query`\n *\n * ```ts\n * import { ArkosRouter } from \"arkos\"\n *\n * const router = ArkosRouter()\n *\n * router.get({\n * route: \"/api/posts\",\n * validation: {\n * query: undefined\n * }\n * })\n *\n * ```\n */\n strict?: boolean;\n } & (\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n }\n );\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for example:\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n * \n * #### Default:\n * \n * {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n }\n * \n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n * \n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n *\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Strict mode configuration for routing security\n *\n * @default false\n * - all CRUD + Auth (if using auth) endpoits are enabled and avialable by default.\n *\n * When enabled:\n * - If `true`: All CRUD endpoints start disabled and must be explicitly enabled\n * in each model's router configuration\n * - If `'no-bulk'`: Bulk operations (createMany, updateMany, deleteMany) are disabled\n * by default, while individual operations can be enabled per model\n *\n * This provides enhanced security by ensuring no routes are accidentally exposed.\n * Use this in production environments to follow the principle of least privilege.\n *\n * See documentation: https://www.arkosjs.com/docs/guide/security#strict-mode\n */\n strict?: boolean | \"no-bulk\";\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n } & Parameters<typeof nodemailer.createTransport>[0];\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict?: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n /**\n * Helps in debugging some of the variables values that are used inside arkos from dynamic loaded components towhat is used into the generated api.\n *\n */\n debugging?: {\n /**\n * Controls debugging over HTTP request level\n */\n requests?: {\n level?: 0 | 1 | 2 | 3;\n filter?: (\n | \"Query\"\n | \"Body\"\n | \"Params\"\n | \"TransformedQuery\"\n | \"ServiceArgs\"\n | \"FinalPrismaQueryArgs\"\n )[];\n };\n /**\n * Controls debugging over the dynamic loaded modules and it's components on app starting\n */\n dynamicLoader?: {\n /**\n * Adjusts logging details\n *\n * 1 - Loaded modules and list of it's components files\n * 2 - All from 1 and detailed inspection per module component\n * 3 - All from 1 and 2, plus the final router component after merged with autho generated router.\n */\n level?: 0 | 1 | 2 | 3;\n filters?: {\n /**\n * Allows filtering by specific modules.\n *\n * Supports only searching for the starting parts of the module name, e.g: If there is`user-profile`, `user`, `posts`, passing `[\"user\"]` will match both `user-profile` and `user`.\n */\n modules?: string[];\n /**\n * Allows filtering by component's names\n */\n components?: keyof ModuleComponents[];\n };\n };\n };\n};\n"]}
1
+ {"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\nimport nodemailer from \"nodemailer\";\nimport { ModuleComponents } from \"../utils/dynamic-loader\";\nimport { IArkosRouter } from \"../utils/arkos-router/types\";\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds](https://www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?: {\n /**\n * Defines whether to use strict request validation, it means in every request using `ArkosRouter()` you must pass the validation options with all options (e.g: query, params, body, etc.).\n *\n * **How It Works:**\n * - If it is true, Arkos will require all the options a stated above on the routes and if you don't pass it will throw an error.\n * **What if you don't want to pass a validator to some options?**\n * - You will need to pass `undefined` to the validator option (see example below), this way Arkos will throw an error if something is passed to `req.query` if you passed undefined as validator into `validation.query`\n *\n * ```ts\n * import { ArkosRouter } from \"arkos\"\n *\n * const router = ArkosRouter()\n *\n * router.get({\n * route: \"/api/posts\",\n * validation: {\n * query: undefined\n * }\n * })\n *\n * ```\n */\n strict?: boolean;\n } & (\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n }\n );\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for example:\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n * \n * #### Default:\n * \n * {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n }\n * \n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n * \n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n *\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Strict mode configuration for routing security\n *\n * @default false\n * - all CRUD + Auth (if using auth) endpoits are enabled and avialable by default.\n *\n * When enabled:\n * - If `true`: All CRUD endpoints start disabled and must be explicitly enabled\n * in each model's router configuration\n * - If `'no-bulk'`: Bulk operations (createMany, updateMany, deleteMany) are disabled\n * by default, while individual operations can be enabled per model\n *\n * This provides enhanced security by ensuring no routes are accidentally exposed.\n * Use this in production environments to follow the principle of least privilege.\n *\n * See documentation: https://www.arkosjs.com/docs/guide/security#strict-mode\n */\n strict?: boolean | \"no-bulk\";\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[] | IArkosRouter[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n } & Parameters<typeof nodemailer.createTransport>[0];\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict?: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n /**\n * Helps in debugging some of the variables values that are used inside arkos from dynamic loaded components towhat is used into the generated api.\n *\n */\n debugging?: {\n /**\n * Controls debugging over HTTP request level\n */\n requests?: {\n level?: 0 | 1 | 2 | 3;\n filter?: (\n | \"Query\"\n | \"Body\"\n | \"Params\"\n | \"TransformedQuery\"\n | \"ServiceArgs\"\n | \"FinalPrismaQueryArgs\"\n )[];\n };\n /**\n * Controls debugging over the dynamic loaded modules and it's components on app starting\n */\n dynamicLoader?: {\n /**\n * Adjusts logging details\n *\n * 1 - Loaded modules and list of it's components files\n * 2 - All from 1 and detailed inspection per module component\n * 3 - All from 1 and 2, plus the final router component after merged with autho generated router.\n */\n level?: 0 | 1 | 2 | 3;\n filters?: {\n /**\n * Allows filtering by specific modules.\n *\n * Supports only searching for the starting parts of the module name, e.g: If there is`user-profile`, `user`, `posts`, passing `[\"user\"]` will match both `user-profile` and `user`.\n */\n modules?: string[];\n /**\n * Allows filtering by component's names\n */\n components?: keyof ModuleComponents[];\n };\n };\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/arkos-router/types/index.ts"],"names":[],"mappings":"","sourcesContent":["import { IRouter } from \"express\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport { ZodSchema } from \"zod\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport { AccessControlRules } from \"../../../types/auth\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../../types\";\nimport { CorsOptions } from \"cors\";\nimport express from \"express\";\n\ntype MethodHandler = (\n config: ArkosRouteConfig,\n ...handlers: (ArkosRequestHandler | ArkosErrorRequestHandler)[]\n) => IArkosRouter;\n\nexport interface IArkosRouter\n extends Omit<\n IRouter,\n | \"get\"\n | \"post\"\n | \"put\"\n | \"patch\"\n | \"delete\"\n | \"options\"\n | \"head\"\n | \"trace\"\n | \"all\"\n > {\n get: MethodHandler;\n post: MethodHandler;\n put: MethodHandler;\n patch: MethodHandler;\n delete: MethodHandler;\n options: MethodHandler;\n head: MethodHandler;\n trace: MethodHandler;\n all: MethodHandler;\n}\n\nexport interface ArkosRouteConfig {\n route: string;\n authentication?:\n | boolean\n | {\n resource: string;\n action: string;\n rule?: AccessControlRules;\n };\n validation?:\n | false\n | {\n query?: ZodSchema | (new (...args: any[]) => object) | false;\n body?: ZodSchema | (new (...args: any[]) => object) | false;\n params?: ZodSchema | (new (...args: any[]) => object) | false;\n };\n openapi?: boolean | Partial<OpenAPIV3.OperationObject>;\n rateLimit?: Partial<RateLimitOptions>;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: CorsOptions;\n };\n /**\n * Configuration for request body parsing.\n *\n * @property {(\"json\" | \"urlencoded\" | \"raw\" | \"text\")} parser - The type of body parser to use.\n * @property {object} [options] - Parser-specific options passed to the corresponding Express body parser middleware.\n *\n * @remarks\n * - When `parser` is `\"json\"`, options are passed to `express.json()`.\n * - When `parser` is `\"urlencoded\"`, options are passed to `express.urlencoded()`.\n * - When `parser` is `\"raw\"`, options are passed to `express.raw()`.\n * - When `parser` is `\"text\"`, options are passed to `express.text()`.\n * - Set to `false` to disable body parsing for this route.\n *\n * See https://expressjs.com/en/api.html#express.json\n */\n bodyParser?:\n | { parser: \"json\"; options?: Parameters<typeof express.json>[0] }\n | {\n parser: \"urlencoded\";\n options?: Parameters<typeof express.urlencoded>[0];\n }\n | { parser: \"raw\"; options?: Parameters<typeof express.raw>[0] }\n | { parser: \"text\"; options?: Parameters<typeof express.text>[0] }\n | false;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/arkos-router/types/index.ts"],"names":[],"mappings":"","sourcesContent":["import { IRouter } from \"express\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport { ZodSchema } from \"zod\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport { AccessControlRules } from \"../../../types/auth\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../../types\";\nimport { CorsOptions } from \"cors\";\nimport express from \"express\";\n\ntype MethodHandler = (\n config: ArkosRouteConfig,\n ...handlers: (ArkosRequestHandler | ArkosErrorRequestHandler)[]\n) => IRouter;\n\nexport interface IArkosRouter\n extends Omit<\n IRouter,\n | \"get\"\n | \"post\"\n | \"put\"\n | \"patch\"\n | \"delete\"\n | \"options\"\n | \"head\"\n | \"trace\"\n | \"all\"\n > {\n get: MethodHandler;\n post: MethodHandler;\n put: MethodHandler;\n patch: MethodHandler;\n delete: MethodHandler;\n options: MethodHandler;\n head: MethodHandler;\n trace: MethodHandler;\n all: MethodHandler;\n}\n\nexport interface ArkosRouteConfig {\n route: string;\n authentication?:\n | boolean\n | {\n resource: string;\n action: string;\n rule?: AccessControlRules;\n };\n validation?:\n | false\n | {\n query?: ZodSchema | (new (...args: any[]) => object) | false;\n body?: ZodSchema | (new (...args: any[]) => object) | false;\n params?: ZodSchema | (new (...args: any[]) => object) | false;\n };\n openapi?: boolean | Partial<OpenAPIV3.OperationObject>;\n rateLimit?: Partial<RateLimitOptions>;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: CorsOptions;\n };\n /**\n * Configuration for request body parsing.\n *\n * @property {(\"json\" | \"urlencoded\" | \"raw\" | \"text\")} parser - The type of body parser to use.\n * @property {object} [options] - Parser-specific options passed to the corresponding Express body parser middleware.\n *\n * @remarks\n * - When `parser` is `\"json\"`, options are passed to `express.json()`.\n * - When `parser` is `\"urlencoded\"`, options are passed to `express.urlencoded()`.\n * - When `parser` is `\"raw\"`, options are passed to `express.raw()`.\n * - When `parser` is `\"text\"`, options are passed to `express.text()`.\n * - Set to `false` to disable body parsing for this route.\n *\n * See https://expressjs.com/en/api.html#express.json\n */\n bodyParser?:\n | { parser: \"json\"; options?: Parameters<typeof express.json>[0] }\n | {\n parser: \"urlencoded\";\n options?: Parameters<typeof express.urlencoded>[0];\n }\n | { parser: \"raw\"; options?: Parameters<typeof express.raw>[0] }\n | { parser: \"text\"; options?: Parameters<typeof express.text>[0] }\n | false;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/utils/arkos-router/utils/helpers/index.ts"],"names":[],"mappings":";;;;;AAQA,gDA+DC;AAED,gDAiCC;AAzGD,2DAA2D;AAC3D,gFAAkF;AAClF,wFAA8D;AAG9D,sDAA8B;AAE9B,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,WAAW,GAAG,+BAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;wBAE5D,IAAI,WAAW,EAAE,CAAC;4BAChB,MAAM,GAAG,WAAW,CAAC;4BACrB,MAAM,CAAC,IAAI,CAAC;gCACV,IAAI,EAAE,QAAQ;gCACd,MAAM,EAAE,MAAM,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cAAc,CAAC,MAAM;QAC5B,MAAM,CAAC,cAAc,CAAC,QAAQ;QAE9B,WAAW,CAAC,IAAI,CACd,sBAAW,CAAC,mBAAmB,CAC7B,MAAM,CAAC,cAAc,CAAC,MAAM,EAC5B,MAAM,CAAC,cAAc,CAAC,QAAQ,EAC9B,MAAM,CAAC,cAAc,EAAE,IAAI,CAC5B,CACF,CAAC;IAMJ,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,WAAW,CAAC,IAAI,CAAC,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC;IAEhD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import rateLimit from \"express-rate-limit\";\nimport { authService } from \"../../../../exports/services\";\nimport { validateRequestInputs } from \"../../../../modules/base/base.middlewares\";\nimport RouteConfigRegistry from \"../../route-config-registry\";\nimport { ArkosRouteConfig } from \"../../types\";\nimport cors from \"cors\";\nimport express from \"express\";\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?.rule\n )\n );\n\n // if (config.rateLimit) middlewares.push(rateLimit(config.rateLimit));\n\n // if (config.cors) middlewares.push(cors(config.cors.options));\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 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":";;;;;AAMA,gDA+DC;AAED,gDAiCC;AAxGD,2DAA2D;AAC3D,gFAAkF;AAClF,wFAA8D;AAE9D,sDAA8B;AAE9B,SAAgB,kBAAkB,CAChC,GAAQ,EACR,QAAQ,GAAG,EAAE;IAMb,MAAM,MAAM,GAIP,EAAE,CAAC;IAER,SAAS,gBAAgB,CAAC,KAAY,EAAE,MAAM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O,CAAC,CAC7D,CAAC;IAEJ,WAAW,CAAC,IAAI,CAAC,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,CAAC;IAEhD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { authService } from \"../../../../exports/services\";\nimport { validateRequestInputs } from \"../../../../modules/base/base.middlewares\";\nimport RouteConfigRegistry from \"../../route-config-registry\";\nimport { ArkosRouteConfig } from \"../../types\";\nimport express from \"express\";\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?.rule\n )\n );\n\n // if (config.rateLimit) middlewares.push(rateLimit(config.rateLimit));\n\n // if (config.cors) middlewares.push(cors(config.cors.options));\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 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.26";
22
+ return "1.4.0-canary.28";
23
23
  }
24
24
  //# sourceMappingURL=cli.helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sheu.js","sourceRoot":"","sources":["../../../src/utils/sheu.ts"],"names":[],"mappings":";;AAGA,MAAM,IAAI;IAIA,YAAY;QAClB,OAAO,IAAI,IAAI,EAAE,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAKO,UAAU,CAChB,UAAe,EAAE,EACjB,UAII,EAAE;QAEN,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK;YAC1B,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,OAAO,EAAE,KAAK,GAAG,GAAG;gBACtB,CAAC,CAAC,OAAO,KAAK,IAAI;oBAChB,CAAC,CAAC,OAAO,EAAE,KAAK,GAAG,GAAG;oBACtB,CAAC,CAAC,OAAO,EAAE,KAAK;YACpB,CAAC,CAAC,EAAE,CAAC;QACP,IAAI,MAAM,GAAG,GAAG,KAAK,GAAG,OAAO,EAAE,CAAC;QAGlC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;Y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,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;IAKD,IAAI,CACF,OAAY,EACZ,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,OAAY,EACZ,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,KAAK,CACH,OAAY,EACZ,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,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,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 content: any = \"\",\n options: {\n timestamp?: boolean | string;\n bold?: boolean;\n label?: string;\n } = {}\n ): string {\n const label = options?.label\n ? content\n ? options?.label + \" \"\n : content === null\n ? options?.label + \" \"\n : options?.label\n : \"\";\n let result = `${label}${content}`;\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 ${content}`;\n else if (typeof options.timestamp === \"string\") {\n const colorCode = this.getColorCode(options.timestamp);\n result = `${label}${colorCode}${timestamp}\\x1b[0m ${content}`;\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 content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[31m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Blue color\n */\n blue(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[34m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Green color\n */\n green(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[32m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Yellow color\n */\n yellow(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[33m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Cyan color\n */\n cyan(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[36m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Magenta color\n */\n magenta(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[35m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * White color\n */\n white(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[37m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Black color\n */\n black(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[30m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Gray color\n */\n gray(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[90m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Orange color\n */\n orange(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[91m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Bold text formatting\n */\n bold(content: any, options?: { timestamp?: boolean | string }): string {\n return this.formatText(content, { ...options, bold: true });\n }\n\n /**\n * Info label with cyan color [INFO]\n */\n info(\n message: any,\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 * Simple Log with no label\n */\n print(\n message: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const result = this.formatText(message, { ...options });\n console.info(result);\n return result;\n }\n\n /**\n * Error label with red color [ERROR]\n */\n error(\n message: any,\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[32m✓\\x1b[0m`;\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: any,\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: any,\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 /**\n * Debug label with magenta color [DEBUG]\n */\n debug(\n message: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[35mDebug\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.debug(result);\n return result;\n }\n}\n\nconst sheu = new Sheu();\n\nexport default sheu;\n"]}
1
+ {"version":3,"file":"sheu.js","sourceRoot":"","sources":["../../../src/utils/sheu.ts"],"names":[],"mappings":";;AAGA,MAAM,IAAI;IAIA,YAAY;QAClB,OAAO,IAAI,IAAI,EAAE,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAKO,UAAU,CAChB,UAAe,EAAE,EACjB,UAII,EAAE;QAEN,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK;YAC1B,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,OAAO,EAAE,KAAK,GAAG,GAAG;gBACtB,CAAC,CAAC,OAAO,KAAK,IAAI;oBAChB,CAAC,CAAC,OAAO,EAAE,KAAK,GAAG,GAAG;oBACtB,CAAC,CAAC,OAAO,E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B,CAAC;IAKD,KAAK,CACH,OAAe,EACf,OAA0D;QAG1D,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,OAAY,EACZ,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,OAAY,EACZ,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,KAAK,CACH,OAAY,EACZ,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,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,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 content: any = \"\",\n options: {\n timestamp?: boolean | string;\n bold?: boolean;\n label?: string;\n } = {}\n ): string {\n const label = options?.label\n ? content\n ? options?.label + \" \"\n : content === null\n ? options?.label + \" \"\n : options?.label\n : \"\";\n let result = `${label}${content}`;\n\n if (options.timestamp) {\n const timestamp = this.getTimestamp();\n if (options.timestamp === true)\n result = `${label}\\x1b[90m${timestamp}\\x1b[0m ${content}`;\n else if (typeof options.timestamp === \"string\") {\n const colorCode = this.getColorCode(options.timestamp);\n result = `${label}${colorCode}${timestamp}\\x1b[0m ${content}`;\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 content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[31m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Blue color\n */\n blue(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[34m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Green color\n */\n green(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[32m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Yellow color\n */\n yellow(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[33m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Cyan color\n */\n cyan(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[36m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Magenta color\n */\n magenta(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[35m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * White color\n */\n white(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[37m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Black color\n */\n black(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[30m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Gray color\n */\n gray(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[90m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Orange color\n */\n orange(\n content: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const coloredText = `\\x1b[91m${content}\\x1b[0m`;\n return this.formatText(coloredText, options || {});\n }\n\n /**\n * Bold text formatting\n */\n bold(content: any, options?: { timestamp?: boolean | string }): string {\n return this.formatText(content, { ...options, bold: true });\n }\n\n /**\n * Info label with cyan color [INFO]\n */\n info(\n message: any,\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 * Simple Log with no label\n */\n print(\n message: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const result = this.formatText(message, { ...options });\n console.info(result);\n return result;\n }\n\n /**\n * Error label with red color [ERROR]\n */\n error(\n message: any,\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[32m✓\\x1b[0m`;\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: any,\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: any,\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 /**\n * Debug label with magenta color [DEBUG]\n */\n debug(\n message: any,\n options?: { timestamp?: boolean | string; bold?: boolean }\n ): string {\n const label = `[\\x1b[35mDebug\\x1b[0m]`;\n const result = this.formatText(message, { ...options, label });\n console.debug(result);\n return result;\n }\n}\n\nconst sheu = new Sheu();\n\nexport default sheu;\n"]}
package/dist/esm/app.js CHANGED
@@ -116,16 +116,16 @@ export async function bootstrap(arkosConfig) {
116
116
  }
117
117
  app.use(knowModulesRouter);
118
118
  app.use("/api", getAvailableResourcesAndRoutesRouter());
119
- if (arkosConfig.swagger &&
120
- (process.env.ARKOS_BUILD !== "true" ||
121
- arkosConfig.swagger.enableAfterBuild === true))
122
- app.use("/api", await getSwaggerRouter(arkosConfig, app));
123
119
  if (routersConfig?.additional)
124
120
  routersConfig.additional.forEach((router) => {
125
121
  app.use(router);
126
122
  });
123
+ if (arkosConfig.swagger &&
124
+ (process.env.ARKOS_BUILD !== "true" ||
125
+ arkosConfig.swagger.enableAfterBuild === true))
126
+ app.use("/api", await getSwaggerRouter(arkosConfig, app));
127
127
  app.use("*", (req) => {
128
- throw new AppError("Route not found", 404, { route: req.route }, "RouteNotFound");
128
+ throw new AppError("Route not found", 404, { route: req.path }, "RouteNotFound");
129
129
  });
130
130
  if (!disabledMiddlewares?.includes?.("global-error-handler"))
131
131
  app.use(replacedMiddlewares.globalErrorHandler || errorHandler);