@adaas/a-server 0.0.22 → 0.0.23
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 +1669 -0
- package/dist/browser/index.mjs +2869 -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-BVYAc6-8.d.mts +318 -0
- package/dist/node/A-Response.entity-CRc-t-vr.d.ts +318 -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 +544 -0
- package/dist/node/lib/A-Response/A-Response.entity.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.entity.mjs +532 -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 +194 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.mjs +182 -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 +689 -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 +251 -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,181 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ARequest_error = require('./A-Request.error');
|
|
4
|
+
|
|
5
|
+
class A_RequestHelper {
|
|
6
|
+
/**
|
|
7
|
+
* Extract URL parameters from a URL using a route pattern
|
|
8
|
+
* @param url - The actual URL to extract parameters from
|
|
9
|
+
* @param routePattern - The route pattern with parameters (e.g., "/users/:id/posts/:postId")
|
|
10
|
+
* @returns Object containing extracted parameters
|
|
11
|
+
*/
|
|
12
|
+
static extractParams(url, routePattern) {
|
|
13
|
+
const cleanUrl = url.split("?")[0];
|
|
14
|
+
const cleanPattern = routePattern.split("?")[0];
|
|
15
|
+
const urlSegments = cleanUrl.split("/").filter(Boolean);
|
|
16
|
+
const patternSegments = cleanPattern.split("/").filter(Boolean);
|
|
17
|
+
const params = {};
|
|
18
|
+
for (let i = 0; i < patternSegments.length; i++) {
|
|
19
|
+
const patternSegment = patternSegments[i];
|
|
20
|
+
const urlSegment = urlSegments[i];
|
|
21
|
+
if (patternSegment.startsWith(":")) {
|
|
22
|
+
const paramName = patternSegment.slice(1);
|
|
23
|
+
if (urlSegment) {
|
|
24
|
+
params[paramName] = decodeURIComponent(urlSegment);
|
|
25
|
+
}
|
|
26
|
+
} else if (patternSegment !== urlSegment) {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return params;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Extract query parameters from URL
|
|
34
|
+
* @param url - The URL to extract query parameters from
|
|
35
|
+
* @returns Object containing query parameters
|
|
36
|
+
*/
|
|
37
|
+
static extractQuery(url) {
|
|
38
|
+
const query = {};
|
|
39
|
+
const queryString = url.split("?")[1];
|
|
40
|
+
if (!queryString) return query;
|
|
41
|
+
const cleanQuery = queryString.split("#")[0];
|
|
42
|
+
for (const pair of cleanQuery.split("&")) {
|
|
43
|
+
if (!pair) continue;
|
|
44
|
+
const [key, value = ""] = pair.split("=");
|
|
45
|
+
query[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
46
|
+
}
|
|
47
|
+
return query;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parse cookies from Cookie header
|
|
51
|
+
*/
|
|
52
|
+
static parseCookies(cookieHeader) {
|
|
53
|
+
const cookies = {};
|
|
54
|
+
if (!cookieHeader) return {};
|
|
55
|
+
cookieHeader.split(";").forEach((cookie) => {
|
|
56
|
+
const [name, ...rest] = cookie.trim().split("=");
|
|
57
|
+
const value = rest.join("=");
|
|
58
|
+
if (name && value) {
|
|
59
|
+
cookies[name] = decodeURIComponent(value);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return cookies;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parse request body based on Content-Type
|
|
66
|
+
*
|
|
67
|
+
*
|
|
68
|
+
* @param context - The HTTP server request context
|
|
69
|
+
* @returns Parsed body data and detected body type
|
|
70
|
+
*/
|
|
71
|
+
static parseRequestBody(context) {
|
|
72
|
+
let parsedBody;
|
|
73
|
+
let bodyType;
|
|
74
|
+
switch (true) {
|
|
75
|
+
case (!!context.contentType && context.contentType.includes("application/json")):
|
|
76
|
+
parsedBody = JSON.parse(context.data);
|
|
77
|
+
bodyType = "json";
|
|
78
|
+
break;
|
|
79
|
+
case (!!context.contentType && context.contentType.includes("application/x-www-form-urlencoded")):
|
|
80
|
+
parsedBody = A_RequestHelper.parseFormUrlEncoded(context.data);
|
|
81
|
+
bodyType = "form";
|
|
82
|
+
break;
|
|
83
|
+
case (!!context.contentType && context.contentType.includes("multipart/form-data")):
|
|
84
|
+
const multipartResult = A_RequestHelper.parseMultipartData(Buffer.concat(context.buffers), context.contentType);
|
|
85
|
+
parsedBody = {
|
|
86
|
+
...multipartResult.fields,
|
|
87
|
+
_files: multipartResult.files
|
|
88
|
+
};
|
|
89
|
+
bodyType = "multipart";
|
|
90
|
+
break;
|
|
91
|
+
case (!!context.contentType && context.contentType.includes("text/")):
|
|
92
|
+
parsedBody = context.data;
|
|
93
|
+
bodyType = "text";
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
parsedBody = Buffer.concat(context.buffers);
|
|
97
|
+
bodyType = "raw";
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
data: parsedBody,
|
|
102
|
+
type: bodyType
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Parse URL-encoded form data (application/x-www-form-urlencoded)
|
|
107
|
+
* @param body - The URL-encoded body string
|
|
108
|
+
* @returns Object containing form data
|
|
109
|
+
*/
|
|
110
|
+
static parseFormUrlEncoded(body) {
|
|
111
|
+
const result = {};
|
|
112
|
+
if (!body) return result;
|
|
113
|
+
const pairs = body.split("&");
|
|
114
|
+
for (const pair of pairs) {
|
|
115
|
+
if (!pair) continue;
|
|
116
|
+
const [key, value = ""] = pair.split("=");
|
|
117
|
+
const decodedKey = decodeURIComponent(key.replace(/\+/g, " "));
|
|
118
|
+
const decodedValue = decodeURIComponent(value.replace(/\+/g, " "));
|
|
119
|
+
if (decodedKey in result) {
|
|
120
|
+
const existing = result[decodedKey];
|
|
121
|
+
if (Array.isArray(existing)) {
|
|
122
|
+
existing.push(decodedValue);
|
|
123
|
+
} else {
|
|
124
|
+
result[decodedKey] = [existing, decodedValue];
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
result[decodedKey] = decodedValue;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Parse multipart form data (for file uploads and form data)
|
|
134
|
+
* @param buffer - The raw buffer containing multipart data
|
|
135
|
+
* @param contentType - The content type header
|
|
136
|
+
* @returns Object containing fields and files
|
|
137
|
+
*/
|
|
138
|
+
static parseMultipartData(buffer, contentType) {
|
|
139
|
+
const boundaryMatch = contentType.match(/boundary=(.+)/);
|
|
140
|
+
if (!boundaryMatch) {
|
|
141
|
+
throw new ARequest_error.A_RequestError(
|
|
142
|
+
ARequest_error.A_RequestError.RequestBodyParsingError,
|
|
143
|
+
"Missing boundary in multipart/form-data content type"
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const boundary = "--" + boundaryMatch[1];
|
|
147
|
+
const textData = buffer.toString();
|
|
148
|
+
const parts = textData.split(boundary).filter((part) => part.trim() && !part.includes("--"));
|
|
149
|
+
const fields = {};
|
|
150
|
+
const files = [];
|
|
151
|
+
parts.forEach((part) => {
|
|
152
|
+
const [headers, content] = part.split("\r\n\r\n");
|
|
153
|
+
if (!headers || content === void 0) return;
|
|
154
|
+
const nameMatch = headers.match(/name="([^"]+)"/);
|
|
155
|
+
const filenameMatch = headers.match(/filename="([^"]+)"/);
|
|
156
|
+
const contentTypeMatch = headers.match(/Content-Type: ([^\r\n]+)/);
|
|
157
|
+
if (nameMatch) {
|
|
158
|
+
const fieldName = nameMatch[1];
|
|
159
|
+
const cleanContent = content.replace(/\r\n$/, "");
|
|
160
|
+
if (filenameMatch) {
|
|
161
|
+
const file = {
|
|
162
|
+
fieldName,
|
|
163
|
+
filename: filenameMatch[1],
|
|
164
|
+
encoding: "binary",
|
|
165
|
+
mimetype: contentTypeMatch?.[1] || "application/octet-stream",
|
|
166
|
+
size: Buffer.byteLength(cleanContent),
|
|
167
|
+
buffer: Buffer.from(cleanContent, "binary")
|
|
168
|
+
};
|
|
169
|
+
files.push(file);
|
|
170
|
+
} else {
|
|
171
|
+
fields[fieldName] = cleanContent;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return { fields, files };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
exports.A_RequestHelper = A_RequestHelper;
|
|
180
|
+
//# sourceMappingURL=A-Request.helper.js.map
|
|
181
|
+
//# sourceMappingURL=A-Request.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/A-Request/A-Request.helper.ts"],"names":["A_RequestError"],"mappings":";;;;AA+BO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K,YAAA,EAAc,QAAQ;AAAA,WAC9C;AACA,UAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA,QACnB,CAAA,MAAO;AAEH,UAAA,MAAA,CAAO,SAAS,CAAA,GAAI,YAAA;AAAA,QACxB;AAAA,MACJ;AAAA,IACJ,CAAC,CAAA;AAED,IAAA,OAAO,EAAE,QAAQ,KAAA,EAAM;AAAA,EAC3B;AAEJ","file":"A-Request.helper.js","sourcesContent":["import { A_HttpServerRequestContext } from \"./A-HttpServerRequest.context\";\nimport { A_RequestError } from \"./A-Request.error\";\nimport { A_Request_BodyType, A_Request_FileUpload } from \"./A-Request.types\";\n\n/**\n * A_RequestHelper - Stateless utility class for HTTP request processing\n * \n * This helper class provides static methods for parsing and processing HTTP request data:\n * - URL parameter extraction from route patterns\n * - Query string parsing\n * - Request body parsing (JSON, form-data, multipart, raw)\n * - URL-encoded form data parsing\n * - Multipart form data parsing (including file uploads)\n * \n * All methods are stateless and only depend on input parameters.\n * \n * @example\n * ```typescript\n * // Extract URL parameters\n * const params = A_RequestHelper.extractParams('/users/123', '/users/:id');\n * // { id: '123' }\n * \n * // Parse query string\n * const query = A_RequestHelper.extractQuery('/api/users?page=1&limit=10');\n * // { page: '1', limit: '10' }\n * \n * // Parse request body\n * const result = await A_RequestHelper.parseRequestBody(req, { maxBodySize: 1024 * 1024 });\n * // { data: {...}, type: 'json' }\n * ```\n */\nexport class A_RequestHelper {\n\n /**\n * Extract URL parameters from a URL using a route pattern\n * @param url - The actual URL to extract parameters from\n * @param routePattern - The route pattern with parameters (e.g., \"/users/:id/posts/:postId\")\n * @returns Object containing extracted parameters\n */\n static extractParams(url: string, routePattern: string): Record<string, string> {\n // Remove query string (anything after ?)\n const cleanUrl = url.split('?')[0];\n const cleanPattern = routePattern.split('?')[0];\n\n const urlSegments = cleanUrl.split('/').filter(Boolean);\n const patternSegments = cleanPattern.split('/').filter(Boolean);\n\n const params: Record<string, string> = {};\n\n for (let i = 0; i < patternSegments.length; i++) {\n const patternSegment = patternSegments[i];\n const urlSegment = urlSegments[i];\n\n if (patternSegment.startsWith(':')) {\n const paramName = patternSegment.slice(1); // Remove ':' from pattern\n if (urlSegment) {\n params[paramName] = decodeURIComponent(urlSegment);\n }\n } else if (patternSegment !== urlSegment) {\n // If static segments don't match → fail\n return {};\n }\n }\n\n return params;\n }\n\n\n\n /**\n * Extract query parameters from URL\n * @param url - The URL to extract query parameters from\n * @returns Object containing query parameters\n */\n static extractQuery<T = Record<string, string>>(url: string): T {\n const query: Record<string, string> = {};\n\n // Take only the part after \"?\"\n const queryString = url.split('?')[1];\n if (!queryString) return query as T;\n\n // Remove fragment (#...) if present\n const cleanQuery = queryString.split('#')[0];\n\n // Split into key=value pairs\n for (const pair of cleanQuery.split('&')) {\n if (!pair) continue;\n const [key, value = ''] = pair.split('=');\n query[decodeURIComponent(key)] = decodeURIComponent(value);\n }\n\n return query as T;\n }\n\n\n /**\n * Parse cookies from Cookie header\n */\n static parseCookies(\n cookieHeader?: string\n ): Record<string, string> {\n const cookies: Record<string, string> = {};\n\n if (!cookieHeader) return {};\n\n cookieHeader.split(';').forEach(cookie => {\n const [name, ...rest] = cookie.trim().split('=');\n const value = rest.join('=');\n if (name && value) {\n cookies[name] = decodeURIComponent(value);\n }\n });\n\n return cookies;\n }\n\n /**\n * Parse request body based on Content-Type\n * \n * \n * @param context - The HTTP server request context\n * @returns Parsed body data and detected body type\n */\n static parseRequestBody<T extends any = any>(\n context: A_HttpServerRequestContext\n ): {\n data: T;\n type: A_Request_BodyType;\n } {\n let parsedBody: any;\n let bodyType: A_Request_BodyType;\n\n switch (true) {\n case !!context.contentType && context.contentType.includes('application/json'):\n parsedBody = JSON.parse(context.data);\n bodyType = 'json';\n break;\n case !!context.contentType && context.contentType.includes('application/x-www-form-urlencoded'):\n parsedBody = A_RequestHelper.parseFormUrlEncoded(context.data) as T;\n bodyType = 'form';\n break;\n case !!context.contentType && context.contentType.includes('multipart/form-data'):\n const multipartResult = A_RequestHelper.parseMultipartData(Buffer.concat(context.buffers), context.contentType);\n // Return the entire multipart result (fields + files) as T\n parsedBody = {\n ...multipartResult.fields,\n _files: multipartResult.files\n } as T;\n bodyType = 'multipart';\n break;\n case !!context.contentType && context.contentType.includes('text/'):\n parsedBody = context.data as T;\n bodyType = 'text';\n break;\n default:\n parsedBody = Buffer.concat(context.buffers) as T;\n bodyType = 'raw';\n break;\n }\n\n\n return {\n data: parsedBody,\n type: bodyType\n };\n }\n\n /**\n * Parse URL-encoded form data (application/x-www-form-urlencoded)\n * @param body - The URL-encoded body string\n * @returns Object containing form data\n */\n static parseFormUrlEncoded(\n /**\n * The URL-encoded body string\n */\n body: string\n ): Record<string, string | string[]> {\n const result: Record<string, string | string[]> = {};\n\n if (!body) return result;\n\n const pairs = body.split('&');\n\n for (const pair of pairs) {\n if (!pair) continue;\n\n const [key, value = ''] = pair.split('=');\n const decodedKey = decodeURIComponent(key.replace(/\\+/g, ' '));\n const decodedValue = decodeURIComponent(value.replace(/\\+/g, ' '));\n\n // Handle multiple values for the same key (arrays)\n if (decodedKey in result) {\n const existing = result[decodedKey];\n if (Array.isArray(existing)) {\n existing.push(decodedValue);\n } else {\n result[decodedKey] = [existing, decodedValue];\n }\n } else {\n result[decodedKey] = decodedValue;\n }\n }\n\n return result;\n }\n\n /**\n * Parse multipart form data (for file uploads and form data)\n * @param buffer - The raw buffer containing multipart data\n * @param contentType - The content type header\n * @returns Object containing fields and files\n */\n static parseMultipartData(\n /**\n * The raw buffer containing multipart data\n */\n buffer: Buffer,\n /**\n * The content type header\n */\n contentType: string\n ): {\n fields: Record<string, string>;\n files: A_Request_FileUpload[];\n } {\n // Extract boundary\n const boundaryMatch = contentType.match(/boundary=(.+)/);\n if (!boundaryMatch) {\n throw new A_RequestError(\n A_RequestError.RequestBodyParsingError,\n 'Missing boundary in multipart/form-data content type'\n )\n }\n\n const boundary = '--' + boundaryMatch[1];\n const textData = buffer.toString();\n const parts = textData.split(boundary).filter(part => part.trim() && !part.includes('--'));\n\n const fields: Record<string, string> = {};\n const files: A_Request_FileUpload[] = [];\n\n parts.forEach(part => {\n const [headers, content] = part.split('\\r\\n\\r\\n');\n if (!headers || content === undefined) return;\n\n const nameMatch = headers.match(/name=\"([^\"]+)\"/);\n const filenameMatch = headers.match(/filename=\"([^\"]+)\"/);\n const contentTypeMatch = headers.match(/Content-Type: ([^\\r\\n]+)/);\n\n if (nameMatch) {\n const fieldName = nameMatch[1];\n const cleanContent = content.replace(/\\r\\n$/, '');\n\n if (filenameMatch) {\n // It's a file upload\n const file: A_Request_FileUpload = {\n fieldName,\n filename: filenameMatch[1],\n encoding: 'binary',\n mimetype: contentTypeMatch?.[1] || 'application/octet-stream',\n size: Buffer.byteLength(cleanContent),\n buffer: Buffer.from(cleanContent, 'binary')\n };\n files.push(file);\n } else {\n // It's a regular field\n fields[fieldName] = cleanContent;\n }\n }\n });\n\n return { fields, files };\n }\n\n}"]}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import '../../chunk-EQQGB2QZ.mjs';
|
|
2
|
+
import { A_RequestError } from './A-Request.error';
|
|
3
|
+
|
|
4
|
+
class A_RequestHelper {
|
|
5
|
+
/**
|
|
6
|
+
* Extract URL parameters from a URL using a route pattern
|
|
7
|
+
* @param url - The actual URL to extract parameters from
|
|
8
|
+
* @param routePattern - The route pattern with parameters (e.g., "/users/:id/posts/:postId")
|
|
9
|
+
* @returns Object containing extracted parameters
|
|
10
|
+
*/
|
|
11
|
+
static extractParams(url, routePattern) {
|
|
12
|
+
const cleanUrl = url.split("?")[0];
|
|
13
|
+
const cleanPattern = routePattern.split("?")[0];
|
|
14
|
+
const urlSegments = cleanUrl.split("/").filter(Boolean);
|
|
15
|
+
const patternSegments = cleanPattern.split("/").filter(Boolean);
|
|
16
|
+
const params = {};
|
|
17
|
+
for (let i = 0; i < patternSegments.length; i++) {
|
|
18
|
+
const patternSegment = patternSegments[i];
|
|
19
|
+
const urlSegment = urlSegments[i];
|
|
20
|
+
if (patternSegment.startsWith(":")) {
|
|
21
|
+
const paramName = patternSegment.slice(1);
|
|
22
|
+
if (urlSegment) {
|
|
23
|
+
params[paramName] = decodeURIComponent(urlSegment);
|
|
24
|
+
}
|
|
25
|
+
} else if (patternSegment !== urlSegment) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return params;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extract query parameters from URL
|
|
33
|
+
* @param url - The URL to extract query parameters from
|
|
34
|
+
* @returns Object containing query parameters
|
|
35
|
+
*/
|
|
36
|
+
static extractQuery(url) {
|
|
37
|
+
const query = {};
|
|
38
|
+
const queryString = url.split("?")[1];
|
|
39
|
+
if (!queryString) return query;
|
|
40
|
+
const cleanQuery = queryString.split("#")[0];
|
|
41
|
+
for (const pair of cleanQuery.split("&")) {
|
|
42
|
+
if (!pair) continue;
|
|
43
|
+
const [key, value = ""] = pair.split("=");
|
|
44
|
+
query[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
45
|
+
}
|
|
46
|
+
return query;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parse cookies from Cookie header
|
|
50
|
+
*/
|
|
51
|
+
static parseCookies(cookieHeader) {
|
|
52
|
+
const cookies = {};
|
|
53
|
+
if (!cookieHeader) return {};
|
|
54
|
+
cookieHeader.split(";").forEach((cookie) => {
|
|
55
|
+
const [name, ...rest] = cookie.trim().split("=");
|
|
56
|
+
const value = rest.join("=");
|
|
57
|
+
if (name && value) {
|
|
58
|
+
cookies[name] = decodeURIComponent(value);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return cookies;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse request body based on Content-Type
|
|
65
|
+
*
|
|
66
|
+
*
|
|
67
|
+
* @param context - The HTTP server request context
|
|
68
|
+
* @returns Parsed body data and detected body type
|
|
69
|
+
*/
|
|
70
|
+
static parseRequestBody(context) {
|
|
71
|
+
let parsedBody;
|
|
72
|
+
let bodyType;
|
|
73
|
+
switch (true) {
|
|
74
|
+
case (!!context.contentType && context.contentType.includes("application/json")):
|
|
75
|
+
parsedBody = JSON.parse(context.data);
|
|
76
|
+
bodyType = "json";
|
|
77
|
+
break;
|
|
78
|
+
case (!!context.contentType && context.contentType.includes("application/x-www-form-urlencoded")):
|
|
79
|
+
parsedBody = A_RequestHelper.parseFormUrlEncoded(context.data);
|
|
80
|
+
bodyType = "form";
|
|
81
|
+
break;
|
|
82
|
+
case (!!context.contentType && context.contentType.includes("multipart/form-data")):
|
|
83
|
+
const multipartResult = A_RequestHelper.parseMultipartData(Buffer.concat(context.buffers), context.contentType);
|
|
84
|
+
parsedBody = {
|
|
85
|
+
...multipartResult.fields,
|
|
86
|
+
_files: multipartResult.files
|
|
87
|
+
};
|
|
88
|
+
bodyType = "multipart";
|
|
89
|
+
break;
|
|
90
|
+
case (!!context.contentType && context.contentType.includes("text/")):
|
|
91
|
+
parsedBody = context.data;
|
|
92
|
+
bodyType = "text";
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
parsedBody = Buffer.concat(context.buffers);
|
|
96
|
+
bodyType = "raw";
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
data: parsedBody,
|
|
101
|
+
type: bodyType
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Parse URL-encoded form data (application/x-www-form-urlencoded)
|
|
106
|
+
* @param body - The URL-encoded body string
|
|
107
|
+
* @returns Object containing form data
|
|
108
|
+
*/
|
|
109
|
+
static parseFormUrlEncoded(body) {
|
|
110
|
+
const result = {};
|
|
111
|
+
if (!body) return result;
|
|
112
|
+
const pairs = body.split("&");
|
|
113
|
+
for (const pair of pairs) {
|
|
114
|
+
if (!pair) continue;
|
|
115
|
+
const [key, value = ""] = pair.split("=");
|
|
116
|
+
const decodedKey = decodeURIComponent(key.replace(/\+/g, " "));
|
|
117
|
+
const decodedValue = decodeURIComponent(value.replace(/\+/g, " "));
|
|
118
|
+
if (decodedKey in result) {
|
|
119
|
+
const existing = result[decodedKey];
|
|
120
|
+
if (Array.isArray(existing)) {
|
|
121
|
+
existing.push(decodedValue);
|
|
122
|
+
} else {
|
|
123
|
+
result[decodedKey] = [existing, decodedValue];
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
result[decodedKey] = decodedValue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Parse multipart form data (for file uploads and form data)
|
|
133
|
+
* @param buffer - The raw buffer containing multipart data
|
|
134
|
+
* @param contentType - The content type header
|
|
135
|
+
* @returns Object containing fields and files
|
|
136
|
+
*/
|
|
137
|
+
static parseMultipartData(buffer, contentType) {
|
|
138
|
+
const boundaryMatch = contentType.match(/boundary=(.+)/);
|
|
139
|
+
if (!boundaryMatch) {
|
|
140
|
+
throw new A_RequestError(
|
|
141
|
+
A_RequestError.RequestBodyParsingError,
|
|
142
|
+
"Missing boundary in multipart/form-data content type"
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
const boundary = "--" + boundaryMatch[1];
|
|
146
|
+
const textData = buffer.toString();
|
|
147
|
+
const parts = textData.split(boundary).filter((part) => part.trim() && !part.includes("--"));
|
|
148
|
+
const fields = {};
|
|
149
|
+
const files = [];
|
|
150
|
+
parts.forEach((part) => {
|
|
151
|
+
const [headers, content] = part.split("\r\n\r\n");
|
|
152
|
+
if (!headers || content === void 0) return;
|
|
153
|
+
const nameMatch = headers.match(/name="([^"]+)"/);
|
|
154
|
+
const filenameMatch = headers.match(/filename="([^"]+)"/);
|
|
155
|
+
const contentTypeMatch = headers.match(/Content-Type: ([^\r\n]+)/);
|
|
156
|
+
if (nameMatch) {
|
|
157
|
+
const fieldName = nameMatch[1];
|
|
158
|
+
const cleanContent = content.replace(/\r\n$/, "");
|
|
159
|
+
if (filenameMatch) {
|
|
160
|
+
const file = {
|
|
161
|
+
fieldName,
|
|
162
|
+
filename: filenameMatch[1],
|
|
163
|
+
encoding: "binary",
|
|
164
|
+
mimetype: contentTypeMatch?.[1] || "application/octet-stream",
|
|
165
|
+
size: Buffer.byteLength(cleanContent),
|
|
166
|
+
buffer: Buffer.from(cleanContent, "binary")
|
|
167
|
+
};
|
|
168
|
+
files.push(file);
|
|
169
|
+
} else {
|
|
170
|
+
fields[fieldName] = cleanContent;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return { fields, files };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export { A_RequestHelper };
|
|
179
|
+
//# sourceMappingURL=A-Request.helper.mjs.map
|
|
180
|
+
//# sourceMappingURL=A-Request.helper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/A-Request/A-Request.helper.ts"],"names":[],"mappings":";;;AA+BO,MAAM,eAAA,CAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzB,OAAO,aAAA,CAAc,GAAA,EAAa,YAAA,EAA8C;AAE5E,IAAA,MAAM,QAAA,GAAW,GAAA,CAAI,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AACjC,IAAA,MAAM,YAAA,GAAe,YAAA,CAAa,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAE9C,IAAA,MAAM,cAAc,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CAAE,OAAO,OAAO,CAAA;AACtD,IAAA,MAAM,kBAAkB,YAAA,CAAa,KAAA,CAAM,GAAG,CAAA,CAAE,OAAO,OAAO,CAAA;AAE9D,IAAA,MAAM,SAAiC,EAAC;AAExC,IAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,eAAA,CAAgB,QAAQ,CAAA,EAAA,EAAK;AAC7C,MAAA,MAAM,cAAA,GAAiB,gBAAgB,CAAC,CAAA;AACxC,MAAA,MAAM,U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KAAA,CAAM,oBAAoB,CAAA;AACxD,MAAA,MAAM,gBAAA,GAAmB,OAAA,CAAQ,KAAA,CAAM,0BAA0B,CAAA;AAEjE,MAAA,IAAI,SAAA,EAAW;AACX,QAAA,MAAM,SAAA,GAAY,UAAU,CAAC,CAAA;AAC7B,QAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,OAAA,CAAQ,OAAA,EAAS,EAAE,CAAA;AAEhD,QAAA,IAAI,aAAA,EAAe;AAEf,UAAA,MAAM,IAAA,GAA6B;AAAA,YAC/B,SAAA;AAAA,YACA,QAAA,EAAU,cAAc,CAAC,CAAA;AAAA,YACzB,QAAA,EAAU,QAAA;AAAA,YACV,QAAA,EAAU,gBAAA,GAAmB,CAAC,CAAA,IAAK,0BAAA;AAAA,YACnC,IAAA,EAAM,MAAA,CAAO,UAAA,CAAW,YAAY,CAAA;AAAA,YACpC,MAAA,EAAQ,MAAA,CAAO,IAAA,CAAK,YAAA,EAAc,QAAQ;AAAA,WAC9C;AACA,UAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA,QACnB,CAAA,MAAO;AAEH,UAAA,MAAA,CAAO,SAAS,CAAA,GAAI,YAAA;AAAA,QACxB;AAAA,MACJ;AAAA,IACJ,CAAC,CAAA;AAED,IAAA,OAAO,EAAE,QAAQ,KAAA,EAAM;AAAA,EAC3B;AAEJ","file":"A-Request.helper.mjs","sourcesContent":["import { A_HttpServerRequestContext } from \"./A-HttpServerRequest.context\";\nimport { A_RequestError } from \"./A-Request.error\";\nimport { A_Request_BodyType, A_Request_FileUpload } from \"./A-Request.types\";\n\n/**\n * A_RequestHelper - Stateless utility class for HTTP request processing\n * \n * This helper class provides static methods for parsing and processing HTTP request data:\n * - URL parameter extraction from route patterns\n * - Query string parsing\n * - Request body parsing (JSON, form-data, multipart, raw)\n * - URL-encoded form data parsing\n * - Multipart form data parsing (including file uploads)\n * \n * All methods are stateless and only depend on input parameters.\n * \n * @example\n * ```typescript\n * // Extract URL parameters\n * const params = A_RequestHelper.extractParams('/users/123', '/users/:id');\n * // { id: '123' }\n * \n * // Parse query string\n * const query = A_RequestHelper.extractQuery('/api/users?page=1&limit=10');\n * // { page: '1', limit: '10' }\n * \n * // Parse request body\n * const result = await A_RequestHelper.parseRequestBody(req, { maxBodySize: 1024 * 1024 });\n * // { data: {...}, type: 'json' }\n * ```\n */\nexport class A_RequestHelper {\n\n /**\n * Extract URL parameters from a URL using a route pattern\n * @param url - The actual URL to extract parameters from\n * @param routePattern - The route pattern with parameters (e.g., \"/users/:id/posts/:postId\")\n * @returns Object containing extracted parameters\n */\n static extractParams(url: string, routePattern: string): Record<string, string> {\n // Remove query string (anything after ?)\n const cleanUrl = url.split('?')[0];\n const cleanPattern = routePattern.split('?')[0];\n\n const urlSegments = cleanUrl.split('/').filter(Boolean);\n const patternSegments = cleanPattern.split('/').filter(Boolean);\n\n const params: Record<string, string> = {};\n\n for (let i = 0; i < patternSegments.length; i++) {\n const patternSegment = patternSegments[i];\n const urlSegment = urlSegments[i];\n\n if (patternSegment.startsWith(':')) {\n const paramName = patternSegment.slice(1); // Remove ':' from pattern\n if (urlSegment) {\n params[paramName] = decodeURIComponent(urlSegment);\n }\n } else if (patternSegment !== urlSegment) {\n // If static segments don't match → fail\n return {};\n }\n }\n\n return params;\n }\n\n\n\n /**\n * Extract query parameters from URL\n * @param url - The URL to extract query parameters from\n * @returns Object containing query parameters\n */\n static extractQuery<T = Record<string, string>>(url: string): T {\n const query: Record<string, string> = {};\n\n // Take only the part after \"?\"\n const queryString = url.split('?')[1];\n if (!queryString) return query as T;\n\n // Remove fragment (#...) if present\n const cleanQuery = queryString.split('#')[0];\n\n // Split into key=value pairs\n for (const pair of cleanQuery.split('&')) {\n if (!pair) continue;\n const [key, value = ''] = pair.split('=');\n query[decodeURIComponent(key)] = decodeURIComponent(value);\n }\n\n return query as T;\n }\n\n\n /**\n * Parse cookies from Cookie header\n */\n static parseCookies(\n cookieHeader?: string\n ): Record<string, string> {\n const cookies: Record<string, string> = {};\n\n if (!cookieHeader) return {};\n\n cookieHeader.split(';').forEach(cookie => {\n const [name, ...rest] = cookie.trim().split('=');\n const value = rest.join('=');\n if (name && value) {\n cookies[name] = decodeURIComponent(value);\n }\n });\n\n return cookies;\n }\n\n /**\n * Parse request body based on Content-Type\n * \n * \n * @param context - The HTTP server request context\n * @returns Parsed body data and detected body type\n */\n static parseRequestBody<T extends any = any>(\n context: A_HttpServerRequestContext\n ): {\n data: T;\n type: A_Request_BodyType;\n } {\n let parsedBody: any;\n let bodyType: A_Request_BodyType;\n\n switch (true) {\n case !!context.contentType && context.contentType.includes('application/json'):\n parsedBody = JSON.parse(context.data);\n bodyType = 'json';\n break;\n case !!context.contentType && context.contentType.includes('application/x-www-form-urlencoded'):\n parsedBody = A_RequestHelper.parseFormUrlEncoded(context.data) as T;\n bodyType = 'form';\n break;\n case !!context.contentType && context.contentType.includes('multipart/form-data'):\n const multipartResult = A_RequestHelper.parseMultipartData(Buffer.concat(context.buffers), context.contentType);\n // Return the entire multipart result (fields + files) as T\n parsedBody = {\n ...multipartResult.fields,\n _files: multipartResult.files\n } as T;\n bodyType = 'multipart';\n break;\n case !!context.contentType && context.contentType.includes('text/'):\n parsedBody = context.data as T;\n bodyType = 'text';\n break;\n default:\n parsedBody = Buffer.concat(context.buffers) as T;\n bodyType = 'raw';\n break;\n }\n\n\n return {\n data: parsedBody,\n type: bodyType\n };\n }\n\n /**\n * Parse URL-encoded form data (application/x-www-form-urlencoded)\n * @param body - The URL-encoded body string\n * @returns Object containing form data\n */\n static parseFormUrlEncoded(\n /**\n * The URL-encoded body string\n */\n body: string\n ): Record<string, string | string[]> {\n const result: Record<string, string | string[]> = {};\n\n if (!body) return result;\n\n const pairs = body.split('&');\n\n for (const pair of pairs) {\n if (!pair) continue;\n\n const [key, value = ''] = pair.split('=');\n const decodedKey = decodeURIComponent(key.replace(/\\+/g, ' '));\n const decodedValue = decodeURIComponent(value.replace(/\\+/g, ' '));\n\n // Handle multiple values for the same key (arrays)\n if (decodedKey in result) {\n const existing = result[decodedKey];\n if (Array.isArray(existing)) {\n existing.push(decodedValue);\n } else {\n result[decodedKey] = [existing, decodedValue];\n }\n } else {\n result[decodedKey] = decodedValue;\n }\n }\n\n return result;\n }\n\n /**\n * Parse multipart form data (for file uploads and form data)\n * @param buffer - The raw buffer containing multipart data\n * @param contentType - The content type header\n * @returns Object containing fields and files\n */\n static parseMultipartData(\n /**\n * The raw buffer containing multipart data\n */\n buffer: Buffer,\n /**\n * The content type header\n */\n contentType: string\n ): {\n fields: Record<string, string>;\n files: A_Request_FileUpload[];\n } {\n // Extract boundary\n const boundaryMatch = contentType.match(/boundary=(.+)/);\n if (!boundaryMatch) {\n throw new A_RequestError(\n A_RequestError.RequestBodyParsingError,\n 'Missing boundary in multipart/form-data content type'\n )\n }\n\n const boundary = '--' + boundaryMatch[1];\n const textData = buffer.toString();\n const parts = textData.split(boundary).filter(part => part.trim() && !part.includes('--'));\n\n const fields: Record<string, string> = {};\n const files: A_Request_FileUpload[] = [];\n\n parts.forEach(part => {\n const [headers, content] = part.split('\\r\\n\\r\\n');\n if (!headers || content === undefined) return;\n\n const nameMatch = headers.match(/name=\"([^\"]+)\"/);\n const filenameMatch = headers.match(/filename=\"([^\"]+)\"/);\n const contentTypeMatch = headers.match(/Content-Type: ([^\\r\\n]+)/);\n\n if (nameMatch) {\n const fieldName = nameMatch[1];\n const cleanContent = content.replace(/\\r\\n$/, '');\n\n if (filenameMatch) {\n // It's a file upload\n const file: A_Request_FileUpload = {\n fieldName,\n filename: filenameMatch[1],\n encoding: 'binary',\n mimetype: contentTypeMatch?.[1] || 'application/octet-stream',\n size: Buffer.byteLength(cleanContent),\n buffer: Buffer.from(cleanContent, 'binary')\n };\n files.push(file);\n } else {\n // It's a regular field\n fields[fieldName] = cleanContent;\n }\n }\n });\n\n return { fields, files };\n }\n\n}"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import 'http';
|
|
2
|
+
export { a as A_RequestFeatureNames, b as A_Request_BodyType, c as A_Request_Event, d as A_Request_EventCallback, e as A_Request_FileUpload, f as A_Request_Init, g as A_Request_Listener, h as A_Request_Methods, i as A_Request_Options, j as A_Request_ParsedBody, k as A_Request_Serialized, l as A_Request_SessionData, m as A_Request_ValidationResult } from '../../A-Request.entity-r905O60G.mjs';
|
|
3
|
+
import '@adaas/a-concept';
|
|
4
|
+
import '../A-Server/A-HttpServer.types.mjs';
|
|
5
|
+
import './A-Request.constants.mjs';
|
|
6
|
+
import '../A-Server/A-HttpServer.error.mjs';
|
|
7
|
+
import '../A-Server/A-HttpServer.constants.mjs';
|
|
8
|
+
import './A-Request.env.mjs';
|
|
9
|
+
import './A-HttpServerRequest.context.mjs';
|
|
10
|
+
import '@adaas/a-utils/a-operation';
|
|
11
|
+
import './A-HttpRequestData.context.mjs';
|
|
12
|
+
import '@adaas/a-utils/a-execution';
|
|
13
|
+
import '@adaas/a-utils/a-config';
|
|
14
|
+
import '../A-ServerRoute/A-ServerRoute.entity.mjs';
|
|
15
|
+
import '@adaas/a-utils/a-route';
|
|
16
|
+
import '../A-ServerRoute/A-ServerRoute.types.mjs';
|
|
17
|
+
import '../A-ServerRoute/A-ServerRoute.constants.mjs';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import 'http';
|
|
2
|
+
export { a as A_RequestFeatureNames, b as A_Request_BodyType, c as A_Request_Event, d as A_Request_EventCallback, e as A_Request_FileUpload, f as A_Request_Init, g as A_Request_Listener, h as A_Request_Methods, i as A_Request_Options, j as A_Request_ParsedBody, k as A_Request_Serialized, l as A_Request_SessionData, m as A_Request_ValidationResult } from '../../A-Request.entity-8_9MCXT2.js';
|
|
3
|
+
import '@adaas/a-concept';
|
|
4
|
+
import '../A-Server/A-HttpServer.types.js';
|
|
5
|
+
import './A-Request.constants.js';
|
|
6
|
+
import '../A-Server/A-HttpServer.error.js';
|
|
7
|
+
import '../A-Server/A-HttpServer.constants.js';
|
|
8
|
+
import './A-Request.env.js';
|
|
9
|
+
import './A-HttpServerRequest.context.js';
|
|
10
|
+
import '@adaas/a-utils/a-operation';
|
|
11
|
+
import './A-HttpRequestData.context.js';
|
|
12
|
+
import '@adaas/a-utils/a-execution';
|
|
13
|
+
import '@adaas/a-utils/a-config';
|
|
14
|
+
import '../A-ServerRoute/A-ServerRoute.entity.js';
|
|
15
|
+
import '@adaas/a-utils/a-route';
|
|
16
|
+
import '../A-ServerRoute/A-ServerRoute.types.js';
|
|
17
|
+
import '../A-ServerRoute/A-ServerRoute.constants.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var A_Request_Event = /* @__PURE__ */ ((A_Request_Event2) => {
|
|
4
|
+
A_Request_Event2["Error"] = "error";
|
|
5
|
+
A_Request_Event2["Finish"] = "finish";
|
|
6
|
+
A_Request_Event2["Data"] = "data";
|
|
7
|
+
A_Request_Event2["End"] = "end";
|
|
8
|
+
A_Request_Event2["Close"] = "close";
|
|
9
|
+
return A_Request_Event2;
|
|
10
|
+
})(A_Request_Event || {});
|
|
11
|
+
|
|
12
|
+
exports.A_Request_Event = A_Request_Event;
|
|
13
|
+
//# sourceMappingURL=A-Request.types.js.map
|
|
14
|
+
//# sourceMappingURL=A-Request.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/A-Request/A-Request.types.ts"],"names":["A_Request_Event"],"mappings":";;AA2EO,IAAK,eAAA,qBAAAA,gBAAAA,KAAL;AACH,EAAAA,iBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,iBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,iBAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,iBAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,iBAAA,OAAA,CAAA,GAAQ,OAAA;AALA,EAAA,OAAAA,gBAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA","file":"A-Request.types.js","sourcesContent":["import type { IncomingMessage } from \"http\";\nimport { A_Request } from \"./A-Request.entity\";\nimport { A_TYPES__Entity_Serialized } from \"@adaas/a-concept\";\nimport { A_HttpServerRequestMethod } from \"@adaas/a-server/server/A-HttpServer.types\";\nimport { A_RequestFeatures } from \"./A-Request.constants\";\n\n\n// =============================================\n// Core Request Types\n// =============================================\n/**\n * Constructor parameters for A_Request entity\n */\nexport type A_Request_Init = {\n /**\n * Unique identifier for the request (should correspond to Response id)\n */\n id: string;\n\n /**\n * ASEID Shard for the request. \n * it's some sort of request fingerprint\n */\n shard: string\n /**\n * Node.js IncomingMessage object\n */\n request: IncomingMessage;\n /**\n * Request scope for context resolution\n */\n scope: string;\n};\n\n/**\n * Serialized representation of A_Request entity\n */\nexport type A_Request_Serialized<\n _ReqBodyType = any,\n _ParamsType extends Record<string, string> = any,\n _QueryType = any,\n> = A_TYPES__Entity_Serialized & {\n method: A_HttpServerRequestMethod;\n url: string;\n headers: Record<string, string | string[] | undefined>;\n params?: _ParamsType;\n query?: _QueryType;\n cookies: Record<string, string>;\n body?: _ReqBodyType;\n userAgent?: string;\n isValid: boolean;\n bodyType?: A_Request_BodyType;\n filesCount?: number;\n fileFieldNames?: string[];\n totalFileSize?: number;\n}\n\n/**\n * Supported HTTP request methods\n */\nexport type A_Request_Methods =\n | 'GET'\n | 'POST'\n | 'PUT'\n | 'DELETE'\n | 'PATCH'\n | 'OPTIONS'\n | 'HEAD'\n | 'CONNECT'\n | 'TRACE'\n | 'DEFAULT'; // Default is used for routes that do not have a method specified\n\n/**\n * Request lifecycle events\n */\nexport enum A_Request_Event {\n Error = 'error',\n Finish = 'finish',\n Data = 'data',\n End = 'end',\n Close = 'close',\n}\n\n\nexport type A_RequestFeatureNames = typeof A_RequestFeatures[keyof typeof A_RequestFeatures];\n\n/**\n * Request event callback function type\n */\nexport type A_Request_EventCallback = (request: A_Request) => void;\n\n\n// =============================================\n// Body Parsing Types\n// =============================================\n\n/**\n * Supported body content types for parsing\n */\nexport type A_Request_BodyType = 'json' | 'form' | 'multipart' | 'raw' | 'text';\n\n/**\n * Result of body parsing operation\n */\nexport type A_Request_ParsedBody = {\n /**\n * Type of parsed content\n */\n type: A_Request_BodyType;\n /**\n * Parsed data\n */\n data: any;\n /**\n * Size of the body in bytes\n */\n size: number;\n /**\n * Character encoding used\n */\n encoding?: string;\n /**\n * Multipart boundary (for multipart content)\n */\n boundary?: string;\n};\n\n\n\n// =============================================\n// Session Management Types\n// =============================================\n\n/**\n * Session data structure for user session management\n */\nexport type A_Request_SessionData = {\n /**\n * Unique session identifier\n */\n id?: string;\n /**\n * Associated user ID\n */\n userId?: string;\n /**\n * Session creation timestamp\n */\n createdAt?: Date;\n /**\n * Last access timestamp\n */\n lastAccess?: Date;\n /**\n * Session data storage\n */\n data?: Record<string, any>;\n /**\n * Whether session is expired\n */\n isExpired?: boolean;\n /**\n * Maximum session age in milliseconds\n */\n maxAge?: number;\n};\n\n\n// =============================================\n// File Upload Types\n// =============================================\n\n/**\n * File upload information for multipart requests\n */\nexport type A_Request_FileUpload = {\n /**\n * Form field name\n */\n fieldName: string;\n /**\n * Original filename\n */\n filename: string;\n /**\n * File encoding\n */\n encoding: string;\n /**\n * MIME type\n */\n mimetype: string;\n /**\n * File size in bytes\n */\n size: number;\n /**\n * File buffer data\n */\n buffer: Buffer;\n /**\n * Path if saved to disk\n */\n path?: string;\n /**\n * File hash for integrity verification\n */\n hash?: string;\n};\n\n\n// =============================================\n// Validation Types\n// =============================================\n\n/**\n * Request validation result with detailed feedback\n */\nexport type A_Request_ValidationResult = {\n /**\n * Whether validation passed\n */\n isValid: boolean;\n /**\n * Validation error messages\n */\n errors: string[];\n /**\n * Warning messages\n */\n warnings: string[];\n /**\n * Sanitized data after validation\n */\n sanitized?: any;\n};\n\n\n// =============================================\n// Configuration Types\n// =============================================\n\n/**\n * Request processing configuration options\n */\nexport type A_Request_Options = {\n /**\n * Maximum request body size in bytes (default: 10MB)\n */\n maxBodySize?: number;\n /**\n * Request timeout in milliseconds (default: 30s)\n */\n timeout?: number;\n /**\n * Default character encoding (default: 'utf8')\n */\n encoding?: string;\n /**\n * Automatically parse cookies (default: true)\n */\n parseCookies?: boolean;\n /**\n * Automatically parse query parameters (default: true)\n */\n parseQuery?: boolean;\n /**\n * Automatically parse request body (default: true)\n */\n parseBody?: boolean;\n /**\n * Enable file upload handling (default: false)\n */\n enableFileUploads?: boolean;\n /**\n * Enable strict validation mode (default: false)\n */\n strictValidation?: boolean;\n};\n\n/**\n * Request Event Listener Function\n */\nexport type A_Request_Listener = (req?: A_Request) => void;"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '../../chunk-EQQGB2QZ.mjs';
|
|
2
|
+
|
|
3
|
+
var A_Request_Event = /* @__PURE__ */ ((A_Request_Event2) => {
|
|
4
|
+
A_Request_Event2["Error"] = "error";
|
|
5
|
+
A_Request_Event2["Finish"] = "finish";
|
|
6
|
+
A_Request_Event2["Data"] = "data";
|
|
7
|
+
A_Request_Event2["End"] = "end";
|
|
8
|
+
A_Request_Event2["Close"] = "close";
|
|
9
|
+
return A_Request_Event2;
|
|
10
|
+
})(A_Request_Event || {});
|
|
11
|
+
|
|
12
|
+
export { A_Request_Event };
|
|
13
|
+
//# sourceMappingURL=A-Request.types.mjs.map
|
|
14
|
+
//# sourceMappingURL=A-Request.types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/A-Request/A-Request.types.ts"],"names":["A_Request_Event"],"mappings":";;AA2EO,IAAK,eAAA,qBAAAA,gBAAAA,KAAL;AACH,EAAAA,iBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,iBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,iBAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,iBAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,iBAAA,OAAA,CAAA,GAAQ,OAAA;AALA,EAAA,OAAAA,gBAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA","file":"A-Request.types.mjs","sourcesContent":["import type { IncomingMessage } from \"http\";\nimport { A_Request } from \"./A-Request.entity\";\nimport { A_TYPES__Entity_Serialized } from \"@adaas/a-concept\";\nimport { A_HttpServerRequestMethod } from \"@adaas/a-server/server/A-HttpServer.types\";\nimport { A_RequestFeatures } from \"./A-Request.constants\";\n\n\n// =============================================\n// Core Request Types\n// =============================================\n/**\n * Constructor parameters for A_Request entity\n */\nexport type A_Request_Init = {\n /**\n * Unique identifier for the request (should correspond to Response id)\n */\n id: string;\n\n /**\n * ASEID Shard for the request. \n * it's some sort of request fingerprint\n */\n shard: string\n /**\n * Node.js IncomingMessage object\n */\n request: IncomingMessage;\n /**\n * Request scope for context resolution\n */\n scope: string;\n};\n\n/**\n * Serialized representation of A_Request entity\n */\nexport type A_Request_Serialized<\n _ReqBodyType = any,\n _ParamsType extends Record<string, string> = any,\n _QueryType = any,\n> = A_TYPES__Entity_Serialized & {\n method: A_HttpServerRequestMethod;\n url: string;\n headers: Record<string, string | string[] | undefined>;\n params?: _ParamsType;\n query?: _QueryType;\n cookies: Record<string, string>;\n body?: _ReqBodyType;\n userAgent?: string;\n isValid: boolean;\n bodyType?: A_Request_BodyType;\n filesCount?: number;\n fileFieldNames?: string[];\n totalFileSize?: number;\n}\n\n/**\n * Supported HTTP request methods\n */\nexport type A_Request_Methods =\n | 'GET'\n | 'POST'\n | 'PUT'\n | 'DELETE'\n | 'PATCH'\n | 'OPTIONS'\n | 'HEAD'\n | 'CONNECT'\n | 'TRACE'\n | 'DEFAULT'; // Default is used for routes that do not have a method specified\n\n/**\n * Request lifecycle events\n */\nexport enum A_Request_Event {\n Error = 'error',\n Finish = 'finish',\n Data = 'data',\n End = 'end',\n Close = 'close',\n}\n\n\nexport type A_RequestFeatureNames = typeof A_RequestFeatures[keyof typeof A_RequestFeatures];\n\n/**\n * Request event callback function type\n */\nexport type A_Request_EventCallback = (request: A_Request) => void;\n\n\n// =============================================\n// Body Parsing Types\n// =============================================\n\n/**\n * Supported body content types for parsing\n */\nexport type A_Request_BodyType = 'json' | 'form' | 'multipart' | 'raw' | 'text';\n\n/**\n * Result of body parsing operation\n */\nexport type A_Request_ParsedBody = {\n /**\n * Type of parsed content\n */\n type: A_Request_BodyType;\n /**\n * Parsed data\n */\n data: any;\n /**\n * Size of the body in bytes\n */\n size: number;\n /**\n * Character encoding used\n */\n encoding?: string;\n /**\n * Multipart boundary (for multipart content)\n */\n boundary?: string;\n};\n\n\n\n// =============================================\n// Session Management Types\n// =============================================\n\n/**\n * Session data structure for user session management\n */\nexport type A_Request_SessionData = {\n /**\n * Unique session identifier\n */\n id?: string;\n /**\n * Associated user ID\n */\n userId?: string;\n /**\n * Session creation timestamp\n */\n createdAt?: Date;\n /**\n * Last access timestamp\n */\n lastAccess?: Date;\n /**\n * Session data storage\n */\n data?: Record<string, any>;\n /**\n * Whether session is expired\n */\n isExpired?: boolean;\n /**\n * Maximum session age in milliseconds\n */\n maxAge?: number;\n};\n\n\n// =============================================\n// File Upload Types\n// =============================================\n\n/**\n * File upload information for multipart requests\n */\nexport type A_Request_FileUpload = {\n /**\n * Form field name\n */\n fieldName: string;\n /**\n * Original filename\n */\n filename: string;\n /**\n * File encoding\n */\n encoding: string;\n /**\n * MIME type\n */\n mimetype: string;\n /**\n * File size in bytes\n */\n size: number;\n /**\n * File buffer data\n */\n buffer: Buffer;\n /**\n * Path if saved to disk\n */\n path?: string;\n /**\n * File hash for integrity verification\n */\n hash?: string;\n};\n\n\n// =============================================\n// Validation Types\n// =============================================\n\n/**\n * Request validation result with detailed feedback\n */\nexport type A_Request_ValidationResult = {\n /**\n * Whether validation passed\n */\n isValid: boolean;\n /**\n * Validation error messages\n */\n errors: string[];\n /**\n * Warning messages\n */\n warnings: string[];\n /**\n * Sanitized data after validation\n */\n sanitized?: any;\n};\n\n\n// =============================================\n// Configuration Types\n// =============================================\n\n/**\n * Request processing configuration options\n */\nexport type A_Request_Options = {\n /**\n * Maximum request body size in bytes (default: 10MB)\n */\n maxBodySize?: number;\n /**\n * Request timeout in milliseconds (default: 30s)\n */\n timeout?: number;\n /**\n * Default character encoding (default: 'utf8')\n */\n encoding?: string;\n /**\n * Automatically parse cookies (default: true)\n */\n parseCookies?: boolean;\n /**\n * Automatically parse query parameters (default: true)\n */\n parseQuery?: boolean;\n /**\n * Automatically parse request body (default: true)\n */\n parseBody?: boolean;\n /**\n * Enable file upload handling (default: false)\n */\n enableFileUploads?: boolean;\n /**\n * Enable strict validation mode (default: false)\n */\n strictValidation?: boolean;\n};\n\n/**\n * Request Event Listener Function\n */\nexport type A_Request_Listener = (req?: A_Request) => void;"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const A_ResponseFeatures: {
|
|
2
|
+
/**
|
|
3
|
+
* Event fired when an error occurs while sending the response
|
|
4
|
+
*/
|
|
5
|
+
readonly onError: "_A_Response_onError";
|
|
6
|
+
/**
|
|
7
|
+
* Event fired when the response is closed
|
|
8
|
+
*/
|
|
9
|
+
readonly onClose: "_A_Response_onClose";
|
|
10
|
+
/**
|
|
11
|
+
* Event fired when the response is finished
|
|
12
|
+
*/
|
|
13
|
+
readonly onFinish: "_A_Response_onFinish";
|
|
14
|
+
/**
|
|
15
|
+
* Event fired when the response is sent
|
|
16
|
+
*/
|
|
17
|
+
readonly onSend: "_A_Response_onSend";
|
|
18
|
+
/**
|
|
19
|
+
* Event fired when the response is redirected
|
|
20
|
+
*/
|
|
21
|
+
readonly onRedirect: "_A_Response_onRedirect";
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { A_ResponseFeatures };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const A_ResponseFeatures: {
|
|
2
|
+
/**
|
|
3
|
+
* Event fired when an error occurs while sending the response
|
|
4
|
+
*/
|
|
5
|
+
readonly onError: "_A_Response_onError";
|
|
6
|
+
/**
|
|
7
|
+
* Event fired when the response is closed
|
|
8
|
+
*/
|
|
9
|
+
readonly onClose: "_A_Response_onClose";
|
|
10
|
+
/**
|
|
11
|
+
* Event fired when the response is finished
|
|
12
|
+
*/
|
|
13
|
+
readonly onFinish: "_A_Response_onFinish";
|
|
14
|
+
/**
|
|
15
|
+
* Event fired when the response is sent
|
|
16
|
+
*/
|
|
17
|
+
readonly onSend: "_A_Response_onSend";
|
|
18
|
+
/**
|
|
19
|
+
* Event fired when the response is redirected
|
|
20
|
+
*/
|
|
21
|
+
readonly onRedirect: "_A_Response_onRedirect";
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { A_ResponseFeatures };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const A_ResponseFeatures = {
|
|
4
|
+
/**
|
|
5
|
+
* Event fired when an error occurs while sending the response
|
|
6
|
+
*/
|
|
7
|
+
onError: "_A_Response_onError",
|
|
8
|
+
/**
|
|
9
|
+
* Event fired when the response is closed
|
|
10
|
+
*/
|
|
11
|
+
onClose: "_A_Response_onClose",
|
|
12
|
+
/**
|
|
13
|
+
* Event fired when the response is finished
|
|
14
|
+
*/
|
|
15
|
+
onFinish: "_A_Response_onFinish",
|
|
16
|
+
/**
|
|
17
|
+
* Event fired when the response is sent
|
|
18
|
+
*/
|
|
19
|
+
onSend: "_A_Response_onSend",
|
|
20
|
+
/**
|
|
21
|
+
* Event fired when the response is redirected
|
|
22
|
+
*/
|
|
23
|
+
onRedirect: "_A_Response_onRedirect"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.A_ResponseFeatures = A_ResponseFeatures;
|
|
27
|
+
//# sourceMappingURL=A-Response.constants.js.map
|
|
28
|
+
//# sourceMappingURL=A-Response.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/A-Response/A-Response.constants.ts"],"names":[],"mappings":";;AAEO,MAAM,kBAAA,GAAqB;AAAA;AAAA;AAAA;AAAA,EAI9B,OAAA,EAAS,qBAAA;AAAA;AAAA;AAAA;AAAA,EAIT,OAAA,EAAS,qBAAA;AAAA;AAAA;AAAA;AAAA,EAIT,QAAA,EAAU,sBAAA;AAAA;AAAA;AAAA;AAAA,EAIV,MAAA,EAAQ,oBAAA;AAAA;AAAA;AAAA;AAAA,EAIR,UAAA,EAAY;AAChB","file":"A-Response.constants.js","sourcesContent":["\n\nexport const A_ResponseFeatures = {\n /**\n * Event fired when an error occurs while sending the response\n */\n onError: '_A_Response_onError',\n /**\n * Event fired when the response is closed\n */\n onClose: '_A_Response_onClose',\n /**\n * Event fired when the response is finished\n */\n onFinish: '_A_Response_onFinish',\n /**\n * Event fired when the response is sent\n */\n onSend: '_A_Response_onSend',\n /**\n * Event fired when the response is redirected\n */\n onRedirect: '_A_Response_onRedirect',\n} as const;"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import '../../chunk-EQQGB2QZ.mjs';
|
|
2
|
+
|
|
3
|
+
const A_ResponseFeatures = {
|
|
4
|
+
/**
|
|
5
|
+
* Event fired when an error occurs while sending the response
|
|
6
|
+
*/
|
|
7
|
+
onError: "_A_Response_onError",
|
|
8
|
+
/**
|
|
9
|
+
* Event fired when the response is closed
|
|
10
|
+
*/
|
|
11
|
+
onClose: "_A_Response_onClose",
|
|
12
|
+
/**
|
|
13
|
+
* Event fired when the response is finished
|
|
14
|
+
*/
|
|
15
|
+
onFinish: "_A_Response_onFinish",
|
|
16
|
+
/**
|
|
17
|
+
* Event fired when the response is sent
|
|
18
|
+
*/
|
|
19
|
+
onSend: "_A_Response_onSend",
|
|
20
|
+
/**
|
|
21
|
+
* Event fired when the response is redirected
|
|
22
|
+
*/
|
|
23
|
+
onRedirect: "_A_Response_onRedirect"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { A_ResponseFeatures };
|
|
27
|
+
//# sourceMappingURL=A-Response.constants.mjs.map
|
|
28
|
+
//# sourceMappingURL=A-Response.constants.mjs.map
|