@scpxl/nodejs-framework 1.0.20 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +719 -66
  3. package/dist/application/base-application.d.ts.map +1 -1
  4. package/dist/application/base-application.interface.d.ts +1 -0
  5. package/dist/application/base-application.interface.d.ts.map +1 -1
  6. package/dist/application/base-application.js +4 -1
  7. package/dist/application/base-application.js.map +2 -2
  8. package/dist/application/command-application.d.ts.map +1 -1
  9. package/dist/application/command-application.js.map +2 -2
  10. package/dist/application/web-application.d.ts.map +1 -1
  11. package/dist/application/web-application.js +2 -0
  12. package/dist/application/web-application.js.map +2 -2
  13. package/dist/cli/index.d.ts +2 -0
  14. package/dist/cli/index.d.ts.map +1 -0
  15. package/dist/cli/index.js +5655 -0
  16. package/dist/cli/index.js.map +7 -0
  17. package/dist/command/command.d.ts +1 -1
  18. package/dist/command/command.d.ts.map +1 -1
  19. package/dist/command/command.js.map +1 -1
  20. package/dist/config/schema.d.ts +40 -16
  21. package/dist/config/schema.d.ts.map +1 -1
  22. package/dist/config/schema.js +17 -7
  23. package/dist/config/schema.js.map +2 -2
  24. package/dist/event/manager.d.ts +2 -2
  25. package/dist/event/manager.d.ts.map +1 -1
  26. package/dist/event/manager.interface.d.ts +4 -1
  27. package/dist/event/manager.interface.d.ts.map +1 -1
  28. package/dist/event/manager.js.map +2 -2
  29. package/dist/lifecycle/lifecycle-manager.d.ts +1 -1
  30. package/dist/lifecycle/lifecycle-manager.d.ts.map +1 -1
  31. package/dist/lifecycle/lifecycle-manager.js +6 -11
  32. package/dist/lifecycle/lifecycle-manager.js.map +2 -2
  33. package/dist/logger/logger.d.ts +4 -0
  34. package/dist/logger/logger.d.ts.map +1 -1
  35. package/dist/logger/logger.js +29 -2
  36. package/dist/logger/logger.js.map +2 -2
  37. package/dist/queue/index.d.ts +1 -1
  38. package/dist/queue/index.d.ts.map +1 -1
  39. package/dist/queue/index.js.map +1 -1
  40. package/dist/queue/job.interface.d.ts +4 -3
  41. package/dist/queue/job.interface.d.ts.map +1 -1
  42. package/dist/queue/manager.d.ts +14 -6
  43. package/dist/queue/manager.d.ts.map +1 -1
  44. package/dist/queue/manager.js +24 -12
  45. package/dist/queue/manager.js.map +2 -2
  46. package/dist/queue/processor/base.d.ts +6 -5
  47. package/dist/queue/processor/base.d.ts.map +1 -1
  48. package/dist/queue/processor/base.js.map +2 -2
  49. package/dist/queue/processor/processor.interface.d.ts +4 -3
  50. package/dist/queue/processor/processor.interface.d.ts.map +1 -1
  51. package/dist/redis/manager.d.ts.map +1 -1
  52. package/dist/redis/manager.js +13 -14
  53. package/dist/redis/manager.js.map +2 -2
  54. package/dist/services/aws/s3.js.map +2 -2
  55. package/dist/util/helper.d.ts +9 -10
  56. package/dist/util/helper.d.ts.map +1 -1
  57. package/dist/util/helper.js +73 -11
  58. package/dist/util/helper.js.map +2 -2
  59. package/dist/util/loader.d.ts +8 -6
  60. package/dist/util/loader.d.ts.map +1 -1
  61. package/dist/util/loader.js +5 -2
  62. package/dist/util/loader.js.map +2 -2
  63. package/dist/util/timing.interface.d.ts +1 -1
  64. package/dist/util/timing.interface.d.ts.map +1 -1
  65. package/dist/webserver/controller/base.d.ts +9 -9
  66. package/dist/webserver/controller/base.d.ts.map +1 -1
  67. package/dist/webserver/controller/base.interface.d.ts +12 -9
  68. package/dist/webserver/controller/base.interface.d.ts.map +1 -1
  69. package/dist/webserver/controller/base.js.map +2 -2
  70. package/dist/webserver/define-action.d.ts +26 -0
  71. package/dist/webserver/define-action.d.ts.map +1 -0
  72. package/dist/webserver/define-action.js +16 -0
  73. package/dist/webserver/define-action.js.map +7 -0
  74. package/dist/webserver/define-route.d.ts +53 -0
  75. package/dist/webserver/define-route.d.ts.map +1 -0
  76. package/dist/webserver/define-route.js +27 -0
  77. package/dist/webserver/define-route.js.map +7 -0
  78. package/dist/webserver/index.d.ts +4 -2
  79. package/dist/webserver/index.d.ts.map +1 -1
  80. package/dist/webserver/index.js +4 -0
  81. package/dist/webserver/index.js.map +2 -2
  82. package/dist/webserver/util.d.ts.map +1 -1
  83. package/dist/webserver/util.js +5 -2
  84. package/dist/webserver/util.js.map +2 -2
  85. package/dist/webserver/webserver.d.ts +20 -6
  86. package/dist/webserver/webserver.d.ts.map +1 -1
  87. package/dist/webserver/webserver.interface.d.ts +30 -4
  88. package/dist/webserver/webserver.interface.d.ts.map +1 -1
  89. package/dist/webserver/webserver.interface.js.map +2 -2
  90. package/dist/webserver/webserver.js +209 -57
  91. package/dist/webserver/webserver.js.map +2 -2
  92. package/dist/websocket/websocket-base.d.ts +6 -2
  93. package/dist/websocket/websocket-base.d.ts.map +1 -1
  94. package/dist/websocket/websocket-base.js.map +2 -2
  95. package/dist/websocket/websocket-client.js.map +1 -1
  96. package/dist/websocket/websocket-server.d.ts.map +1 -1
  97. package/dist/websocket/websocket-server.js +38 -14
  98. package/dist/websocket/websocket-server.js.map +2 -2
  99. package/dist/websocket/websocket.interface.d.ts +9 -4
  100. package/dist/websocket/websocket.interface.d.ts.map +1 -1
  101. package/dist/websocket/websocket.interface.js.map +2 -2
  102. package/package.json +14 -13
  103. package/pxl.js +0 -4
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/webserver/controller/base.ts"],
4
- "sourcesContent": ["import { StatusCodes } from 'http-status-codes';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport type { DatabaseInstance } from '../../database/index.js';\nimport type { RedisInstance } from '../../redis/index.js';\nimport type { QueueManager } from '../../queue/index.js';\nimport type { ApiError, ApiResponse, WebServerBaseControllerConstructorParams } from './base.interface.js';\nimport { Logger } from '../../logger/index.js';\nimport type { ApplicationConfig } from '../../application/base-application.interface.js';\nimport type EventManager from '../../event/manager.js';\nimport cluster from 'cluster';\nimport type { WebServerOptions } from '../webserver.interface.js';\nimport type { LifecycleManager } from '../../lifecycle/lifecycle-manager.js';\nimport Jwt from '../../auth/jwt.js';\n\nexport interface AuthenticatedUser {\n userId: number;\n payload: any;\n}\n\nexport default abstract class BaseController {\n protected workerId: number | undefined;\n\n protected applicationConfig: ApplicationConfig;\n protected webServerOptions: WebServerOptions;\n\n protected redisInstance: RedisInstance;\n protected queueManager: QueueManager;\n protected eventManager: EventManager;\n protected databaseInstance: DatabaseInstance;\n protected lifecycleManager: LifecycleManager;\n\n constructor({\n applicationConfig,\n webServerOptions,\n redisInstance,\n queueManager,\n eventManager,\n databaseInstance,\n lifecycleManager,\n }: WebServerBaseControllerConstructorParams) {\n this.workerId = cluster.worker?.id;\n\n this.applicationConfig = applicationConfig;\n this.webServerOptions = webServerOptions;\n\n this.redisInstance = redisInstance;\n this.queueManager = queueManager;\n this.eventManager = eventManager;\n this.databaseInstance = databaseInstance;\n this.lifecycleManager = lifecycleManager;\n }\n\n protected sendSuccessResponse<T = any>({\n reply,\n data,\n statusCode = StatusCodes.OK,\n meta,\n }: {\n reply: FastifyReply;\n data: T;\n statusCode?: StatusCodes;\n meta?: ApiResponse<T>['meta'];\n }) {\n const response: ApiResponse<T> = {\n data,\n meta: {\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n ...meta,\n },\n };\n reply.status(statusCode).send(response);\n }\n\n protected sendNotFoundResponse(reply: FastifyReply, message: string = 'Resource not found') {\n const error: ApiError = {\n message,\n type: 'not_found',\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n };\n const response: ApiResponse = { error };\n reply.status(StatusCodes.NOT_FOUND).send(response);\n }\n\n protected sendErrorResponse({\n reply,\n error,\n statusCode = StatusCodes.BAD_REQUEST,\n errorType,\n }: {\n reply: FastifyReply;\n error: unknown;\n statusCode?: StatusCodes;\n errorType?: ApiError['type'];\n }) {\n let publicErrorMessage: string;\n let errorDetails: any = undefined;\n\n if (this.webServerOptions.errors?.verbose === true) {\n if (error instanceof Error) {\n publicErrorMessage = error.stack ?? error.message;\n errorDetails = { stack: error.stack, name: error.name };\n } else {\n publicErrorMessage = String(error);\n }\n } else {\n if (process.env.NODE_ENV === 'production') {\n if (error instanceof Error) {\n publicErrorMessage = 'Something went wrong';\n } else if (typeof error === 'string') {\n publicErrorMessage = error;\n } else {\n publicErrorMessage = 'An unknown error occurred';\n }\n } else {\n if (error instanceof Error) {\n publicErrorMessage = error.stack ?? error.message;\n errorDetails = { stack: error.stack, name: error.name };\n } else {\n publicErrorMessage = String(error);\n }\n }\n }\n\n Logger.custom({ level: 'webServer', message: error });\n console.error(error);\n\n const apiError: ApiError = {\n message: publicErrorMessage,\n type: errorType ?? this.getErrorType(statusCode),\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n ...(errorDetails && { details: errorDetails }),\n };\n\n const response: ApiResponse = { error: apiError };\n reply.status(statusCode).send(response);\n }\n\n private getErrorType(statusCode: StatusCodes): ApiError['type'] {\n switch (statusCode) {\n case StatusCodes.UNAUTHORIZED:\n return 'authentication';\n case StatusCodes.FORBIDDEN:\n return 'authorization';\n case StatusCodes.NOT_FOUND:\n return 'not_found';\n case StatusCodes.BAD_REQUEST:\n case StatusCodes.UNPROCESSABLE_ENTITY:\n return 'validation';\n case StatusCodes.INTERNAL_SERVER_ERROR:\n case StatusCodes.BAD_GATEWAY:\n case StatusCodes.SERVICE_UNAVAILABLE:\n return 'server_error';\n default:\n return 'client_error';\n }\n }\n\n protected async authenticateRequest(request: FastifyRequest, reply: FastifyReply): Promise<AuthenticatedUser | null> {\n // Get JWT secret key from application config\n const jwtSecretKey = this.applicationConfig.auth?.jwtSecretKey;\n\n if (!jwtSecretKey) {\n this.sendErrorResponse({\n reply,\n error: 'Authentication not configured.',\n statusCode: StatusCodes.INTERNAL_SERVER_ERROR,\n errorType: 'server_error',\n });\n return null;\n }\n\n const authHeader = request.headers.authorization;\n\n if (!authHeader) {\n this.sendErrorResponse({\n reply,\n error: 'No token provided.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n if (!authHeader.startsWith('Bearer ')) {\n this.sendErrorResponse({\n reply,\n error: 'Invalid token.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n try {\n const importedJwtSecretKey = await Jwt.importJwtSecretKey({\n jwtSecretKey,\n });\n\n // Remove \"Bearer \" from token\n const jwtAccessToken = authHeader.substring(7);\n\n const { payload } = await Jwt.jwtVerify(jwtAccessToken, importedJwtSecretKey);\n\n if (!payload.sub) {\n this.sendErrorResponse({\n reply,\n error: 'Invalid token payload.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n const userId = parseInt(payload.sub);\n\n return {\n userId,\n payload,\n };\n } catch {\n this.sendErrorResponse({\n reply,\n error: 'Invalid or expired token.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n }\n}\n"],
5
- "mappings": ";;AAAA,SAAS,mBAAmB;AAM5B,SAAS,cAAc;AAGvB,OAAO,aAAa;AAGpB,OAAO,SAAS;AAOhB,MAAO,eAAsC;AAAA,EAnB7C,OAmB6C;AAAA;AAAA;AAAA,EACjC;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEV,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAA6C;AAC3C,SAAK,WAAW,QAAQ,QAAQ;AAEhC,SAAK,oBAAoB;AACzB,SAAK,mBAAmB;AAExB,SAAK,gBAAgB;AACrB,SAAK,eAAe;AACpB,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEU,oBAA6B;AAAA,IACrC;AAAA,IACA;AAAA,IACA,aAAa,YAAY;AAAA,IACzB;AAAA,EACF,GAKG;AACD,UAAM,WAA2B;AAAA,MAC/B;AAAA,MACA,M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ACxB,WAAW;AAAA,MACb,CAAC;AACD,aAAO;AAAA,IACT;AAEA,QAAI;AACF,YAAM,uBAAuB,MAAM,IAAI,mBAAmB;AAAA,QACxD;AAAA,MACF,CAAC;AAGD,YAAM,iBAAiB,WAAW,UAAU,CAAC;AAE7C,YAAM,EAAE,QAAQ,IAAI,MAAM,IAAI,UAAU,gBAAgB,oBAAoB;AAE5E,UAAI,CAAC,QAAQ,KAAK;AAChB,aAAK,kBAAkB;AAAA,UACrB;AAAA,UACA,OAAO;AAAA,UACP,YAAY,YAAY;AAAA,UACxB,WAAW;AAAA,QACb,CAAC;AACD,eAAO;AAAA,MACT;AAEA,YAAM,SAAS,SAAS,QAAQ,GAAG;AAEnC,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,QAAQ;AACN,WAAK,kBAAkB;AAAA,QACrB;AAAA,QACA,OAAO;AAAA,QACP,YAAY,YAAY;AAAA,QACxB,WAAW;AAAA,MACb,CAAC;AACD,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { StatusCodes } from 'http-status-codes';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport type { DatabaseInstance } from '../../database/index.js';\nimport type { RedisInstance } from '../../redis/index.js';\nimport type { QueueManager } from '../../queue/index.js';\nimport type { ApiError, ApiResponse, WebServerBaseControllerConstructorParams } from './base.interface.js';\nimport { Logger } from '../../logger/index.js';\nimport type { ApplicationConfig } from '../../application/base-application.interface.js';\nimport type EventManager from '../../event/manager.js';\nimport cluster from 'cluster';\nimport type { WebServerOptions } from '../webserver.interface.js';\nimport type { LifecycleManager } from '../../lifecycle/lifecycle-manager.js';\nimport Jwt from '../../auth/jwt.js';\n\nexport interface AuthenticatedUser<TPayload = Record<string, unknown>> {\n userId: number;\n payload: TPayload;\n}\n\nexport default abstract class BaseController<\n TQueueManager extends QueueManager = QueueManager,\n TRedisInstance extends RedisInstance = RedisInstance,\n TEventManager extends EventManager = EventManager,\n TDatabaseInstance extends DatabaseInstance = DatabaseInstance,\n> {\n protected workerId: number | undefined;\n\n protected applicationConfig: ApplicationConfig;\n protected webServerOptions: WebServerOptions;\n\n protected redisInstance: TRedisInstance;\n protected queueManager: TQueueManager;\n protected eventManager: TEventManager;\n protected databaseInstance: TDatabaseInstance;\n protected lifecycleManager: LifecycleManager;\n\n constructor({\n applicationConfig,\n webServerOptions,\n redisInstance,\n queueManager,\n eventManager,\n databaseInstance,\n lifecycleManager,\n }: WebServerBaseControllerConstructorParams<TQueueManager, TRedisInstance, TEventManager, TDatabaseInstance>) {\n this.workerId = cluster.worker?.id;\n\n this.applicationConfig = applicationConfig;\n this.webServerOptions = webServerOptions;\n\n this.redisInstance = redisInstance;\n this.queueManager = queueManager;\n this.eventManager = eventManager;\n this.databaseInstance = databaseInstance;\n this.lifecycleManager = lifecycleManager;\n }\n\n protected sendSuccessResponse<T = unknown>({\n reply,\n data,\n statusCode = StatusCodes.OK,\n meta,\n }: {\n reply: FastifyReply;\n data: T;\n statusCode?: StatusCodes;\n meta?: ApiResponse<T>['meta'];\n }) {\n const response: ApiResponse<T> = {\n data,\n meta: {\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n ...meta,\n },\n };\n reply.status(statusCode).send(response);\n }\n\n protected sendNotFoundResponse(reply: FastifyReply, message: string = 'Resource not found') {\n const error: ApiError = {\n message,\n type: 'not_found',\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n };\n const response: ApiResponse = { error };\n reply.status(StatusCodes.NOT_FOUND).send(response);\n }\n\n protected sendErrorResponse({\n reply,\n error,\n statusCode = StatusCodes.BAD_REQUEST,\n errorType,\n }: {\n reply: FastifyReply;\n error: unknown;\n statusCode?: StatusCodes;\n errorType?: ApiError['type'];\n }) {\n let publicErrorMessage: string;\n let errorDetails: Record<string, unknown> | undefined = undefined;\n\n if (this.webServerOptions.errors?.verbose === true) {\n if (error instanceof Error) {\n publicErrorMessage = error.stack ?? error.message;\n errorDetails = { stack: error.stack, name: error.name };\n } else {\n publicErrorMessage = String(error);\n }\n } else {\n if (process.env.NODE_ENV === 'production') {\n if (error instanceof Error) {\n publicErrorMessage = 'Something went wrong';\n } else if (typeof error === 'string') {\n publicErrorMessage = error;\n } else {\n publicErrorMessage = 'An unknown error occurred';\n }\n } else {\n if (error instanceof Error) {\n publicErrorMessage = error.stack ?? error.message;\n errorDetails = { stack: error.stack, name: error.name };\n } else {\n publicErrorMessage = String(error);\n }\n }\n }\n\n Logger.custom({ level: 'webServer', message: error });\n console.error(error);\n\n const apiError: ApiError = {\n message: publicErrorMessage,\n type: errorType ?? this.getErrorType(statusCode),\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n ...(errorDetails && { details: errorDetails }),\n };\n\n const response: ApiResponse = { error: apiError };\n reply.status(statusCode).send(response);\n }\n\n private getErrorType(statusCode: StatusCodes): ApiError['type'] {\n switch (statusCode) {\n case StatusCodes.UNAUTHORIZED:\n return 'authentication';\n case StatusCodes.FORBIDDEN:\n return 'authorization';\n case StatusCodes.NOT_FOUND:\n return 'not_found';\n case StatusCodes.BAD_REQUEST:\n case StatusCodes.UNPROCESSABLE_ENTITY:\n return 'validation';\n case StatusCodes.INTERNAL_SERVER_ERROR:\n case StatusCodes.BAD_GATEWAY:\n case StatusCodes.SERVICE_UNAVAILABLE:\n return 'server_error';\n default:\n return 'client_error';\n }\n }\n\n protected async authenticateRequest(request: FastifyRequest, reply: FastifyReply): Promise<AuthenticatedUser | null> {\n // Get JWT secret key from application config\n const jwtSecretKey = this.applicationConfig.auth?.jwtSecretKey;\n\n if (!jwtSecretKey) {\n this.sendErrorResponse({\n reply,\n error: 'Authentication not configured.',\n statusCode: StatusCodes.INTERNAL_SERVER_ERROR,\n errorType: 'server_error',\n });\n return null;\n }\n\n const authHeader = request.headers.authorization;\n\n if (!authHeader) {\n this.sendErrorResponse({\n reply,\n error: 'No token provided.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n if (!authHeader.startsWith('Bearer ')) {\n this.sendErrorResponse({\n reply,\n error: 'Invalid token.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n try {\n const importedJwtSecretKey = await Jwt.importJwtSecretKey({\n jwtSecretKey,\n });\n\n // Remove \"Bearer \" from token\n const jwtAccessToken = authHeader.substring(7);\n\n const { payload } = await Jwt.jwtVerify(jwtAccessToken, importedJwtSecretKey);\n\n if (!payload.sub) {\n this.sendErrorResponse({\n reply,\n error: 'Invalid token payload.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n const userId = parseInt(payload.sub);\n\n return {\n userId,\n payload,\n };\n } catch {\n this.sendErrorResponse({\n reply,\n error: 'Invalid or expired token.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n }\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,mBAAmB;AAM5B,SAAS,cAAc;AAGvB,OAAO,aAAa;AAGpB,OAAO,SAAS;AAOhB,MAAO,eAKL;AAAA,EAxBF,OAwBE;AAAA;AAAA;AAAA,EACU;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEV,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAA8G;AAC5G,SAAK,WAAW,QAAQ,QAAQ;AAEhC,SAAK,oBAAoB;AACzB,SAAK,mBAAmB;AAExB,SAAK,gBAAgB;AACrB,SAAK,eAAe;AACpB,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEU,oBAAiC;AAAA,IACzC;AAAA,IACA;AAAA,IACA,aAAa,YAAY;AAAA,IACzB;AAAA,EACF,GAKG;AACD,UAAM,WAA2B;AAAA,MAC/B;AAAA,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AAA,QACxB,WAAW;AAAA,MACb,CAAC;AACD,aAAO;AAAA,IACT;AAEA,QAAI;AACF,YAAM,uBAAuB,MAAM,IAAI,mBAAmB;AAAA,QACxD;AAAA,MACF,CAAC;AAGD,YAAM,iBAAiB,WAAW,UAAU,CAAC;AAE7C,YAAM,EAAE,QAAQ,IAAI,MAAM,IAAI,UAAU,gBAAgB,oBAAoB;AAE5E,UAAI,CAAC,QAAQ,KAAK;AAChB,aAAK,kBAAkB;AAAA,UACrB;AAAA,UACA,OAAO;AAAA,UACP,YAAY,YAAY;AAAA,UACxB,WAAW;AAAA,QACb,CAAC;AACD,eAAO;AAAA,MACT;AAEA,YAAM,SAAS,SAAS,QAAQ,GAAG;AAEnC,aAAO;AAAA,QACL;AAAA,QACA;AAAA,MACF;AAAA,IACF,QAAQ;AACN,WAAK,kBAAkB;AAAA,QACrB;AAAA,QACA,OAAO;AAAA,QACP,YAAY,YAAY;AAAA,QACxB,WAAW;AAAA,MACb,CAAC;AACD,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,26 @@
1
+ import type { RouteSchemaDefinition } from './webserver.interface.js';
2
+ import type { ControllerAction } from './controller/base.interface.js';
3
+ /**
4
+ * Define a typed controller action with schema inference.
5
+ * This helper provides TypeScript type inference for controller methods based on Zod schemas.
6
+ *
7
+ * @example
8
+ * const helloSchema = {
9
+ * body: z.object({ name: z.string() }),
10
+ * response: { 200: z.object({ message: z.string() }) }
11
+ * } satisfies RouteSchemaDefinition;
12
+ *
13
+ * class MyController extends WebServerBaseController {
14
+ * hello = defineAction(helloSchema, async (request, reply) => {
15
+ * // request.body is typed as { name: string }
16
+ * return reply.send({ message: `Hello ${request.body.name}` });
17
+ * });
18
+ * }
19
+ */
20
+ export declare function defineAction<Schema extends RouteSchemaDefinition<any, any, any, any, any>>(schema: Schema, handler: ControllerAction<Schema>): ControllerAction<Schema>;
21
+ /**
22
+ * Define a controller action without a schema.
23
+ * Useful for actions that don't need validation or type inference.
24
+ */
25
+ export declare function defineAction<Schema extends undefined = undefined>(handler: ControllerAction<Schema>): ControllerAction<Schema>;
26
+ //# sourceMappingURL=define-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-action.d.ts","sourceRoot":"","sources":["../../src/webserver/define-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAS,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACxF,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAChC,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE5B;;;GAGG;AAEH,wBAAgB,YAAY,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS,EAC/D,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAChC,gBAAgB,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ function defineAction(schemaOrHandler, handler) {
4
+ if (typeof schemaOrHandler === "function") {
5
+ return schemaOrHandler;
6
+ }
7
+ if (!handler) {
8
+ throw new Error("Handler is required when schema is provided");
9
+ }
10
+ return handler;
11
+ }
12
+ __name(defineAction, "defineAction");
13
+ export {
14
+ defineAction
15
+ };
16
+ //# sourceMappingURL=define-action.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/webserver/define-action.ts"],
4
+ "sourcesContent": ["import type { RouteSchemaDefinition } from './webserver.interface.js';\nimport type { ControllerAction } from './controller/base.interface.js';\n\n/**\n * Define a typed controller action with schema inference.\n * This helper provides TypeScript type inference for controller methods based on Zod schemas.\n *\n * @example\n * const helloSchema = {\n * body: z.object({ name: z.string() }),\n * response: { 200: z.object({ message: z.string() }) }\n * } satisfies RouteSchemaDefinition;\n *\n * class MyController extends WebServerBaseController {\n * hello = defineAction(helloSchema, async (request, reply) => {\n * // request.body is typed as { name: string }\n * return reply.send({ message: `Hello ${request.body.name}` });\n * });\n * }\n */\nexport function defineAction<Schema extends RouteSchemaDefinition<any, any, any, any, any>>(\n schema: Schema,\n handler: ControllerAction<Schema>,\n): ControllerAction<Schema>;\n\n/**\n * Define a controller action without a schema.\n * Useful for actions that don't need validation or type inference.\n */\n// eslint-disable-next-line no-redeclare\nexport function defineAction<Schema extends undefined = undefined>(\n handler: ControllerAction<Schema>,\n): ControllerAction<Schema>;\n\n// eslint-disable-next-line no-redeclare\nexport function defineAction<Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined>(\n schemaOrHandler: Schema | ControllerAction<Schema>,\n handler?: ControllerAction<Schema>,\n): ControllerAction<Schema> {\n if (typeof schemaOrHandler === 'function') {\n // No schema provided, just return the handler\n return schemaOrHandler;\n }\n\n // Schema provided, return the handler\n // Note: The schema is attached for documentation/IDE purposes only\n // Actual validation happens at the route level\n if (!handler) {\n throw new Error('Handler is required when schema is provided');\n }\n\n return handler;\n}\n"],
5
+ "mappings": ";;AAmCO,SAAS,aACd,iBACA,SAC0B;AAC1B,MAAI,OAAO,oBAAoB,YAAY;AAEzC,WAAO;AAAA,EACT;AAKA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC/D;AAEA,SAAO;AACT;AAjBgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,53 @@
1
+ import type { HTTPMethods } from 'fastify';
2
+ import { type RouteSchemaDefinition, type WebServerRoute } from './webserver.interface.js';
3
+ import type { ControllerAction, WebServerBaseControllerType } from './controller/base.interface.js';
4
+ export interface DefineRouteConfig<Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined, Handler extends ControllerAction<Schema>> {
5
+ method: HTTPMethods | HTTPMethods[];
6
+ path: string;
7
+ schema?: Schema;
8
+ handler: Handler;
9
+ }
10
+ export interface DefineRouteWithControllerConfig<Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined = undefined> {
11
+ method: HTTPMethods | HTTPMethods[];
12
+ path: string;
13
+ schema?: Schema;
14
+ controller: WebServerBaseControllerType;
15
+ action: string;
16
+ }
17
+ /**
18
+ * Define a route with an inline handler function.
19
+ * Provides full type inference for request parameters based on the schema.
20
+ *
21
+ * @example
22
+ * const helloSchema = {
23
+ * body: z.object({ name: z.string() }),
24
+ * response: { 200: z.object({ message: z.string() }) }
25
+ * } satisfies RouteSchemaDefinition;
26
+ *
27
+ * defineRoute({
28
+ * method: 'POST',
29
+ * path: '/hello',
30
+ * schema: helloSchema,
31
+ * handler: async (request, reply) => {
32
+ * // request.body is typed as { name: string }
33
+ * return reply.send({ message: `Hello ${request.body.name}` });
34
+ * }
35
+ * });
36
+ */
37
+ export declare function defineRoute<Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined, Handler extends ControllerAction<Schema>>(config: DefineRouteConfig<Schema, Handler>): WebServerRoute;
38
+ /**
39
+ * Define a route with a controller and action method.
40
+ * Note: Type inference for controller actions is limited. Consider using inline handlers for full type safety.
41
+ *
42
+ * @example
43
+ * defineRoute({
44
+ * method: 'POST',
45
+ * path: '/hello',
46
+ * controller: HelloController,
47
+ * action: 'create',
48
+ * schema: helloSchema
49
+ * });
50
+ */
51
+ export declare function defineRoute<Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined = undefined>(config: DefineRouteWithControllerConfig<Schema>): WebServerRoute;
52
+ export type DefineRoute = typeof defineRoute;
53
+ //# sourceMappingURL=define-route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-route.d.ts","sourceRoot":"","sources":["../../src/webserver/define-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM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C,GAAG,SAAS,GAAG,SAAS,EAC/G,MAAM,EAAE,+BAA+B,CAAC,MAAM,CAAC,GAC9C,cAAc,CAAC;AA2BlB,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC"}
@@ -0,0 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import {
4
+ WebServerRouteType
5
+ } from "./webserver.interface.js";
6
+ function defineRoute(config) {
7
+ const route = {
8
+ type: WebServerRouteType.Default,
9
+ method: config.method,
10
+ path: config.path
11
+ };
12
+ if ("handler" in config) {
13
+ route.handler = config.handler;
14
+ } else if ("controller" in config && "action" in config) {
15
+ route.controller = config.controller;
16
+ route.action = config.action;
17
+ }
18
+ if (config.schema) {
19
+ route.schema = config.schema;
20
+ }
21
+ return route;
22
+ }
23
+ __name(defineRoute, "defineRoute");
24
+ export {
25
+ defineRoute
26
+ };
27
+ //# sourceMappingURL=define-route.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/webserver/define-route.ts"],
4
+ "sourcesContent": ["import type { HTTPMethods } from 'fastify';\nimport {\n type AnyRouteSchemaDefinition,\n type RouteSchemaDefinition,\n type WebServerRoute,\n WebServerRouteType,\n} from './webserver.interface.js';\nimport type { ControllerAction, WebServerBaseControllerType } from './controller/base.interface.js';\n\nexport interface DefineRouteConfig<\n Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined,\n Handler extends ControllerAction<Schema>,\n> {\n method: HTTPMethods | HTTPMethods[];\n path: string;\n schema?: Schema;\n handler: Handler;\n}\n\nexport interface DefineRouteWithControllerConfig<\n Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined = undefined,\n> {\n method: HTTPMethods | HTTPMethods[];\n path: string;\n schema?: Schema;\n controller: WebServerBaseControllerType;\n action: string;\n}\n\n/**\n * Define a route with an inline handler function.\n * Provides full type inference for request parameters based on the schema.\n *\n * @example\n * const helloSchema = {\n * body: z.object({ name: z.string() }),\n * response: { 200: z.object({ message: z.string() }) }\n * } satisfies RouteSchemaDefinition;\n *\n * defineRoute({\n * method: 'POST',\n * path: '/hello',\n * schema: helloSchema,\n * handler: async (request, reply) => {\n * // request.body is typed as { name: string }\n * return reply.send({ message: `Hello ${request.body.name}` });\n * }\n * });\n */\nexport function defineRoute<\n Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined,\n Handler extends ControllerAction<Schema>,\n>(config: DefineRouteConfig<Schema, Handler>): WebServerRoute;\n\n/**\n * Define a route with a controller and action method.\n * Note: Type inference for controller actions is limited. Consider using inline handlers for full type safety.\n *\n * @example\n * defineRoute({\n * method: 'POST',\n * path: '/hello',\n * controller: HelloController,\n * action: 'create',\n * schema: helloSchema\n * });\n */\n// eslint-disable-next-line no-redeclare\nexport function defineRoute<Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined = undefined>(\n config: DefineRouteWithControllerConfig<Schema>,\n): WebServerRoute;\n\n// eslint-disable-next-line no-redeclare\nexport function defineRoute<\n Schema extends RouteSchemaDefinition<any, any, any, any, any> | undefined,\n Handler extends ControllerAction<Schema>,\n>(config: DefineRouteConfig<Schema, Handler> | DefineRouteWithControllerConfig<Schema>): WebServerRoute {\n const route: WebServerRoute = {\n type: WebServerRouteType.Default,\n method: config.method,\n path: config.path,\n };\n\n if ('handler' in config) {\n route.handler = config.handler as ControllerAction<any>;\n } else if ('controller' in config && 'action' in config) {\n route.controller = config.controller;\n route.action = config.action;\n }\n\n if (config.schema) {\n route.schema = config.schema as AnyRouteSchemaDefinition;\n }\n\n return route;\n}\n\nexport type DefineRoute = typeof defineRoute;\n"],
5
+ "mappings": ";;AACA;AAAA,EAIE;AAAA,OACK;AAmEA,SAAS,YAGd,QAAsG;AACtG,QAAM,QAAwB;AAAA,IAC5B,MAAM,mBAAmB;AAAA,IACzB,QAAQ,OAAO;AAAA,IACf,MAAM,OAAO;AAAA,EACf;AAEA,MAAI,aAAa,QAAQ;AACvB,UAAM,UAAU,OAAO;AAAA,EACzB,WAAW,gBAAgB,UAAU,YAAY,QAAQ;AACvD,UAAM,aAAa,OAAO;AAC1B,UAAM,SAAS,OAAO;AAAA,EACxB;AAEA,MAAI,OAAO,QAAQ;AACjB,UAAM,SAAS,OAAO;AAAA,EACxB;AAEA,SAAO;AACT;AAtBgB;",
6
+ "names": []
7
+ }
@@ -1,12 +1,14 @@
1
1
  export { default as WebServer } from './webserver.js';
2
- export type { WebServerConstructorParams, WebServerOptions, WebServerRoute } from './webserver.interface.js';
2
+ export type { RouteHandler as TypedRouteHandler, RouteHandlerContext, RouteSchemaDefinition, WebServerConstructorParams, WebServerOptions, WebServerRoute, } from './webserver.interface.js';
3
3
  export { WebServerRouteType } from './webserver.interface.js';
4
4
  export { default as WebServerBaseController } from './controller/base.js';
5
- export type { WebServerBaseControllerConstructorParams } from './controller/base.interface.js';
5
+ export type { ControllerAction, ControllerRequest, WebServerBaseControllerConstructorParams, } from './controller/base.interface.js';
6
6
  export { default as WebServerHealthController } from './controller/health.js';
7
7
  export { default as WebServerEntityController } from './controller/entity.js';
8
8
  export { default as ExampleAuthController } from './controller/example-auth.js';
9
9
  export { default as RouteUtil } from './util.js';
10
10
  export type { AuthenticatedUser, AuthenticatedRequest, AuthenticatedRouteHandler, RouteHandler, } from './controller/auth-middleware.js';
11
11
  export { withAuth } from './controller/auth-middleware.js';
12
+ export { defineRoute } from './define-route.js';
13
+ export { defineAction } from './define-action.js';
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webserver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC7G,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,OAAO,IA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Y,EACV,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,YAAY,GACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -6,6 +6,8 @@ import { default as default5 } from "./controller/entity.js";
6
6
  import { default as default6 } from "./controller/example-auth.js";
7
7
  import { default as default7 } from "./util.js";
8
8
  import { withAuth } from "./controller/auth-middleware.js";
9
+ import { defineRoute } from "./define-route.js";
10
+ import { defineAction } from "./define-action.js";
9
11
  export {
10
12
  default6 as ExampleAuthController,
11
13
  default7 as RouteUtil,
@@ -14,6 +16,8 @@ export {
14
16
  default5 as WebServerEntityController,
15
17
  default4 as WebServerHealthController,
16
18
  WebServerRouteType,
19
+ defineAction,
20
+ defineRoute,
17
21
  withAuth
18
22
  };
19
23
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/webserver/index.ts"],
4
- "sourcesContent": ["export { default as WebServer } from './webserver.js';\nexport type { WebServerConstructorParams, WebServerOptions, WebServerRoute } from './webserver.interface.js';\nexport { WebServerRouteType } from './webserver.interface.js';\nexport { default as WebServerBaseController } from './controller/base.js';\nexport type { WebServerBaseControllerConstructorParams } from './controller/base.interface.js';\nexport { default as WebServerHealthController } from './controller/health.js';\nexport { default as WebServerEntityController } from './controller/entity.js';\nexport { default as ExampleAuthController } from './controller/example-auth.js';\nexport { default as RouteUtil } from './util.js';\nexport type {\n AuthenticatedUser,\n AuthenticatedRequest,\n AuthenticatedRouteHandler,\n RouteHandler,\n} from './controller/auth-middleware.js';\nexport { withAuth } from './controller/auth-middleware.js';\n"],
5
- "mappings": "AAAA,SAAoB,WAAXA,gBAA4B;AAErC,SAAS,0BAA0B;AACnC,SAAoB,WAAXA,gBAA0C;AAEnD,SAAoB,WAAXA,gBAA4C;AACrD,SAAoB,WAAXA,gBAA4C;AACrD,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAA4B;AAOrC,SAAS,gBAAgB;",
4
+ "sourcesContent": ["export { default as WebServer } from './webserver.js';\nexport type {\n RouteHandler as TypedRouteHandler,\n RouteHandlerContext,\n RouteSchemaDefinition,\n WebServerConstructorParams,\n WebServerOptions,\n WebServerRoute,\n} from './webserver.interface.js';\nexport { WebServerRouteType } from './webserver.interface.js';\nexport { default as WebServerBaseController } from './controller/base.js';\nexport type {\n ControllerAction,\n ControllerRequest,\n WebServerBaseControllerConstructorParams,\n} from './controller/base.interface.js';\nexport { default as WebServerHealthController } from './controller/health.js';\nexport { default as WebServerEntityController } from './controller/entity.js';\nexport { default as ExampleAuthController } from './controller/example-auth.js';\nexport { default as RouteUtil } from './util.js';\nexport type {\n AuthenticatedUser,\n AuthenticatedRequest,\n AuthenticatedRouteHandler,\n RouteHandler,\n} from './controller/auth-middleware.js';\nexport { withAuth } from './controller/auth-middleware.js';\nexport { defineRoute } from './define-route.js';\nexport { defineAction } from './define-action.js';\n"],
5
+ "mappings": "AAAA,SAAoB,WAAXA,gBAA4B;AASrC,SAAS,0BAA0B;AACnC,SAAoB,WAAXA,gBAA0C;AAMnD,SAAoB,WAAXA,gBAA4C;AACrD,SAAoB,WAAXA,gBAA4C;AACrD,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAA4B;AAOrC,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;",
6
6
  "names": ["default"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/webserver/util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAyB,MAAM,0BAA0B,CAAC;AAE7F,iBAAS,yBAAyB,CAAC,EACjC,QAAQ,EACR,sBAAsB,GACvB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB,EAAE,GAAG,CAAC;CAC7B,GAAG,qBAAqB,EAAE,CA6D1B;;;;AAED,wBAGE"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/webserver/util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAyB,MAAM,0BAA0B,CAAC;AAE7F,iBAAS,yBAAyB,CAAC,EACjC,QAAQ,EACR,sBAAsB,GACvB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB,EAAE,GAAG,CAAC;CAC7B,GAAG,qBAAqB,EAAE,CAkE1B;;;;AAED,wBAGE"}
@@ -37,12 +37,15 @@ function getEntityRouteDefinitions({
37
37
  action: "createOne",
38
38
  validationSchema: entityValidationSchema
39
39
  });
40
+ const updateOneValidationSchemas = [idValidationSchema];
41
+ if (entityValidationSchema) {
42
+ updateOneValidationSchemas.push(entityValidationSchema);
43
+ }
40
44
  routeDefinitions.push({
41
45
  path: `${basePath}/:id`,
42
46
  method: "PUT",
43
47
  action: "updateOne",
44
- validationSchema: entityValidationSchema
45
- // TODO: Need to merge with idValidationSchema
48
+ validationSchema: updateOneValidationSchemas
46
49
  });
47
50
  routeDefinitions.push({
48
51
  path: `${basePath}/:id`,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/webserver/util.ts"],
4
- "sourcesContent": ["import type { HTTPMethods } from 'fastify';\nimport type { EntityRouteDefinition, RouteValidationSchema } from './webserver.interface.js';\n\nfunction getEntityRouteDefinitions({\n basePath,\n entityValidationSchema,\n}: {\n basePath: string;\n entityValidationSchema: any;\n}): EntityRouteDefinition[] {\n const routeDefinitions: EntityRouteDefinition[] = [];\n\n const idValidationSchema: RouteValidationSchema = {\n type: 'params',\n schema: {\n properties: {\n id: { type: 'integer' },\n },\n required: ['id'],\n type: 'object',\n },\n };\n\n // Options\n routeDefinitions.push({\n path: `${basePath}/options`,\n method: 'GET' as HTTPMethods,\n action: 'options',\n });\n\n // Get many\n routeDefinitions.push({\n path: `${basePath}`,\n method: 'GET' as HTTPMethods,\n action: 'getMany',\n });\n\n // Get one\n routeDefinitions.push({\n path: `${basePath}/:id`,\n method: 'GET' as HTTPMethods,\n action: 'getOne',\n validationSchema: idValidationSchema,\n });\n\n // Create one\n routeDefinitions.push({\n path: `${basePath}`,\n method: 'POST' as HTTPMethods,\n action: 'createOne',\n validationSchema: entityValidationSchema,\n });\n\n // Update one\n routeDefinitions.push({\n path: `${basePath}/:id`,\n method: 'PUT' as HTTPMethods,\n action: 'updateOne',\n validationSchema: entityValidationSchema, // TODO: Need to merge with idValidationSchema\n });\n\n // Delete one\n routeDefinitions.push({\n path: `${basePath}/:id`,\n method: 'DELETE' as HTTPMethods,\n action: 'deleteOne',\n validationSchema: idValidationSchema,\n });\n\n return routeDefinitions;\n}\n\nexport default {\n // getEntityRoutes,\n getEntityRouteDefinitions,\n};\n"],
5
- "mappings": ";;AAGA,SAAS,0BAA0B;AAAA,EACjC;AAAA,EACA;AACF,GAG4B;AAC1B,QAAM,mBAA4C,CAAC;AAEnD,QAAM,qBAA4C;AAAA,IAChD,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,YAAY;AAAA,QACV,IAAI,EAAE,MAAM,UAAU;AAAA,MACxB;AAAA,MACA,UAAU,CAAC,IAAI;AAAA,MACf,MAAM;AAAA,IACR;AAAA,EACF;AAGA,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA;AAAA,EACpB,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AAED,SAAO;AACT;AAnES;AAqET,IAAO,eAAQ;AAAA;AAAA,EAEb;AACF;",
4
+ "sourcesContent": ["import type { HTTPMethods } from 'fastify';\nimport type { EntityRouteDefinition, RouteValidationSchema } from './webserver.interface.js';\n\nfunction getEntityRouteDefinitions({\n basePath,\n entityValidationSchema,\n}: {\n basePath: string;\n entityValidationSchema: any;\n}): EntityRouteDefinition[] {\n const routeDefinitions: EntityRouteDefinition[] = [];\n\n const idValidationSchema: RouteValidationSchema = {\n type: 'params',\n schema: {\n properties: {\n id: { type: 'integer' },\n },\n required: ['id'],\n type: 'object',\n },\n };\n\n // Options\n routeDefinitions.push({\n path: `${basePath}/options`,\n method: 'GET' as HTTPMethods,\n action: 'options',\n });\n\n // Get many\n routeDefinitions.push({\n path: `${basePath}`,\n method: 'GET' as HTTPMethods,\n action: 'getMany',\n });\n\n // Get one\n routeDefinitions.push({\n path: `${basePath}/:id`,\n method: 'GET' as HTTPMethods,\n action: 'getOne',\n validationSchema: idValidationSchema,\n });\n\n // Create one\n routeDefinitions.push({\n path: `${basePath}`,\n method: 'POST' as HTTPMethods,\n action: 'createOne',\n validationSchema: entityValidationSchema,\n });\n\n // Update one - merge params and body validation\n const updateOneValidationSchemas: RouteValidationSchema[] = [idValidationSchema];\n if (entityValidationSchema) {\n updateOneValidationSchemas.push(entityValidationSchema);\n }\n\n routeDefinitions.push({\n path: `${basePath}/:id`,\n method: 'PUT' as HTTPMethods,\n action: 'updateOne',\n validationSchema: updateOneValidationSchemas,\n });\n\n // Delete one\n routeDefinitions.push({\n path: `${basePath}/:id`,\n method: 'DELETE' as HTTPMethods,\n action: 'deleteOne',\n validationSchema: idValidationSchema,\n });\n\n return routeDefinitions;\n}\n\nexport default {\n // getEntityRoutes,\n getEntityRouteDefinitions,\n};\n"],
5
+ "mappings": ";;AAGA,SAAS,0BAA0B;AAAA,EACjC;AAAA,EACA;AACF,GAG4B;AAC1B,QAAM,mBAA4C,CAAC;AAEnD,QAAM,qBAA4C;AAAA,IAChD,MAAM;AAAA,IACN,QAAQ;AAAA,MACN,YAAY;AAAA,QACV,IAAI,EAAE,MAAM,UAAU;AAAA,MACxB;AAAA,MACA,UAAU,CAAC,IAAI;AAAA,MACf,MAAM;AAAA,IACR;AAAA,EACF;AAGA,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AAGD,QAAM,6BAAsD,CAAC,kBAAkB;AAC/E,MAAI,wBAAwB;AAC1B,+BAA2B,KAAK,sBAAsB;AAAA,EACxD;AAEA,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AAGD,mBAAiB,KAAK;AAAA,IACpB,MAAM,GAAG,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AAED,SAAO;AACT;AAxES;AA0ET,IAAO,eAAQ;AAAA;AAAA,EAEb;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,8 @@
1
1
  import { type FastifyInstance, type HTTPMethods } from 'fastify';
2
- import { type WebServerConstructorParams } from './webserver.interface.js';
2
+ import { type AnyRouteSchemaDefinition, type WebServerConstructorParams } from './webserver.interface.js';
3
+ import type { ControllerAction } from './controller/base.interface.js';
3
4
  import type { LifecycleManager } from '../lifecycle/lifecycle-manager.js';
5
+ import { type ZodTypeProvider } from 'fastify-type-provider-zod';
4
6
  declare module 'fastify' {
5
7
  interface FastifyRequest {
6
8
  startTime?: number;
@@ -16,7 +18,7 @@ declare class WebServer {
16
18
  private queueManager;
17
19
  private eventManager;
18
20
  private databaseInstance;
19
- fastifyServer: FastifyInstance;
21
+ fastifyServer: FastifyInstance<any, any, any, any, ZodTypeProvider>;
20
22
  private lifecycleManager;
21
23
  private _isReady;
22
24
  constructor(params: WebServerConstructorParams & {
@@ -45,18 +47,28 @@ declare class WebServer {
45
47
  * Configure routes.
46
48
  */
47
49
  private configureRoutes;
48
- defineRoute({ controllerInstance, controllerName, routeMethod, routePath, routeAction, routeValidation, }: {
50
+ private loadRoutesFromDirectory;
51
+ private normalizeRouteExport;
52
+ private isValidRoute;
53
+ defineRoute({ controllerInstance, controllerName, routeMethod, routePath, routeAction, routeSchema, handlerOverride, legacyValidation, }: {
49
54
  controllerInstance: any;
50
55
  controllerName: string;
51
56
  routeMethod: HTTPMethods | HTTPMethods[];
52
57
  routePath: string;
53
- routeAction: string;
54
- routeValidation?: {
58
+ routeAction?: string;
59
+ routeSchema?: AnyRouteSchemaDefinition;
60
+ handlerOverride?: ControllerAction<any>;
61
+ legacyValidation?: {
55
62
  type: 'body' | 'query' | 'params';
56
63
  schema: {
57
64
  [key: string]: any;
58
65
  };
59
- };
66
+ } | Array<{
67
+ type: 'body' | 'query' | 'params';
68
+ schema: {
69
+ [key: string]: any;
70
+ };
71
+ }>;
60
72
  }): Promise<void>;
61
73
  /**
62
74
  * Start web server.
@@ -66,6 +78,8 @@ declare class WebServer {
66
78
  * Stop web server.
67
79
  */
68
80
  stop(): Promise<void>;
81
+ private buildFastifySchema;
82
+ private buildLegacySchema;
69
83
  /**
70
84
  * Check if web server is ready to accept traffic.
71
85
  */
@@ -1 +1 @@
1
- {"version":3,"file":"webserver.d.ts","sourceRoot":"","sources":["../../src/webserver/webserver.ts"],"names":[],"mappings":"AACA,OAAgB,EAAE,KAAK,eAAe,EAA0C,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAKlH,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,0BAA0B,CAAC;AASlC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAK1E,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,cAAc;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;CACF;AAED,cAAM,SAAS;IACb,OAAO,CAAC,MAAM,CAAyB;IAEvC,OAAO,CAAC,iBAAiB,CAAoB;IAE7C,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,MAAM,CAAmB;IAEjC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,gBAAgB,CAAmB;IAEpC,aAAa,EAAE,eAAe,CAAC;IAEtC,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAS;gBAEb,MAAM,EAAE,0BAA0B,GAAG;QAAE,gBAAgB,EAAE,gBAAgB,CAAA;KAAE;IAgDvF;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC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X,WAAW,EACX,eAAe,EACf,gBAAgB,GACjB,EAAE;QACD,kBAAkB,EAAE,GAAG,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC;QACvB,WAAW,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;QACzC,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,wBAAwB,CAAC;QACvC,eAAe,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACxC,gBAAgB,CAAC,EACb;YACE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;YAClC,MAAM,EAAE;gBAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;aAAE,CAAC;SAChC,GACD,KAAK,CAAC;YACJ,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;YAClC,MAAM,EAAE;gBAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;aAAE,CAAC;SAChC,CAAC,CAAC;KACR,GAAG,OAAO,CAAC,IAAI,CAAC;IA2CjB;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAanC;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC,OAAO,CAAC,kBAAkB;IAgC1B,OAAO,CAAC,iBAAiB;IAqCzB;;OAEG;IACI,OAAO,IAAI,OAAO;IAIzB;;OAEG;IACI,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAGlE;AAED,eAAe,SAAS,CAAC"}
@@ -1,11 +1,30 @@
1
- import type { HTTPMethods } from 'fastify';
1
+ import type { FastifyReply, FastifyRequest, HTTPMethods, RouteGenericInterface } from 'fastify';
2
2
  import type { DatabaseInstance } from '../database/index.js';
3
3
  import type { QueueManager } from '../queue/index.js';
4
4
  import type { RedisInstance } from '../redis/index.js';
5
- import type { WebServerBaseControllerType } from './controller/base.interface.js';
5
+ import type { ControllerAction, WebServerBaseControllerType } from './controller/base.interface.js';
6
6
  import type { ApplicationConfig } from '../application/base-application.interface.js';
7
7
  import type EventManager from '../event/manager.js';
8
8
  import type { LifecycleManager } from '../lifecycle/lifecycle-manager.js';
9
+ import type { z } from 'zod';
10
+ export interface RouteSchemaDefinition<TParams extends z.ZodTypeAny | undefined = undefined, TQuery extends z.ZodTypeAny | undefined = undefined, TBody extends z.ZodTypeAny | undefined = undefined, TReply extends Record<number | `${number}`, z.ZodTypeAny> | undefined = undefined, THeaders extends z.ZodTypeAny | undefined = undefined> {
11
+ params?: TParams;
12
+ querystring?: TQuery;
13
+ body?: TBody;
14
+ response?: TReply;
15
+ headers?: THeaders;
16
+ }
17
+ type InferOrDefault<TZod extends z.ZodTypeAny | undefined, TFallback> = TZod extends z.ZodTypeAny ? z.input<TZod> : TFallback;
18
+ type InferResponse<TResponse> = TResponse extends Record<number | `${number}`, z.ZodTypeAny> ? z.output<TResponse[keyof TResponse]> : RouteGenericInterface['Reply'];
19
+ export interface RouteHandlerContext<Schema extends RouteSchemaDefinition | undefined = undefined> extends RouteGenericInterface {
20
+ Params?: Schema extends RouteSchemaDefinition<infer TParams, any, any, any, any> ? InferOrDefault<TParams, RouteGenericInterface['Params']> : RouteGenericInterface['Params'];
21
+ Querystring?: Schema extends RouteSchemaDefinition<any, infer TQuery, any, any, any> ? InferOrDefault<TQuery, RouteGenericInterface['Querystring']> : RouteGenericInterface['Querystring'];
22
+ Body?: Schema extends RouteSchemaDefinition<any, any, infer TBody, any, any> ? InferOrDefault<TBody, RouteGenericInterface['Body']> : RouteGenericInterface['Body'];
23
+ Headers?: Schema extends RouteSchemaDefinition<any, any, any, any, infer THeaders> ? InferOrDefault<THeaders, RouteGenericInterface['Headers']> : RouteGenericInterface['Headers'];
24
+ Reply?: Schema extends RouteSchemaDefinition<any, any, any, infer TReply, any> ? InferResponse<TReply> : RouteGenericInterface['Reply'];
25
+ }
26
+ export type AnyRouteSchemaDefinition = RouteSchemaDefinition<z.ZodTypeAny | undefined, z.ZodTypeAny | undefined, z.ZodTypeAny | undefined, Record<number | `${number}`, z.ZodTypeAny> | undefined, z.ZodTypeAny | undefined>;
27
+ export type RouteHandler<Schema extends RouteSchemaDefinition | undefined = undefined> = (request: FastifyRequest<RouteHandlerContext<Schema>>, reply: FastifyReply) => Promise<RouteHandlerContext<Schema>['Reply'] | void> | RouteHandlerContext<Schema>['Reply'] | void;
9
28
  export interface WebServerConstructorParams {
10
29
  /** Application configuration */
11
30
  applicationConfig: ApplicationConfig;
@@ -37,6 +56,8 @@ export interface BaseWebServerRoute {
37
56
  controllerName?: string;
38
57
  /** Route controller */
39
58
  controller?: WebServerBaseControllerType;
59
+ /** Typed route handler */
60
+ handler?: ControllerAction<any>;
40
61
  /** Route validation */
41
62
  validation?: {
42
63
  /** Validation type */
@@ -46,13 +67,15 @@ export interface BaseWebServerRoute {
46
67
  [key: string]: any;
47
68
  };
48
69
  };
70
+ /** Zod-based schema definition */
71
+ schema?: AnyRouteSchemaDefinition;
49
72
  }
50
73
  export interface DefaultWebServerRoute extends BaseWebServerRoute {
51
74
  type: WebServerRouteType.Default;
52
75
  /** Route method */
53
76
  method: HTTPMethods | HTTPMethods[];
54
77
  /** Route action */
55
- action: string;
78
+ action?: string;
56
79
  }
57
80
  export interface EntityWebServerRoute extends BaseWebServerRoute {
58
81
  type: WebServerRouteType.Entity;
@@ -74,7 +97,7 @@ export interface EntityRouteDefinition {
74
97
  path: string;
75
98
  method: HTTPMethods | HTTPMethods[];
76
99
  action: string;
77
- validationSchema?: RouteValidationSchema;
100
+ validationSchema?: RouteValidationSchema | RouteValidationSchema[];
78
101
  }
79
102
  export interface WebServerLogConfig {
80
103
  startUp?: boolean;
@@ -146,10 +169,13 @@ export interface WebServerOptions {
146
169
  errors?: WebServerErrorsOptions;
147
170
  /** Web server controllers directory */
148
171
  controllersDirectory: string;
172
+ /** Optional directory containing route definition files */
173
+ routesDirectory?: string;
149
174
  log?: WebServerLogConfig;
150
175
  /** Web server security options (helmet, rate limiting) */
151
176
  security?: WebServerSecurityOptions;
152
177
  /** Web server debug options */
153
178
  debug?: WebServerDebugOptions;
154
179
  }
180
+ export {};
155
181
  //# sourceMappingURL=webserver.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webserver.interface.d.ts","sourceRoot":"","sources":["../../src/webserver/webserver.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,WAAW,0BAA0B;IACzC,gCAAgC;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;IAErC,yBAAyB;IACzB,OAAO,EAAE,gBAAgB,CAAC;IAE1B,wBAAwB;IACxB,MAAM,EAAE,cAAc,EAAE,CAAC;IAEzB,qBAAqB;IACrB,aAAa,EAAE,aAAa,CAAC;IAE7B,oBAAoB;IACpB,YAAY,EAAE,YAAY,CAAC;IAE3B,oBAAoB;IACpB,YAAY,EAAE,YAAY,CAAC;IAE3B,wBAAwB;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,wBAAwB;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,oBAAY,kBAAkB;IAC5B,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB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OAAO,CAAC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iCAAiC;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,8BAA8B,CAAC;IACxC,SAAS,CAAC,EAAE,iCAAiC,CAAC;CAC/C;AAED,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IAEb,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IAEb,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,8BAA8B;IAC9B,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAE5B,+BAA+B;IAC/B,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAEhC,uCAAuC;IACvC,oBAAoB,EAAE,MAAM,CAAC;IAE7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,GAAG,CAAC,EAAE,kBAAkB,CAAC;IAEzB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,wBAAwB,CAAC;IAEpC,+BAA+B;IAC/B,KAAK,CAAC,EAAE,qBAAqB,CAAC;CAC/B"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/webserver/webserver.interface.ts"],
4
- "sourcesContent": ["import type { HTTPMethods } from 'fastify';\nimport type { DatabaseInstance } from '../database/index.js';\nimport type { QueueManager } from '../queue/index.js';\nimport type { RedisInstance } from '../redis/index.js';\nimport type { WebServerBaseControllerType } from './controller/base.interface.js';\nimport type { ApplicationConfig } from '../application/base-application.interface.js';\nimport type EventManager from '../event/manager.js';\nimport type { LifecycleManager } from '../lifecycle/lifecycle-manager.js';\n\nexport interface WebServerConstructorParams {\n /** Application configuration */\n applicationConfig: ApplicationConfig;\n\n /** Web server options */\n options: WebServerOptions;\n\n /** Web server routes */\n routes: WebServerRoute[];\n\n /** Redis instance */\n redisInstance: RedisInstance;\n\n /** Queue manager */\n queueManager: QueueManager;\n\n /** Event manager */\n eventManager: EventManager;\n\n /** Database instance */\n databaseInstance: DatabaseInstance;\n\n /** Lifecycle manager */\n lifecycleManager: LifecycleManager;\n}\n\nexport enum WebServerRouteType {\n Default = 'default',\n Entity = 'entity',\n}\n\nexport interface BaseWebServerRoute {\n /** Route type */\n type?: WebServerRouteType;\n\n /** Route path */\n path: string;\n\n /** Route controller name */\n controllerName?: string;\n\n /** Route controller */\n controller?: WebServerBaseControllerType;\n\n /** Route validation */\n validation?: {\n /** Validation type */\n type: 'body' | 'query' | 'params';\n\n /** Validation schema */\n schema: { [key: string]: any };\n };\n}\n\nexport interface DefaultWebServerRoute extends BaseWebServerRoute {\n type: WebServerRouteType.Default;\n\n /** Route method */\n method: HTTPMethods | HTTPMethods[];\n\n /** Route action */\n action: string;\n}\n\nexport interface EntityWebServerRoute extends BaseWebServerRoute {\n type: WebServerRouteType.Entity;\n\n /** Entity name */\n entityName: string;\n}\n\nexport type WebServerRoute = DefaultWebServerRoute | EntityWebServerRoute;\n\nexport interface RouteValidationSchema {\n type: 'body' | 'query' | 'params';\n schema: {\n type: 'object';\n properties: { [key: string]: any };\n required: string[];\n };\n}\n\nexport interface EntityRouteDefinition {\n path: string;\n method: HTTPMethods | HTTPMethods[];\n action: string;\n validationSchema?: RouteValidationSchema;\n}\n\nexport interface WebServerLogConfig {\n startUp?: boolean;\n}\n\nexport interface WebServerDebugOptions {\n printRoutes?: boolean;\n simulateSlowConnection?: {\n enabled?: boolean;\n delay?: number;\n };\n}\n\nexport interface WebServerCorsBaseOptions {\n /** Whether CORS is enabled */\n enabled: boolean;\n}\n\nexport interface WebServerCorsDisabledOptionsBase {\n enabled: false;\n}\n\nexport interface WebServerCorsEnabledOptionsBase {\n enabled: true;\n}\n\nexport interface WebServerCorsEnabledOptions extends WebServerCorsEnabledOptionsBase {\n urls: string[];\n}\n\nexport type WebServerCorsOptions = WebServerCorsDisabledOptionsBase | WebServerCorsEnabledOptions;\n\nexport interface WebServerErrorsOptions {\n verbose: boolean;\n}\n\nexport interface WebServerSecurityHelmetOptions {\n enabled?: boolean;\n contentSecurityPolicy?: boolean;\n crossOriginEmbedderPolicy?: boolean;\n crossOriginOpenerPolicy?: boolean;\n crossOriginResourcePolicy?: boolean;\n dnsPrefetchControl?: boolean;\n frameguard?: boolean;\n hidePoweredBy?: boolean;\n hsts?: boolean;\n ieNoOpen?: boolean;\n noSniff?: boolean;\n originAgentCluster?: boolean;\n permittedCrossDomainPolicies?: boolean;\n referrerPolicy?: boolean;\n xssFilter?: boolean;\n}\n\nexport interface WebServerSecurityRateLimitOptions {\n enabled?: boolean;\n max?: number;\n timeWindow?: string;\n ban?: number;\n cache?: number;\n}\n\nexport interface WebServerSecurityOptions {\n helmet?: WebServerSecurityHelmetOptions;\n rateLimit?: WebServerSecurityRateLimitOptions;\n}\n\nexport interface WebServerOptions {\n /** Web server host */\n host: string;\n\n /** Web server port */\n port: number;\n\n /** Maximum request body size in bytes (default: 100MB) */\n bodyLimit?: number;\n\n /** Connection timeout in milliseconds (default: 30s) */\n connectionTimeout?: number;\n\n /** Web server CORS options */\n cors?: WebServerCorsOptions;\n\n /** Web server error options */\n errors?: WebServerErrorsOptions;\n\n /** Web server controllers directory */\n controllersDirectory: string;\n\n log?: WebServerLogConfig;\n\n /** Web server security options (helmet, rate limiting) */\n security?: WebServerSecurityOptions;\n\n /** Web server debug options */\n debug?: WebServerDebugOptions;\n}\n\n// export interface WebServerLogParams {\n// /** Method */\n// Method: string;\n\n// /** Path */\n// Path: string;\n\n// /** Status code */\n// Status: number;\n\n// /** IP address */\n// IP?: string;\n\n// /** Execution time */\n// Time?: string;\n\n// [key: string]: unknown;\n// }\n"],
5
- "mappings": "AAmCO,IAAK,qBAAL,kBAAKA,wBAAL;AACL,EAAAA,oBAAA,aAAU;AACV,EAAAA,oBAAA,YAAS;AAFC,SAAAA;AAAA,GAAA;",
4
+ "sourcesContent": ["import type { FastifyReply, FastifyRequest, HTTPMethods, RouteGenericInterface } from 'fastify';\nimport type { DatabaseInstance } from '../database/index.js';\nimport type { QueueManager } from '../queue/index.js';\nimport type { RedisInstance } from '../redis/index.js';\nimport type { ControllerAction, WebServerBaseControllerType } from './controller/base.interface.js';\nimport type { ApplicationConfig } from '../application/base-application.interface.js';\nimport type EventManager from '../event/manager.js';\nimport type { LifecycleManager } from '../lifecycle/lifecycle-manager.js';\nimport type { z } from 'zod';\n\nexport interface RouteSchemaDefinition<\n TParams extends z.ZodTypeAny | undefined = undefined,\n TQuery extends z.ZodTypeAny | undefined = undefined,\n TBody extends z.ZodTypeAny | undefined = undefined,\n TReply extends Record<number | `${number}`, z.ZodTypeAny> | undefined = undefined,\n THeaders extends z.ZodTypeAny | undefined = undefined,\n> {\n params?: TParams;\n querystring?: TQuery;\n body?: TBody;\n response?: TReply;\n headers?: THeaders;\n}\n\ntype InferOrDefault<TZod extends z.ZodTypeAny | undefined, TFallback> = TZod extends z.ZodTypeAny\n ? z.input<TZod>\n : TFallback;\n\ntype InferResponse<TResponse> =\n TResponse extends Record<number | `${number}`, z.ZodTypeAny>\n ? z.output<TResponse[keyof TResponse]>\n : RouteGenericInterface['Reply'];\n\nexport interface RouteHandlerContext<Schema extends RouteSchemaDefinition | undefined = undefined>\n extends RouteGenericInterface {\n Params?: Schema extends RouteSchemaDefinition<infer TParams, any, any, any, any>\n ? InferOrDefault<TParams, RouteGenericInterface['Params']>\n : RouteGenericInterface['Params'];\n Querystring?: Schema extends RouteSchemaDefinition<any, infer TQuery, any, any, any>\n ? InferOrDefault<TQuery, RouteGenericInterface['Querystring']>\n : RouteGenericInterface['Querystring'];\n Body?: Schema extends RouteSchemaDefinition<any, any, infer TBody, any, any>\n ? InferOrDefault<TBody, RouteGenericInterface['Body']>\n : RouteGenericInterface['Body'];\n Headers?: Schema extends RouteSchemaDefinition<any, any, any, any, infer THeaders>\n ? InferOrDefault<THeaders, RouteGenericInterface['Headers']>\n : RouteGenericInterface['Headers'];\n Reply?: Schema extends RouteSchemaDefinition<any, any, any, infer TReply, any>\n ? InferResponse<TReply>\n : RouteGenericInterface['Reply'];\n}\n\nexport type AnyRouteSchemaDefinition = RouteSchemaDefinition<\n z.ZodTypeAny | undefined,\n z.ZodTypeAny | undefined,\n z.ZodTypeAny | undefined,\n Record<number | `${number}`, z.ZodTypeAny> | undefined,\n z.ZodTypeAny | undefined\n>;\n\nexport type RouteHandler<Schema extends RouteSchemaDefinition | undefined = undefined> = (\n request: FastifyRequest<RouteHandlerContext<Schema>>,\n reply: FastifyReply,\n) => Promise<RouteHandlerContext<Schema>['Reply'] | void> | RouteHandlerContext<Schema>['Reply'] | void;\n\nexport interface WebServerConstructorParams {\n /** Application configuration */\n applicationConfig: ApplicationConfig;\n\n /** Web server options */\n options: WebServerOptions;\n\n /** Web server routes */\n routes: WebServerRoute[];\n\n /** Redis instance */\n redisInstance: RedisInstance;\n\n /** Queue manager */\n queueManager: QueueManager;\n\n /** Event manager */\n eventManager: EventManager;\n\n /** Database instance */\n databaseInstance: DatabaseInstance;\n\n /** Lifecycle manager */\n lifecycleManager: LifecycleManager;\n}\n\nexport enum WebServerRouteType {\n Default = 'default',\n Entity = 'entity',\n}\n\nexport interface BaseWebServerRoute {\n /** Route type */\n type?: WebServerRouteType;\n\n /** Route path */\n path: string;\n\n /** Route controller name */\n controllerName?: string;\n\n /** Route controller */\n controller?: WebServerBaseControllerType;\n\n /** Typed route handler */\n handler?: ControllerAction<any>;\n\n /** Route validation */\n validation?: {\n /** Validation type */\n type: 'body' | 'query' | 'params';\n\n /** Validation schema */\n schema: { [key: string]: any };\n };\n\n /** Zod-based schema definition */\n schema?: AnyRouteSchemaDefinition;\n}\n\nexport interface DefaultWebServerRoute extends BaseWebServerRoute {\n type: WebServerRouteType.Default;\n\n /** Route method */\n method: HTTPMethods | HTTPMethods[];\n\n /** Route action */\n action?: string;\n}\n\nexport interface EntityWebServerRoute extends BaseWebServerRoute {\n type: WebServerRouteType.Entity;\n\n /** Entity name */\n entityName: string;\n}\n\nexport type WebServerRoute = DefaultWebServerRoute | EntityWebServerRoute;\n\nexport interface RouteValidationSchema {\n type: 'body' | 'query' | 'params';\n schema: {\n type: 'object';\n properties: { [key: string]: any };\n required: string[];\n };\n}\n\nexport interface EntityRouteDefinition {\n path: string;\n method: HTTPMethods | HTTPMethods[];\n action: string;\n validationSchema?: RouteValidationSchema | RouteValidationSchema[];\n}\n\nexport interface WebServerLogConfig {\n startUp?: boolean;\n}\n\nexport interface WebServerDebugOptions {\n printRoutes?: boolean;\n simulateSlowConnection?: {\n enabled?: boolean;\n delay?: number;\n };\n}\n\nexport interface WebServerCorsBaseOptions {\n /** Whether CORS is enabled */\n enabled: boolean;\n}\n\nexport interface WebServerCorsDisabledOptionsBase {\n enabled: false;\n}\n\nexport interface WebServerCorsEnabledOptionsBase {\n enabled: true;\n}\n\nexport interface WebServerCorsEnabledOptions extends WebServerCorsEnabledOptionsBase {\n urls: string[];\n}\n\nexport type WebServerCorsOptions = WebServerCorsDisabledOptionsBase | WebServerCorsEnabledOptions;\n\nexport interface WebServerErrorsOptions {\n verbose: boolean;\n}\n\nexport interface WebServerSecurityHelmetOptions {\n enabled?: boolean;\n contentSecurityPolicy?: boolean;\n crossOriginEmbedderPolicy?: boolean;\n crossOriginOpenerPolicy?: boolean;\n crossOriginResourcePolicy?: boolean;\n dnsPrefetchControl?: boolean;\n frameguard?: boolean;\n hidePoweredBy?: boolean;\n hsts?: boolean;\n ieNoOpen?: boolean;\n noSniff?: boolean;\n originAgentCluster?: boolean;\n permittedCrossDomainPolicies?: boolean;\n referrerPolicy?: boolean;\n xssFilter?: boolean;\n}\n\nexport interface WebServerSecurityRateLimitOptions {\n enabled?: boolean;\n max?: number;\n timeWindow?: string;\n ban?: number;\n cache?: number;\n}\n\nexport interface WebServerSecurityOptions {\n helmet?: WebServerSecurityHelmetOptions;\n rateLimit?: WebServerSecurityRateLimitOptions;\n}\n\nexport interface WebServerOptions {\n /** Web server host */\n host: string;\n\n /** Web server port */\n port: number;\n\n /** Maximum request body size in bytes (default: 100MB) */\n bodyLimit?: number;\n\n /** Connection timeout in milliseconds (default: 30s) */\n connectionTimeout?: number;\n\n /** Web server CORS options */\n cors?: WebServerCorsOptions;\n\n /** Web server error options */\n errors?: WebServerErrorsOptions;\n\n /** Web server controllers directory */\n controllersDirectory: string;\n\n /** Optional directory containing route definition files */\n routesDirectory?: string;\n\n log?: WebServerLogConfig;\n\n /** Web server security options (helmet, rate limiting) */\n security?: WebServerSecurityOptions;\n\n /** Web server debug options */\n debug?: WebServerDebugOptions;\n}\n\n// export interface WebServerLogParams {\n// /** Method */\n// Method: string;\n\n// /** Path */\n// Path: string;\n\n// /** Status code */\n// Status: number;\n\n// /** IP address */\n// IP?: string;\n\n// /** Execution time */\n// Time?: string;\n\n// [key: string]: unknown;\n// }\n"],
5
+ "mappings": "AA2FO,IAAK,qBAAL,kBAAKA,wBAAL;AACL,EAAAA,oBAAA,aAAU;AACV,EAAAA,oBAAA,YAAS;AAFC,SAAAA;AAAA,GAAA;",
6
6
  "names": ["WebServerRouteType"]
7
7
  }