@adaas/a-server 0.0.22 → 0.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.
- package/.conf/tsconfig.base.json +79 -0
- package/.conf/tsconfig.browser.json +32 -0
- package/.conf/tsconfig.node.json +33 -0
- package/LICENSE +10 -19
- package/dist/browser/index.d.mts +1699 -0
- package/dist/browser/index.mjs +2935 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/node/A-Request.entity-8_9MCXT2.d.ts +533 -0
- package/dist/node/A-Request.entity-r905O60G.d.mts +533 -0
- package/dist/node/A-Response.entity-6qhiV7BE.d.mts +348 -0
- package/dist/node/A-Response.entity-bjh6bofZ.d.ts +348 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.d.mts +9 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.d.ts +9 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.js +13 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.js.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.mjs +12 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.mjs.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.d.mts +23 -0
- package/dist/node/channels/A-Http/A-Http.channel.d.ts +23 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.d.mts +7 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.d.ts +7 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.js +11 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.js.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.mjs +10 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.mjs.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.js +122 -0
- package/dist/node/channels/A-Http/A-Http.channel.js.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.mjs +110 -0
- package/dist/node/channels/A-Http/A-Http.channel.mjs.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.d.mts +67 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.d.ts +67 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.js +4 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.js.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.mjs +3 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.mjs.map +1 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.d.mts +7 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.d.ts +7 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.js +13 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.js.map +1 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.mjs +12 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.mjs.map +1 -0
- package/dist/node/chunk-EQQGB2QZ.mjs +15 -0
- package/dist/node/chunk-EQQGB2QZ.mjs.map +1 -0
- package/dist/node/constants/env.constants.d.mts +12 -0
- package/dist/node/constants/env.constants.d.ts +12 -0
- package/dist/node/constants/env.constants.js +23 -0
- package/dist/node/constants/env.constants.js.map +1 -0
- package/dist/node/constants/env.constants.mjs +22 -0
- package/dist/node/constants/env.constants.mjs.map +1 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.d.mts +29 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.d.ts +29 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.js +55 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.js.map +1 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.mjs +43 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.mjs.map +1 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.d.mts +44 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.d.ts +44 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.js +189 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.js.map +1 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.mjs +177 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.mjs.map +1 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.d.mts +2 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.d.ts +2 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.js +4 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.js.map +1 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.mjs +3 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.mjs.map +1 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.d.mts +28 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.d.ts +28 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.js +59 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.js.map +1 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.mjs +47 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.mjs.map +1 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.d.mts +2 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.d.ts +2 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.js +4 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.js.map +1 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.mjs +3 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.mjs.map +1 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.mts +30 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.ts +30 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js +46 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js.map +1 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.mjs +34 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.mjs.map +1 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.d.mts +2 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.d.ts +2 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.js +4 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.js.map +1 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.mjs +3 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.mjs.map +1 -0
- package/dist/node/index.d.mts +51 -0
- package/dist/node/index.d.ts +51 -0
- package/dist/node/index.js +320 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/index.mjs +48 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.d.mts +12 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.d.ts +12 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.js +25 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.js.map +1 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.mjs +24 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.d.mts +39 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.d.ts +39 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.js +56 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.js.map +1 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.mjs +55 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.constants.d.mts +18 -0
- package/dist/node/lib/A-Request/A-Request.constants.d.ts +18 -0
- package/dist/node/lib/A-Request/A-Request.constants.js +22 -0
- package/dist/node/lib/A-Request/A-Request.constants.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.constants.mjs +22 -0
- package/dist/node/lib/A-Request/A-Request.constants.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.entity.d.mts +17 -0
- package/dist/node/lib/A-Request/A-Request.entity.d.ts +17 -0
- package/dist/node/lib/A-Request/A-Request.entity.js +651 -0
- package/dist/node/lib/A-Request/A-Request.entity.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.entity.mjs +639 -0
- package/dist/node/lib/A-Request/A-Request.entity.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.env.d.mts +37 -0
- package/dist/node/lib/A-Request/A-Request.env.d.ts +37 -0
- package/dist/node/lib/A-Request/A-Request.env.js +39 -0
- package/dist/node/lib/A-Request/A-Request.env.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.env.mjs +38 -0
- package/dist/node/lib/A-Request/A-Request.env.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.error.d.mts +11 -0
- package/dist/node/lib/A-Request/A-Request.error.d.ts +11 -0
- package/dist/node/lib/A-Request/A-Request.error.js +15 -0
- package/dist/node/lib/A-Request/A-Request.error.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.error.mjs +14 -0
- package/dist/node/lib/A-Request/A-Request.error.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.helper.d.mts +105 -0
- package/dist/node/lib/A-Request/A-Request.helper.d.ts +105 -0
- package/dist/node/lib/A-Request/A-Request.helper.js +181 -0
- package/dist/node/lib/A-Request/A-Request.helper.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.helper.mjs +180 -0
- package/dist/node/lib/A-Request/A-Request.helper.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.types.d.mts +17 -0
- package/dist/node/lib/A-Request/A-Request.types.d.ts +17 -0
- package/dist/node/lib/A-Request/A-Request.types.js +14 -0
- package/dist/node/lib/A-Request/A-Request.types.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.types.mjs +14 -0
- package/dist/node/lib/A-Request/A-Request.types.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.constants.d.mts +24 -0
- package/dist/node/lib/A-Response/A-Response.constants.d.ts +24 -0
- package/dist/node/lib/A-Response/A-Response.constants.js +28 -0
- package/dist/node/lib/A-Response/A-Response.constants.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.constants.mjs +28 -0
- package/dist/node/lib/A-Response/A-Response.constants.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.entity.d.mts +20 -0
- package/dist/node/lib/A-Response/A-Response.entity.d.ts +20 -0
- package/dist/node/lib/A-Response/A-Response.entity.js +608 -0
- package/dist/node/lib/A-Response/A-Response.entity.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.entity.mjs +596 -0
- package/dist/node/lib/A-Response/A-Response.entity.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.env.d.mts +2 -0
- package/dist/node/lib/A-Response/A-Response.env.d.ts +2 -0
- package/dist/node/lib/A-Response/A-Response.env.js +4 -0
- package/dist/node/lib/A-Response/A-Response.env.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.env.mjs +3 -0
- package/dist/node/lib/A-Response/A-Response.env.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.error.d.mts +6 -0
- package/dist/node/lib/A-Response/A-Response.error.d.ts +6 -0
- package/dist/node/lib/A-Response/A-Response.error.js +10 -0
- package/dist/node/lib/A-Response/A-Response.error.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.error.mjs +9 -0
- package/dist/node/lib/A-Response/A-Response.error.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.types.d.mts +20 -0
- package/dist/node/lib/A-Response/A-Response.types.d.ts +20 -0
- package/dist/node/lib/A-Response/A-Response.types.js +4 -0
- package/dist/node/lib/A-Response/A-Response.types.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.types.mjs +3 -0
- package/dist/node/lib/A-Response/A-Response.types.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.d.mts +7 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.d.ts +7 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.js +11 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.mjs +11 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.d.mts +50 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.d.ts +50 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.js +196 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.mjs +184 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.d.mts +54 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.d.ts +54 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.js +118 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.mjs +117 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.d.mts +19 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.d.ts +19 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.js +4 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.mjs +3 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-Server.context.d.mts +22 -0
- package/dist/node/lib/A-Server/A-Server.context.d.ts +22 -0
- package/dist/node/lib/A-Server/A-Server.context.js +24 -0
- package/dist/node/lib/A-Server/A-Server.context.js.map +1 -0
- package/dist/node/lib/A-Server/A-Server.context.mjs +23 -0
- package/dist/node/lib/A-Server/A-Server.context.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-Server.error.d.mts +14 -0
- package/dist/node/lib/A-Server/A-Server.error.d.ts +14 -0
- package/dist/node/lib/A-Server/A-Server.error.js +26 -0
- package/dist/node/lib/A-Server/A-Server.error.js.map +1 -0
- package/dist/node/lib/A-Server/A-Server.error.mjs +25 -0
- package/dist/node/lib/A-Server/A-Server.error.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-Server.types.d.mts +26 -0
- package/dist/node/lib/A-Server/A-Server.types.d.ts +26 -0
- package/dist/node/lib/A-Server/A-Server.types.js +4 -0
- package/dist/node/lib/A-Server/A-Server.types.js.map +1 -0
- package/dist/node/lib/A-Server/A-Server.types.mjs +3 -0
- package/dist/node/lib/A-Server/A-Server.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.d.mts +29 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.d.ts +29 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.js +49 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.js.map +1 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.mjs +37 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.d.mts +2 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.d.ts +2 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.js +4 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.js.map +1 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.mjs +3 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.d.mts +49 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.d.ts +49 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.js +91 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.js.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.mjs +90 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.mjs.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.d.mts +22 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.d.ts +22 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.js +10 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.js.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.mjs +10 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.d.mts +13 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.d.ts +13 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.js +32 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.js.map +1 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.mjs +31 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.mjs.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.d.mts +48 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.d.ts +48 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.js +88 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.js.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.mjs +76 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.d.mts +24 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.d.ts +24 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.js +33 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.js.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.mjs +33 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.d.mts +12 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.d.ts +12 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.js +4 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.js.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.mjs +3 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.d.mts +6 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.d.ts +6 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.js +18 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.js.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.mjs +17 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.d.mts +2 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.d.ts +2 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.js +4 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.js.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.mjs +3 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.d.mts +2 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.d.ts +2 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.js +4 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.js.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.mjs +3 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.d.mts +31 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.d.ts +31 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.js +90 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.js.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.mjs +78 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.d.mts +9 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.d.ts +9 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.js +14 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.js.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.mjs +14 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.d.mts +36 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.d.ts +36 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.js +60 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.js.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.mjs +59 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.mjs.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.d.mts +23 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.d.ts +23 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.js +4 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.js.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.mjs +3 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.d.mts +20 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.d.ts +20 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.js +25 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.js.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.mjs +24 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.d.mts +15 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.d.ts +15 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.js +24 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.js.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.mjs +23 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.mjs.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.d.mts +6 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.d.ts +6 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.js +4 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.js.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.mjs +3 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.d.mts +84 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.d.ts +84 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.js +194 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.mjs +184 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.d.mts +6 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.d.ts +6 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.js +10 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.mjs +10 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.d.mts +16 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.d.ts +16 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.js +40 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.mjs +39 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.d.mts +24 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.d.ts +24 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.js +4 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.mjs +3 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.d.mts +16 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.d.ts +16 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.js +25 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.mjs +24 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.mjs.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.d.mts +65 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.d.ts +65 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.js +260 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.js.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.mjs +248 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.d.mts +110 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.d.ts +110 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.js +180 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.js.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.mjs +179 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.mjs.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.d.mts +8 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.d.ts +8 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.js +4 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.js.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.mjs +3 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.mjs.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.d.mts +29 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.d.ts +29 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.js +62 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.js.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.mjs +50 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.mjs.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.d.mts +5 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.d.ts +5 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.js +14 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.js.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.mjs +14 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.mjs.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.d.mts +9 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.d.ts +9 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.js +4 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.js.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.mjs +3 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.mjs.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.d.mts +24 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.d.ts +24 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.js +94 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.js.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.mjs +82 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.mjs.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.d.mts +2 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.d.ts +2 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.js +4 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.js.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.mjs +3 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.mjs.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.d.mts +2 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.d.ts +2 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.js +4 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.js.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.mjs +3 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.mjs.map +1 -0
- package/examples/simple-server/commands/SignIn.command.ts +17 -1
- package/examples/simple-server/components/Test.controller.ts +8 -7
- package/examples/simple-server/components/Users.repository.ts +28 -26
- package/examples/simple-server/concept.ts +56 -66
- package/examples/simple-server/entities/User/User.entity.ts +17 -7
- package/jest.config.ts +24 -10
- package/package.json +267 -25
- package/src/channels/A-Http/A-Http.channel.constants.ts +6 -7
- package/src/channels/A-Http/A-Http.channel.error.ts +2 -2
- package/src/channels/A-Http/A-Http.channel.ts +76 -125
- package/src/channels/A-Http/A-Http.channel.types.ts +6 -3
- package/src/channels/A-Websockets/A-Websockets.channel.ts +1 -1
- package/src/{components → controllers}/A-CommandController/A-CommandController.component.ts +16 -10
- package/src/{components → controllers}/A-EntityController/A-EntityController.component.ts +24 -28
- package/src/{components → controllers}/A-ListingController/A-ListingController.component.ts +10 -12
- package/src/{components → controllers}/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts +11 -11
- package/src/index.ts +58 -63
- package/src/lib/A-Request/A-HttpRequestData.context.ts +30 -0
- package/src/lib/A-Request/A-HttpServerRequest.context.ts +103 -0
- package/src/lib/A-Request/A-Request.constants.ts +30 -0
- package/src/lib/A-Request/A-Request.entity.ts +844 -0
- package/src/lib/A-Request/A-Request.env.ts +50 -0
- package/src/lib/A-Request/A-Request.error.ts +11 -0
- package/src/lib/A-Request/A-Request.helper.ts +276 -0
- package/src/lib/A-Request/A-Request.types.ts +284 -0
- package/src/lib/A-Request/README.md +567 -0
- package/src/lib/A-Response/A-Response.constants.ts +24 -0
- package/src/lib/A-Response/A-Response.entity.ts +751 -0
- package/src/lib/A-Response/A-Response.error.ts +6 -0
- package/src/lib/A-Response/A-Response.types.ts +127 -0
- package/src/lib/A-Response/README.md +793 -0
- package/src/lib/A-Server/A-HttpServer.constants.ts +9 -0
- package/src/lib/A-Server/A-HttpServer.container.ts +256 -0
- package/src/lib/A-Server/A-HttpServer.error.ts +165 -0
- package/src/lib/A-Server/A-HttpServer.types.ts +37 -0
- package/src/{context/A-Server/A_Server.context.ts → lib/A-Server/A-Server.context.ts} +6 -7
- package/src/lib/A-Server/A-Server.error.ts +26 -0
- package/src/{components/A-ServerError/A-ServerError.types.ts → lib/A-Server/A-Server.types.ts} +8 -0
- package/src/{components/A-Controller/A-Controller.component.ts → lib/A-ServerController/A-ServerController.component.ts} +5 -5
- package/src/{entities/A_EntityList/A_EntityList.entity.ts → lib/A-ServerEntityList/A-EntityList.entity.ts} +2 -2
- package/src/{entities/A_EntityList/A_EntityList.entity.types.ts → lib/A-ServerEntityList/A-EntityList.types.ts} +2 -2
- package/src/{context/A-ListQueryFilter/A_ListQueryFilter.context.ts → lib/A-ServerListQuery/A-ServerListQueryFilter.context.ts} +1 -1
- package/src/lib/A-ServerLogger/A-ServerLogger.component.ts +121 -0
- package/src/lib/A-ServerLogger/A-ServerLogger.types.ts +13 -0
- package/src/lib/A-ServerMiddleware/A-ServerMiddleware.component.ts +17 -0
- package/src/{components → lib}/A-ServerProxy/A-ServerProxy.component.ts +17 -12
- package/src/{context/A-ProxyConfig/A_ProxyConfig.constants.ts → lib/A-ServerProxy/A-ServerProxy.constants.ts} +1 -1
- package/src/{context/A-ProxyConfig/A_ProxyConfig.context.ts → lib/A-ServerProxy/A-ServerProxy.context.ts} +4 -4
- package/src/{context/A-ProxyConfig/A_ProxyConfig.types.ts → lib/A-ServerProxy/A-ServerProxy.types.ts} +4 -4
- package/src/lib/A-ServerRoute/A-ServerRoute.constants.ts +20 -0
- package/src/lib/A-ServerRoute/A-ServerRoute.entity.ts +48 -0
- package/src/lib/A-ServerRoute/A-ServerRoute.types.ts +6 -0
- package/src/{components/A-Router/A-Router.component.ts → lib/A-ServerRouter/A-ServerRouter.component.ts} +77 -97
- package/src/lib/A-ServerRouter/A-ServerRouter.constants.ts +8 -0
- package/src/lib/A-ServerRouter/A-ServerRouter.meta.ts +48 -0
- package/src/lib/A-ServerRouter/A-ServerRouter.types.ts +27 -0
- package/src/lib/A-ServerRouter/A-ServerRouterDefine.decorator.ts +37 -0
- package/src/{components/A-StaticLoader/A-StaticLoader.component.ts → lib/A-ServerStatic/A-ServerStatic.component.ts} +73 -54
- package/src/{context/A-StaticConfig/A-StaticConfig.context.ts → lib/A-ServerStatic/A-ServerStatic.context.ts} +16 -6
- package/src/{components → middlewares}/A-ServerCORS/A_ServerCORS.component.ts +16 -13
- package/src/{components/A-ServerCORS/A_ServerCORS.component.defaults.ts → middlewares/A-ServerCORS/A_ServerCORS.constants.ts} +2 -2
- package/src/{components → repositories}/A-EntityRepository/A-EntityRepository.component.ts +39 -30
- package/tests/A-HttpChannel.test.ts +41 -48
- package/tests/A-HttpServerError.test.ts +204 -0
- package/tests/A-Request.test.ts +351 -0
- package/tsconfig.json +40 -50
- package/tsup.config.ts +111 -13
- package/dist/index.d.mts +0 -855
- package/dist/index.d.ts +0 -855
- package/dist/index.js +0 -2179
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2144
- package/dist/index.mjs.map +0 -1
- package/examples/microservices-server/components/controllers/Statistics.controller.ts +0 -18
- package/examples/microservices-server/components/repositories/Memory.repository.ts +0 -66
- package/examples/microservices-server/concept.ts +0 -43
- package/examples/microservices-server/context/MemoryStore.context.ts +0 -31
- package/examples/microservices-server/entities/Order.entity.ts +0 -7
- package/examples/microservices-server/entities/User.entity.ts +0 -8
- package/src/components/A-Router/A-Router.component.types.ts +0 -38
- package/src/components/A-ServerError/A-ServerError.class.ts +0 -98
- package/src/components/A-ServerLogger/A_ServerLogger.component.ts +0 -194
- package/src/components/A-ServerLogger/A_ServerLogger.component.types.ts +0 -14
- package/src/containers/A-Service/A-Service.container.ts +0 -218
- package/src/containers/A-Service/A-Service.container.types.ts +0 -46
- package/src/context/A-EntityFactory/A-EntityFactory.context.ts +0 -163
- package/src/context/A-EntityFactory/A-EntityFactory.context.types.ts +0 -11
- package/src/context/A-HttpChannel/A-HttpChannel.context.ts +0 -36
- package/src/context/A-Server/A_Server.context.types.ts +0 -9
- package/src/entities/A-Request/A-Request.entity.ts +0 -163
- package/src/entities/A-Request/A-Request.entity.types.ts +0 -41
- package/src/entities/A-Response/A-Response.entity.ts +0 -194
- package/src/entities/A-Response/A-Response.entity.types.ts +0 -26
- package/src/entities/A-Route/A-Route.entity.ts +0 -117
- package/tests/A-Service.test.ts +0 -18
- /package/src/{components → controllers}/A-EntityController/A-EntityController.component.types.ts +0 -0
- /package/src/{components/A-Controller/A-Controller.component.types.ts → controllers/A-ListingController/A-ListingController.types.ts} +0 -0
- /package/src/{components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.ts → controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.ts} +0 -0
- /package/src/{components/A-EntityRepository/A-EntityRepository.error.ts → lib/A-Response/A-Response.env.ts} +0 -0
- /package/src/{components/A-EntityRepository/A-EntityRepository.types.ts → lib/A-ServerController/A-ServerController.types.ts} +0 -0
- /package/src/{components → lib}/A-ServerLogger/A-ServerLogger.constants.ts +0 -0
- /package/src/{components/A-ListingController/A-ListingController.component.types.ts → lib/A-ServerMiddleware/A-ServerMiddleware.constants.ts} +0 -0
- /package/src/{components/A-ServerError/A-ServerError.constants.ts → lib/A-ServerMiddleware/A-ServerMiddleware.types.ts} +0 -0
- /package/src/{components/A-StaticLoader/A-StaticLoader.component.types.ts → lib/A-ServerStatic/A-ServerStatic.types.ts} +0 -0
- /package/src/{components/A-ServerCORS/A_ServerCORS.component.types.ts → middlewares/A-ServerCORS/A_ServerCORS.types.ts} +0 -0
- /package/src/{context/A-StaticConfig/A-StaticConfig.context.types.ts → repositories/A-EntityRepository/A-EntityRepository.error.ts} +0 -0
- /package/src/{entities/A-Route/A-Route.entity.types.ts → repositories/A-EntityRepository/A-EntityRepository.types.ts} +0 -0
|
@@ -0,0 +1,844 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders, IncomingMessage } from "http";
|
|
2
|
+
import {
|
|
3
|
+
A_Context,
|
|
4
|
+
A_Entity,
|
|
5
|
+
A_Error,
|
|
6
|
+
A_Feature,
|
|
7
|
+
A_IdentityHelper,
|
|
8
|
+
A_Inject,
|
|
9
|
+
A_Scope,
|
|
10
|
+
ASEID,
|
|
11
|
+
} from '@adaas/a-concept';
|
|
12
|
+
import {
|
|
13
|
+
A_Request_BodyType,
|
|
14
|
+
A_Request_FileUpload,
|
|
15
|
+
A_Request_Init,
|
|
16
|
+
A_Request_Listener,
|
|
17
|
+
A_Request_Options,
|
|
18
|
+
A_Request_Serialized,
|
|
19
|
+
A_RequestFeatureNames,
|
|
20
|
+
} from "./A-Request.types";
|
|
21
|
+
import { A_HttpServerError } from "@adaas/a-server/server/A-HttpServer.error";
|
|
22
|
+
import { A_HttpServerRequestMethod } from "@adaas/a-server/server/A-HttpServer.types";
|
|
23
|
+
import { A_RequestFeatures } from "./A-Request.constants";
|
|
24
|
+
import { A_RequestHelper } from "./A-Request.helper";
|
|
25
|
+
import { A_RequestEnvVariables, A_RequestEnvVariablesType } from "./A-Request.env";
|
|
26
|
+
import { A_HttpServerRequestContext } from "./A-HttpServerRequest.context";
|
|
27
|
+
import { A_HttpRequestData } from "./A-HttpRequestData.context";
|
|
28
|
+
import { A_RequestError } from "./A-Request.error";
|
|
29
|
+
import { A_ScheduleObject } from "@adaas/a-utils/a-schedule";
|
|
30
|
+
import { A_Config } from "@adaas/a-utils/a-config";
|
|
31
|
+
import { A_ServerRoute } from "@adaas/a-server/route/A-ServerRoute.entity";
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export class A_Request<
|
|
36
|
+
_ReqBodyType = any,
|
|
37
|
+
_ParamsType extends Record<string, string> = any,
|
|
38
|
+
_QueryType = any,
|
|
39
|
+
>
|
|
40
|
+
extends A_Entity<
|
|
41
|
+
A_Request_Init,
|
|
42
|
+
A_Request_Serialized<_ReqBodyType, _ParamsType, _QueryType>
|
|
43
|
+
> {
|
|
44
|
+
|
|
45
|
+
static get concept(): string {
|
|
46
|
+
return 'a-server';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// =============================================
|
|
50
|
+
// Core Properties
|
|
51
|
+
// =============================================
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Request processing status
|
|
55
|
+
*/
|
|
56
|
+
protected _listeners: Map<A_RequestFeatureNames, Set<A_Request_Listener>> = new Map();
|
|
57
|
+
|
|
58
|
+
// =============================================
|
|
59
|
+
// Cookie Management
|
|
60
|
+
// =============================================
|
|
61
|
+
/**
|
|
62
|
+
* Parsed cookies from request headers
|
|
63
|
+
*/
|
|
64
|
+
private _cookies!: Record<string, string>;
|
|
65
|
+
|
|
66
|
+
// ============================================
|
|
67
|
+
// Data Management
|
|
68
|
+
// ============================================
|
|
69
|
+
/**
|
|
70
|
+
* Request body type
|
|
71
|
+
*/
|
|
72
|
+
private _bodyType?: A_Request_BodyType;
|
|
73
|
+
/**
|
|
74
|
+
* Request body data
|
|
75
|
+
*/
|
|
76
|
+
private _body!: _ReqBodyType;
|
|
77
|
+
private _req!: IncomingMessage;
|
|
78
|
+
|
|
79
|
+
private _timeout: A_ScheduleObject | undefined;
|
|
80
|
+
|
|
81
|
+
// =============================================
|
|
82
|
+
// File Upload Handling
|
|
83
|
+
// =============================================
|
|
84
|
+
/**
|
|
85
|
+
* Uploaded files from multipart requests
|
|
86
|
+
*/
|
|
87
|
+
private _files!: A_Request_FileUpload[];
|
|
88
|
+
|
|
89
|
+
// =============================================
|
|
90
|
+
// Request Metadata
|
|
91
|
+
// =============================================
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* User agent string from request headers
|
|
95
|
+
*/
|
|
96
|
+
private _userAgent?: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Content length in bytes
|
|
100
|
+
*/
|
|
101
|
+
private _contentLength?: number;
|
|
102
|
+
|
|
103
|
+
// =============================================
|
|
104
|
+
// Configuration
|
|
105
|
+
// =============================================
|
|
106
|
+
/**
|
|
107
|
+
* Request processing configuration options
|
|
108
|
+
*/
|
|
109
|
+
private _options!: Required<A_Request_Options>
|
|
110
|
+
|
|
111
|
+
private _routeDefinition?: A_ServerRoute;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A_Request - Comprehensive HTTP Request Processing Entity
|
|
116
|
+
*
|
|
117
|
+
* This class provides a complete wrapper around Node.js IncomingMessage with advanced features:
|
|
118
|
+
* - Automatic body parsing (JSON, form-data, multipart, raw)
|
|
119
|
+
* - Cookie and session management
|
|
120
|
+
* - File upload handling with easy access methods
|
|
121
|
+
* - Request validation
|
|
122
|
+
* - Middleware support
|
|
123
|
+
* - Type-safe parameter extraction
|
|
124
|
+
* - Request timing and metrics
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const request = new A_Request({
|
|
129
|
+
* id: 'req-123',
|
|
130
|
+
* request: incomingMessage,
|
|
131
|
+
* scope: 'api'
|
|
132
|
+
* }, {
|
|
133
|
+
* enableFileUploads: true,
|
|
134
|
+
* maxBodySize: 50 * 1024 * 1024 // 50MB for file uploads
|
|
135
|
+
* });
|
|
136
|
+
*
|
|
137
|
+
* await request.init();
|
|
138
|
+
*
|
|
139
|
+
* // Access parsed body
|
|
140
|
+
* const userData = request.body;
|
|
141
|
+
*
|
|
142
|
+
* // Get typed parameters
|
|
143
|
+
* const userId = request.params.id;
|
|
144
|
+
*
|
|
145
|
+
* // Handle file uploads
|
|
146
|
+
* if (request.hasFiles()) {
|
|
147
|
+
* const avatar = request.getFile('avatar');
|
|
148
|
+
* if (avatar) {
|
|
149
|
+
* console.log(`Uploaded file: ${avatar.filename}`);
|
|
150
|
+
* console.log(`File size: ${avatar.size} bytes`);
|
|
151
|
+
* console.log(`File type: ${avatar.mimetype}`);
|
|
152
|
+
*
|
|
153
|
+
* // Access file buffer for processing
|
|
154
|
+
* const fileBuffer = avatar.buffer;
|
|
155
|
+
* // Save to disk, process, etc.
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
* // Get all files for a specific field
|
|
159
|
+
* const documents = request.getFiles('documents');
|
|
160
|
+
* for (const doc of documents) {
|
|
161
|
+
* // Process each document...
|
|
162
|
+
* }
|
|
163
|
+
* }
|
|
164
|
+
*
|
|
165
|
+
* // Check specific files
|
|
166
|
+
* if (request.hasFile('profilePicture')) {
|
|
167
|
+
* const pic = request.getFile('profilePicture');
|
|
168
|
+
* // Process profile picture...
|
|
169
|
+
* }
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
constructor(params: A_Request_Init, options?: A_Request_Options) {
|
|
173
|
+
super(params);
|
|
174
|
+
this._options = {
|
|
175
|
+
maxBodySize: 10 * 1024 * 1024, // 10MB default
|
|
176
|
+
timeout: 30000, // 30 seconds
|
|
177
|
+
encoding: 'utf8',
|
|
178
|
+
parseCookies: true,
|
|
179
|
+
parseQuery: true,
|
|
180
|
+
parseBody: true,
|
|
181
|
+
enableFileUploads: false,
|
|
182
|
+
strictValidation: false,
|
|
183
|
+
...(options || {})
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Creates A_Request entity from initialization data
|
|
189
|
+
*
|
|
190
|
+
* @param newEntity
|
|
191
|
+
*/
|
|
192
|
+
fromNew(newEntity: A_Request_Init): void {
|
|
193
|
+
this.aseid = new ASEID({
|
|
194
|
+
concept: (this.constructor as typeof A_Request).concept,
|
|
195
|
+
scope: newEntity.scope,
|
|
196
|
+
entity: (this.constructor as typeof A_Request).entity,
|
|
197
|
+
shard: newEntity.shard,
|
|
198
|
+
id: newEntity.id
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
this._req = newEntity.request;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Core HTTP request object from Node.js
|
|
207
|
+
*/
|
|
208
|
+
get original(): IncomingMessage {
|
|
209
|
+
return this._req;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Parsed request body data
|
|
213
|
+
*/
|
|
214
|
+
get body(): _ReqBodyType {
|
|
215
|
+
return this._body;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* URL route parameters (e.g., /users/:id)
|
|
219
|
+
*/
|
|
220
|
+
get params(): _ParamsType {
|
|
221
|
+
|
|
222
|
+
console.log('Extracting params using route definition:', this.url);
|
|
223
|
+
console.log('Extracting params using route definition:', this._routeDefinition?.path);
|
|
224
|
+
|
|
225
|
+
return A_RequestHelper.extractParams(this.url,
|
|
226
|
+
this._routeDefinition?.path || ''
|
|
227
|
+
|
|
228
|
+
) as _ParamsType;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Query string parameters
|
|
232
|
+
*/
|
|
233
|
+
get query(): _QueryType {
|
|
234
|
+
return A_RequestHelper.extractQuery(this.url) as _QueryType;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Gets the parsed cookies
|
|
238
|
+
*/
|
|
239
|
+
get cookies(): Record<string, string> {
|
|
240
|
+
if (!this._cookies) {
|
|
241
|
+
this._cookies = A_RequestHelper.parseCookies(this.headers['cookie']);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return this._cookies;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Gets the request URL
|
|
248
|
+
*/
|
|
249
|
+
get url(): string {
|
|
250
|
+
return this.original.url!;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Gets the HTTP method
|
|
254
|
+
*/
|
|
255
|
+
get method(): A_HttpServerRequestMethod {
|
|
256
|
+
return (String(this.original.method).toUpperCase() as A_HttpServerRequestMethod) || 'DEFAULT';
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Gets the request headers
|
|
260
|
+
*/
|
|
261
|
+
get headers(): IncomingHttpHeaders {
|
|
262
|
+
return this.original.headers;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Gets the timestamp when the request was started
|
|
266
|
+
*/
|
|
267
|
+
get startedAt(): Date | undefined {
|
|
268
|
+
const timeId = A_IdentityHelper.parseTimeId(this.aseid.id.split('-')[0]);
|
|
269
|
+
return timeId ? new Date(timeId.timestamp) : undefined;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Gets uploaded files
|
|
273
|
+
*/
|
|
274
|
+
get files(): A_Request_FileUpload[] {
|
|
275
|
+
return this._files || [];
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Gets user agent string
|
|
279
|
+
*/
|
|
280
|
+
get userAgent(): string | undefined {
|
|
281
|
+
return this.headers?.['user-agent'] || ''
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Gets content length
|
|
285
|
+
*/
|
|
286
|
+
get contentLength(): number {
|
|
287
|
+
return this.headers?.['content-length'] ? parseInt(this.headers['content-length'], 10) : 0;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Check if request is secure (HTTPS)
|
|
291
|
+
*/
|
|
292
|
+
get isSecure(): boolean {
|
|
293
|
+
return this.original.socket && 'encrypted' in this.original.socket;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Check if request is from mobile device
|
|
297
|
+
*/
|
|
298
|
+
get isMobile(): boolean {
|
|
299
|
+
const userAgent = this._userAgent?.toLowerCase() || '';
|
|
300
|
+
return /mobile|android|iphone|ipad|phone/i.test(userAgent);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get request size in bytes
|
|
304
|
+
*/
|
|
305
|
+
get size(): number {
|
|
306
|
+
return this._contentLength || 0;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Gets content type from headers
|
|
310
|
+
*/
|
|
311
|
+
get contentType(): string | undefined {
|
|
312
|
+
return this.headers['content-type'] || undefined;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Pipes request stream to destination
|
|
331
|
+
*/
|
|
332
|
+
pipe(
|
|
333
|
+
destination: NodeJS.WritableStream,
|
|
334
|
+
options?: { end?: boolean | undefined; }
|
|
335
|
+
): NodeJS.WritableStream {
|
|
336
|
+
return this.original.pipe(destination, options);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Get a file by field name
|
|
340
|
+
*/
|
|
341
|
+
getFile(fieldName: string): A_Request_FileUpload | undefined {
|
|
342
|
+
return this._files?.find(file => file.fieldName === fieldName);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Get all files for a specific field name
|
|
347
|
+
*/
|
|
348
|
+
getFiles(fieldName: string): A_Request_FileUpload[] {
|
|
349
|
+
return this._files?.filter(file => file.fieldName === fieldName) || [];
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Check if request has any files
|
|
354
|
+
*/
|
|
355
|
+
hasFiles(): boolean {
|
|
356
|
+
return this._files && this._files.length > 0;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Check if request has a file with specific field name
|
|
361
|
+
*/
|
|
362
|
+
hasFile(fieldName: string): boolean {
|
|
363
|
+
return this._files?.some(file => file.fieldName === fieldName) || false;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Get total size of all uploaded files
|
|
368
|
+
*/
|
|
369
|
+
getTotalFileSize(): number {
|
|
370
|
+
return this._files?.reduce((total, file) => total + file.size, 0) || 0;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Get a cookie value
|
|
375
|
+
*/
|
|
376
|
+
getCookie(name: string): string | undefined {
|
|
377
|
+
return this._cookies[name];
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Check if request has a specific cookie
|
|
381
|
+
*/
|
|
382
|
+
hasCookie(name: string): boolean {
|
|
383
|
+
return name in this._cookies;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Check if request accepts specific content type
|
|
387
|
+
*/
|
|
388
|
+
accepts(contentType: string): boolean {
|
|
389
|
+
const acceptHeader = this.headers.accept || '';
|
|
390
|
+
return acceptHeader.includes(contentType) || acceptHeader.includes('*/*');
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Get request fingerprint for caching/identification
|
|
394
|
+
*/
|
|
395
|
+
getFingerprint(): string {
|
|
396
|
+
const components = [
|
|
397
|
+
this.method,
|
|
398
|
+
this.url,
|
|
399
|
+
this._userAgent,
|
|
400
|
+
JSON.stringify(this.body)
|
|
401
|
+
];
|
|
402
|
+
|
|
403
|
+
return Buffer.from(components.join('|')).toString('base64');
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// --------------------------------------------------------------------------
|
|
407
|
+
// A-Request Event-Emitter methods
|
|
408
|
+
// --------------------------------------------------------------------------
|
|
409
|
+
/**
|
|
410
|
+
* Registers an event listener for a specific event
|
|
411
|
+
*
|
|
412
|
+
* @param event
|
|
413
|
+
* @param listener
|
|
414
|
+
*/
|
|
415
|
+
on(event: A_RequestFeatureNames, listener: A_Request_Listener) {
|
|
416
|
+
if (!this._listeners.has(event)) {
|
|
417
|
+
this._listeners.set(event, new Set());
|
|
418
|
+
}
|
|
419
|
+
this._listeners.get(event)!.add(listener);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Removes an event listener for a specific event
|
|
423
|
+
*
|
|
424
|
+
* @param event
|
|
425
|
+
* @param listener
|
|
426
|
+
*/
|
|
427
|
+
off(event: A_RequestFeatureNames, listener: A_Request_Listener) {
|
|
428
|
+
this._listeners.get(event)?.delete(listener);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Emits an event to all registered listeners
|
|
432
|
+
*
|
|
433
|
+
* @param event
|
|
434
|
+
*/
|
|
435
|
+
emit(event: A_RequestFeatureNames) {
|
|
436
|
+
this._listeners.get(event)?.forEach(async listener => {
|
|
437
|
+
listener(this);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Allows to use a route definition for this request
|
|
443
|
+
*
|
|
444
|
+
* @param route
|
|
445
|
+
*/
|
|
446
|
+
useRoute(route: A_ServerRoute): void {
|
|
447
|
+
this._routeDefinition = route;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
clearTimeout(): void {
|
|
452
|
+
this._timeout?.clear();
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Initialize the request - parse cookies, query, body etc.
|
|
457
|
+
*/
|
|
458
|
+
async load(): Promise<void> {
|
|
459
|
+
|
|
460
|
+
// this.original.on('close', this.handleClose.bind(this));
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
|
|
464
|
+
await this.call(A_RequestFeatures.onInit);
|
|
465
|
+
|
|
466
|
+
await new Promise<void>((resolve, reject) => {
|
|
467
|
+
const onData = this.handleData.bind(this);
|
|
468
|
+
const onEnd = () => {
|
|
469
|
+
cleanup();
|
|
470
|
+
resolve();
|
|
471
|
+
};
|
|
472
|
+
const onError = (err: Error) => {
|
|
473
|
+
cleanup();
|
|
474
|
+
reject(err);
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
const cleanup = () => {
|
|
478
|
+
this.original.off('data', onData);
|
|
479
|
+
this.original.off('end', onEnd);
|
|
480
|
+
this.original.off('error', onError);
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
this.original.on('data', onData);
|
|
484
|
+
this.original.on('end', onEnd);
|
|
485
|
+
this.original.on('error', onError);
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
await this.handleEnd();
|
|
489
|
+
|
|
490
|
+
} catch (error) {
|
|
491
|
+
|
|
492
|
+
const targetError = error instanceof A_HttpServerError
|
|
493
|
+
? error
|
|
494
|
+
: new A_HttpServerError({
|
|
495
|
+
status: 500,
|
|
496
|
+
description: 'An error occurred while processing the request.',
|
|
497
|
+
originalError: error
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
await this.fail(targetError);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
this.original.on('error', err => {
|
|
504
|
+
this.fail(new A_HttpServerError({
|
|
505
|
+
status: 500,
|
|
506
|
+
description: `Request error: ${err.message}`,
|
|
507
|
+
originalError: err
|
|
508
|
+
}));
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
async validate(): Promise<void> {
|
|
514
|
+
try {
|
|
515
|
+
await this.call(A_RequestFeatures.onValidate);
|
|
516
|
+
} catch (error) {
|
|
517
|
+
const targetError = error instanceof A_HttpServerError
|
|
518
|
+
? error
|
|
519
|
+
: new A_HttpServerError({
|
|
520
|
+
status: 400,
|
|
521
|
+
description: ` Request Validation Failed: ${error instanceof A_Error ? error.message : 'Invalid request.'}`,
|
|
522
|
+
originalError: error
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
await this.fail(targetError);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Destroy the request A-Entity with cleanup
|
|
530
|
+
*
|
|
531
|
+
* @returns
|
|
532
|
+
*/
|
|
533
|
+
async destroy(): Promise<any> {
|
|
534
|
+
const targetError = A_Context.scope(this)?.resolve(A_Error);
|
|
535
|
+
|
|
536
|
+
if (!this.original.destroyed) {
|
|
537
|
+
this.original.destroy(targetError);
|
|
538
|
+
this.original.removeAllListeners();
|
|
539
|
+
|
|
540
|
+
this._listeners.clear();
|
|
541
|
+
|
|
542
|
+
return super.destroy();
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Handles request failure - registers error, emits event, and destroys request
|
|
548
|
+
*
|
|
549
|
+
* [!] Destroys the request after handling the failure.
|
|
550
|
+
*
|
|
551
|
+
* @param err
|
|
552
|
+
*/
|
|
553
|
+
async fail(err?: A_HttpServerError): Promise<void> {
|
|
554
|
+
console.log('Request failed with error:', this.method, this.url, err?.message);
|
|
555
|
+
|
|
556
|
+
if (err)
|
|
557
|
+
A_Context
|
|
558
|
+
.scope(this)
|
|
559
|
+
.register(err);
|
|
560
|
+
|
|
561
|
+
this._timeout?.clear();
|
|
562
|
+
|
|
563
|
+
await this.call(A_RequestFeatures.onError);
|
|
564
|
+
|
|
565
|
+
await this.destroy();
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
// ======================================================================================
|
|
570
|
+
// Internal handlers for request events
|
|
571
|
+
// ======================================================================================
|
|
572
|
+
/**
|
|
573
|
+
* Internal helper method to handle incoming data chunks
|
|
574
|
+
* It creates a new scope for each data chunk, inherits the parent scope,
|
|
575
|
+
* and calls the onData feature with the new scope.
|
|
576
|
+
*
|
|
577
|
+
* [!] This method ensures that each data chunk is processed in isolation,
|
|
578
|
+
* preventing side effects between chunks.
|
|
579
|
+
*
|
|
580
|
+
* @param data
|
|
581
|
+
*/
|
|
582
|
+
protected async handleData(data: Buffer): Promise<void> {
|
|
583
|
+
const chunk = new A_HttpRequestData(data);
|
|
584
|
+
|
|
585
|
+
const scope = new A_Scope({
|
|
586
|
+
name: `${this.aseid.toString()}-data-chunk`,
|
|
587
|
+
fragments: [chunk],
|
|
588
|
+
})
|
|
589
|
+
.inherit(A_Context.scope(this));
|
|
590
|
+
|
|
591
|
+
try {
|
|
592
|
+
|
|
593
|
+
scope.inherit(A_Context.scope(this));
|
|
594
|
+
|
|
595
|
+
await this.call(A_RequestFeatures.onData, scope);
|
|
596
|
+
|
|
597
|
+
scope.destroy();
|
|
598
|
+
|
|
599
|
+
} catch (error) {
|
|
600
|
+
|
|
601
|
+
scope.destroy();
|
|
602
|
+
|
|
603
|
+
await this.fail(new A_HttpServerError({
|
|
604
|
+
status: 500,
|
|
605
|
+
description: `Request data chunk error: ${error instanceof A_Error ? error.message : 'Unable to process request data chunk.'}`,
|
|
606
|
+
originalError: error
|
|
607
|
+
}));
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Handles request close event
|
|
613
|
+
*
|
|
614
|
+
* This method is called when the request is closed prematurely.
|
|
615
|
+
* It triggers the onClose feature and handles any errors that occur during processing.
|
|
616
|
+
*
|
|
617
|
+
*/
|
|
618
|
+
protected async handleClose(): Promise<void> {
|
|
619
|
+
try {
|
|
620
|
+
await this.call(A_RequestFeatures.onClose);
|
|
621
|
+
} catch (error) {
|
|
622
|
+
|
|
623
|
+
await this.fail(new A_HttpServerError({
|
|
624
|
+
status: 499,
|
|
625
|
+
description: `Request closed error: ${error instanceof A_Error ? error.message : 'Request was closed.'}`,
|
|
626
|
+
originalError: error
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Handles request end event
|
|
633
|
+
*
|
|
634
|
+
* This method is called when the request has finished sending data.
|
|
635
|
+
* It triggers the onEnd feature and handles any errors that occur during processing.
|
|
636
|
+
*/
|
|
637
|
+
protected async handleEnd(): Promise<void> {
|
|
638
|
+
try {
|
|
639
|
+
|
|
640
|
+
await this.call(A_RequestFeatures.onEnd);
|
|
641
|
+
|
|
642
|
+
} catch (error) {
|
|
643
|
+
await this.fail(new A_HttpServerError({
|
|
644
|
+
status: 500,
|
|
645
|
+
description: `Request processing error: ${error instanceof A_Error ? error.message : 'Unable to process request.'}`,
|
|
646
|
+
originalError: error
|
|
647
|
+
}));
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Handles request timeout event
|
|
653
|
+
*
|
|
654
|
+
* This method is called when the request processing exceeds the configured timeout.
|
|
655
|
+
* It triggers the onTimeout feature and fails the request with a timeout error.
|
|
656
|
+
*/
|
|
657
|
+
protected async handleTimeout(): Promise<void> {
|
|
658
|
+
try {
|
|
659
|
+
await this.call(A_RequestFeatures.onTimeout);
|
|
660
|
+
|
|
661
|
+
throw new A_HttpServerError({
|
|
662
|
+
status: 503,
|
|
663
|
+
description: `Request processing take too long and timed out. Current timeout is set to ${this._options.timeout} ms.`,
|
|
664
|
+
})
|
|
665
|
+
|
|
666
|
+
} catch (error) {
|
|
667
|
+
|
|
668
|
+
const targetError = error instanceof A_HttpServerError
|
|
669
|
+
? error
|
|
670
|
+
: new A_HttpServerError({
|
|
671
|
+
status: 503,
|
|
672
|
+
description: `Request timeout error: ${error instanceof A_Error ? error.message : 'Request timed out.'}`,
|
|
673
|
+
originalError: error
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
await this.fail(targetError);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
// ======================================================================================
|
|
684
|
+
// A-Request Feature Extensions
|
|
685
|
+
// ======================================================================================
|
|
686
|
+
|
|
687
|
+
@A_Feature.Extend()
|
|
688
|
+
/**
|
|
689
|
+
* Hook called during initialization
|
|
690
|
+
*
|
|
691
|
+
* Default Behavior: Starts request processing timer and sets up timeout handling.
|
|
692
|
+
*/
|
|
693
|
+
async [A_RequestFeatures.onInit](
|
|
694
|
+
@A_Inject(A_Config) config: A_Config<['A_SERVER_REQUEST_TIMEOUT']>,
|
|
695
|
+
@A_Inject(A_HttpServerRequestContext) context: A_HttpServerRequestContext,
|
|
696
|
+
...args: any[]
|
|
697
|
+
): Promise<void> {
|
|
698
|
+
|
|
699
|
+
context.startProcessing();
|
|
700
|
+
|
|
701
|
+
const ms = Number(config?.get('A_SERVER_REQUEST_TIMEOUT')
|
|
702
|
+
|| A_RequestEnvVariables.A_SERVER_REQUEST_TIMEOUT);
|
|
703
|
+
|
|
704
|
+
this._timeout = new A_ScheduleObject(ms, this.handleTimeout.bind(this), { resolveOnClear: true });
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
@A_Feature.Extend({
|
|
709
|
+
before: /.*/
|
|
710
|
+
})
|
|
711
|
+
/**
|
|
712
|
+
* Hook called on receiving data chunk
|
|
713
|
+
*
|
|
714
|
+
* Default Behavior: Accumulates data chunks into context buffers and checks for max body size.
|
|
715
|
+
*/
|
|
716
|
+
async [A_RequestFeatures.onData](
|
|
717
|
+
@A_Inject(A_HttpServerRequestContext) context: A_HttpServerRequestContext,
|
|
718
|
+
@A_Inject(A_HttpRequestData) chunk: A_HttpRequestData,
|
|
719
|
+
...args: any[]
|
|
720
|
+
): Promise<void> {
|
|
721
|
+
|
|
722
|
+
if (context.length + chunk.length > this._options.maxBodySize!) {
|
|
723
|
+
throw new A_RequestError(
|
|
724
|
+
A_RequestError.RequestBodyParsingError,
|
|
725
|
+
`Request body too large. Max size is ${this._options.maxBodySize} bytes.`
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
context.buffers.push(chunk.data);
|
|
730
|
+
if (!context.data)
|
|
731
|
+
context.data = '';
|
|
732
|
+
|
|
733
|
+
context.data += chunk.toString(this._options.encoding as BufferEncoding);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
@A_Feature.Extend({
|
|
737
|
+
before: /.*/
|
|
738
|
+
})
|
|
739
|
+
/**
|
|
740
|
+
* Hook called on request timeout
|
|
741
|
+
*
|
|
742
|
+
* Default Behavior: Stops request processing and emits timeout event.
|
|
743
|
+
*
|
|
744
|
+
* @param context
|
|
745
|
+
* @param args
|
|
746
|
+
*/
|
|
747
|
+
async [A_RequestFeatures.onTimeout](
|
|
748
|
+
@A_Inject(A_HttpServerRequestContext) context: A_HttpServerRequestContext,
|
|
749
|
+
...args: any[]
|
|
750
|
+
): Promise<void> {
|
|
751
|
+
context.stopProcessing();
|
|
752
|
+
|
|
753
|
+
this._timeout?.clear();
|
|
754
|
+
|
|
755
|
+
this.emit(A_RequestFeatures.onTimeout);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
@A_Feature.Extend({
|
|
759
|
+
before: /.*/
|
|
760
|
+
})
|
|
761
|
+
/**
|
|
762
|
+
* Hook called on request close
|
|
763
|
+
*/
|
|
764
|
+
async [A_RequestFeatures.onClose](
|
|
765
|
+
@A_Inject(A_HttpServerRequestContext) context: A_HttpServerRequestContext,
|
|
766
|
+
...args: any[]
|
|
767
|
+
): Promise<void> {
|
|
768
|
+
|
|
769
|
+
this.emit(A_RequestFeatures.onClose);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
@A_Feature.Extend({
|
|
774
|
+
after: /.*/
|
|
775
|
+
})
|
|
776
|
+
/**
|
|
777
|
+
* Hook called on request error
|
|
778
|
+
*/
|
|
779
|
+
async [A_RequestFeatures.onError](
|
|
780
|
+
@A_Inject(A_Error) error: A_Error,
|
|
781
|
+
@A_Inject(A_HttpServerRequestContext) context: A_HttpServerRequestContext,
|
|
782
|
+
...args: any[]
|
|
783
|
+
): Promise<void> {
|
|
784
|
+
context.stopProcessing();
|
|
785
|
+
|
|
786
|
+
this.emit(A_RequestFeatures.onError);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
@A_Feature.Extend()
|
|
790
|
+
/**
|
|
791
|
+
* Hook called to parse request data
|
|
792
|
+
*/
|
|
793
|
+
async [A_RequestFeatures.onEnd](
|
|
794
|
+
@A_Inject(A_Config) config: A_Config<A_RequestEnvVariablesType>,
|
|
795
|
+
@A_Inject(A_HttpServerRequestContext) context: A_HttpServerRequestContext,
|
|
796
|
+
...args: any[]
|
|
797
|
+
): Promise<void> {
|
|
798
|
+
|
|
799
|
+
const { data, type } = A_RequestHelper.parseRequestBody(context);
|
|
800
|
+
|
|
801
|
+
this._body = data;
|
|
802
|
+
this._bodyType = type;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
@A_Feature.Extend()
|
|
808
|
+
/**
|
|
809
|
+
* Hook called to validate request data
|
|
810
|
+
*/
|
|
811
|
+
async [A_RequestFeatures.onValidate](
|
|
812
|
+
@A_Inject(A_HttpServerRequestContext) context: A_HttpServerRequestContext,
|
|
813
|
+
...args: any[]
|
|
814
|
+
): Promise<void> {
|
|
815
|
+
// Validate file uploads if multipart data detected
|
|
816
|
+
if (!!this.contentType && this.contentType.includes('multipart/form-data') && !this._options.enableFileUploads) {
|
|
817
|
+
throw new A_HttpServerError({
|
|
818
|
+
status: 400,
|
|
819
|
+
description: 'File uploads detected but not enabled. Set enableFileUploads: true in options.',
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Serialize request for logging/debugging
|
|
827
|
+
*/
|
|
828
|
+
toJSON(): A_Request_Serialized {
|
|
829
|
+
return {
|
|
830
|
+
...super.toJSON(),
|
|
831
|
+
method: this.method,
|
|
832
|
+
url: this.url,
|
|
833
|
+
headers: this.headers,
|
|
834
|
+
params: this.params,
|
|
835
|
+
query: this.query,
|
|
836
|
+
cookies: this._cookies,
|
|
837
|
+
userAgent: this.userAgent,
|
|
838
|
+
bodyType: this._bodyType,
|
|
839
|
+
body: this._body,
|
|
840
|
+
filesCount: this._files?.length || 0,
|
|
841
|
+
totalFileSize: this.getTotalFileSize(),
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
}
|