@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
package/dist/index.js
DELETED
|
@@ -1,2179 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var aConcept = require('@adaas/a-concept');
|
|
4
|
-
var aUtils = require('@adaas/a-utils');
|
|
5
|
-
var AEntity_constants = require('@adaas/a-concept/dist/src/global/A-Entity/A-Entity.constants');
|
|
6
|
-
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
-
var result = __getOwnPropDesc(target, key) ;
|
|
11
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
-
if (decorator = decorators[i])
|
|
13
|
-
result = (decorator(target, key, result) ) || result;
|
|
14
|
-
if (result) __defProp(target, key, result);
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
18
|
-
|
|
19
|
-
// src/containers/A-Service/A-Service.container.types.ts
|
|
20
|
-
var A_SERVER_TYPES__ServerFeature = /* @__PURE__ */ ((A_SERVER_TYPES__ServerFeature2) => {
|
|
21
|
-
A_SERVER_TYPES__ServerFeature2["beforeStart"] = "beforeStart";
|
|
22
|
-
A_SERVER_TYPES__ServerFeature2["afterStart"] = "afterStart";
|
|
23
|
-
A_SERVER_TYPES__ServerFeature2["beforeStop"] = "beforeStop";
|
|
24
|
-
A_SERVER_TYPES__ServerFeature2["afterStop"] = "afterStop";
|
|
25
|
-
A_SERVER_TYPES__ServerFeature2["beforeRequest"] = "beforeRequest";
|
|
26
|
-
A_SERVER_TYPES__ServerFeature2["onRequest"] = "onRequest";
|
|
27
|
-
A_SERVER_TYPES__ServerFeature2["afterRequest"] = "afterRequest";
|
|
28
|
-
return A_SERVER_TYPES__ServerFeature2;
|
|
29
|
-
})(A_SERVER_TYPES__ServerFeature || {});
|
|
30
|
-
var A_SERVER_TYPES__ServerMethod = /* @__PURE__ */ ((A_SERVER_TYPES__ServerMethod2) => {
|
|
31
|
-
A_SERVER_TYPES__ServerMethod2["GET"] = "GET";
|
|
32
|
-
A_SERVER_TYPES__ServerMethod2["POST"] = "POST";
|
|
33
|
-
A_SERVER_TYPES__ServerMethod2["PUT"] = "PUT";
|
|
34
|
-
A_SERVER_TYPES__ServerMethod2["DELETE"] = "DELETE";
|
|
35
|
-
A_SERVER_TYPES__ServerMethod2["PATCH"] = "PATCH";
|
|
36
|
-
A_SERVER_TYPES__ServerMethod2["OPTIONS"] = "OPTIONS";
|
|
37
|
-
A_SERVER_TYPES__ServerMethod2["HEAD"] = "HEAD";
|
|
38
|
-
A_SERVER_TYPES__ServerMethod2["CONNECT"] = "CONNECT";
|
|
39
|
-
A_SERVER_TYPES__ServerMethod2["TRACE"] = "TRACE";
|
|
40
|
-
A_SERVER_TYPES__ServerMethod2["DEFAULT"] = "DEFAULT";
|
|
41
|
-
return A_SERVER_TYPES__ServerMethod2;
|
|
42
|
-
})(A_SERVER_TYPES__ServerMethod || {});
|
|
43
|
-
var A_HTTPChannel_RequestContext = class extends aConcept.A_Fragment {
|
|
44
|
-
constructor(params) {
|
|
45
|
-
super();
|
|
46
|
-
const {
|
|
47
|
-
method,
|
|
48
|
-
url,
|
|
49
|
-
data,
|
|
50
|
-
config
|
|
51
|
-
} = params;
|
|
52
|
-
this.url = url;
|
|
53
|
-
this.method = method;
|
|
54
|
-
this.data = data;
|
|
55
|
-
this.config = config;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// src/channels/A-Http/A-Http.channel.constants.ts
|
|
60
|
-
var A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle = /* @__PURE__ */ ((A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2) => {
|
|
61
|
-
A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2["onAfterRequest"] = "onAfterHttpChannelRequest";
|
|
62
|
-
A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2["onError"] = "onHttpChannelError";
|
|
63
|
-
A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2["onBeforeRequest"] = "onBeforeHttpChannelRequest";
|
|
64
|
-
return A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle2;
|
|
65
|
-
})(A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle || {});
|
|
66
|
-
var A_ServerError = class extends aConcept.A_Error {
|
|
67
|
-
constructor() {
|
|
68
|
-
super(...arguments);
|
|
69
|
-
this.status = 500;
|
|
70
|
-
}
|
|
71
|
-
// constructor(
|
|
72
|
-
// /**
|
|
73
|
-
// * A_Error Constructor params
|
|
74
|
-
// */
|
|
75
|
-
// params: A_SERVER_TYPES__ServerError_Init
|
|
76
|
-
// )
|
|
77
|
-
// constructor(
|
|
78
|
-
// /**
|
|
79
|
-
// * HTTP Status Code of the error
|
|
80
|
-
// */
|
|
81
|
-
// status: number,
|
|
82
|
-
// /**
|
|
83
|
-
// * Error message
|
|
84
|
-
// */
|
|
85
|
-
// message: string
|
|
86
|
-
// )
|
|
87
|
-
// constructor(
|
|
88
|
-
// /**
|
|
89
|
-
// * Original JS Error
|
|
90
|
-
// */
|
|
91
|
-
// error: Error
|
|
92
|
-
// )
|
|
93
|
-
// constructor(
|
|
94
|
-
// /**
|
|
95
|
-
// * HTTP Status Code of the error
|
|
96
|
-
// */
|
|
97
|
-
// status: number,
|
|
98
|
-
// /**
|
|
99
|
-
// * Error message
|
|
100
|
-
// */
|
|
101
|
-
// title: string,
|
|
102
|
-
// /**
|
|
103
|
-
// * Detailed description of the error
|
|
104
|
-
// */
|
|
105
|
-
// description: string
|
|
106
|
-
// )
|
|
107
|
-
// constructor(
|
|
108
|
-
// param1: A_SERVER_TYPES__ServerError_Init | Error | string | A_Error | number,
|
|
109
|
-
// param2?: string | A_Error,
|
|
110
|
-
// param3?: string
|
|
111
|
-
// ) {
|
|
112
|
-
// switch (true) {
|
|
113
|
-
// case typeof param1 === 'number':
|
|
114
|
-
// if (typeof param2 === 'string' && param3) {
|
|
115
|
-
// super({
|
|
116
|
-
// title: param2,
|
|
117
|
-
// description: param3
|
|
118
|
-
// });
|
|
119
|
-
// }
|
|
120
|
-
// else if (param2 instanceof A_Error) {
|
|
121
|
-
// super(param2);
|
|
122
|
-
// }
|
|
123
|
-
// else {
|
|
124
|
-
// super();
|
|
125
|
-
// }
|
|
126
|
-
// this.status = param1;
|
|
127
|
-
// break;
|
|
128
|
-
// case param1 instanceof A_Error:
|
|
129
|
-
// super (param1);
|
|
130
|
-
// break;
|
|
131
|
-
// case param1 instanceof Error:
|
|
132
|
-
// super (param1);
|
|
133
|
-
// break;
|
|
134
|
-
// default:
|
|
135
|
-
// break;
|
|
136
|
-
// }
|
|
137
|
-
// }
|
|
138
|
-
fromConstructor(params) {
|
|
139
|
-
super.fromConstructor(params);
|
|
140
|
-
if (params.status) {
|
|
141
|
-
this.status = params.status;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
toJSON() {
|
|
145
|
-
return {
|
|
146
|
-
...super.toJSON(),
|
|
147
|
-
status: this.status
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
var A_HTTPChannelError = class extends aConcept.A_Error {
|
|
152
|
-
};
|
|
153
|
-
A_HTTPChannelError.HttpRequestError = "HTTP Channel Request Error";
|
|
154
|
-
|
|
155
|
-
// src/channels/A-Http/A-Http.channel.ts
|
|
156
|
-
var A_HTTPChannel = class extends aUtils.A_Channel {
|
|
157
|
-
async connect() {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Allows to send an HTTP request without expecting a response
|
|
162
|
-
*
|
|
163
|
-
* @param params
|
|
164
|
-
*/
|
|
165
|
-
async send(params) {
|
|
166
|
-
this.request(params);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Makes an HTTP request
|
|
170
|
-
*
|
|
171
|
-
* @param params
|
|
172
|
-
* @returns
|
|
173
|
-
*/
|
|
174
|
-
async request(params) {
|
|
175
|
-
const { method, url, data, config } = params;
|
|
176
|
-
await this.initialize;
|
|
177
|
-
this._processing = true;
|
|
178
|
-
const fullUrl = this.buildURL(url, config?.params);
|
|
179
|
-
const requestScope = new aConcept.A_Scope({ name: `a-http-channel-request-scope-${method}-${url}-${Date.now()}` });
|
|
180
|
-
const context = new A_HTTPChannel_RequestContext({
|
|
181
|
-
method,
|
|
182
|
-
url,
|
|
183
|
-
data,
|
|
184
|
-
config
|
|
185
|
-
});
|
|
186
|
-
requestScope.inherit(aConcept.A_Context.scope(this));
|
|
187
|
-
requestScope.register(context);
|
|
188
|
-
try {
|
|
189
|
-
await this.call("onBeforeHttpChannelRequest" /* onBeforeRequest */, requestScope);
|
|
190
|
-
const headers = {
|
|
191
|
-
"Content-Type": "application/json",
|
|
192
|
-
...config?.headers
|
|
193
|
-
};
|
|
194
|
-
const options = {
|
|
195
|
-
method,
|
|
196
|
-
headers
|
|
197
|
-
};
|
|
198
|
-
if (data && method !== "GET" /* GET */) {
|
|
199
|
-
options.body = JSON.stringify(data);
|
|
200
|
-
}
|
|
201
|
-
const response = await fetch(fullUrl, options);
|
|
202
|
-
if (!response.ok) {
|
|
203
|
-
throw new A_ServerError({
|
|
204
|
-
status: response.status,
|
|
205
|
-
title: response.statusText,
|
|
206
|
-
description: `HTTP request to ${fullUrl} failed with status ${response.status}`
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
context.result = config?.params?.responseType === "text" ? await response.text() : config?.params?.responseType === "blob" ? await response.blob() : await response.json();
|
|
210
|
-
await this.call("onAfterHttpChannelRequest" /* onAfterRequest */, requestScope);
|
|
211
|
-
this._processing = false;
|
|
212
|
-
return context;
|
|
213
|
-
} catch (error) {
|
|
214
|
-
this._processing = false;
|
|
215
|
-
context.error = error;
|
|
216
|
-
await this.call("onHttpChannelError" /* onError */, requestScope);
|
|
217
|
-
if (config?.throwOnError === false)
|
|
218
|
-
return context;
|
|
219
|
-
else
|
|
220
|
-
throw error;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
async post(url, body, config) {
|
|
224
|
-
return this.request(
|
|
225
|
-
{
|
|
226
|
-
method: "POST" /* POST */,
|
|
227
|
-
url,
|
|
228
|
-
data: body,
|
|
229
|
-
config
|
|
230
|
-
}
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
async get(url, params, config) {
|
|
234
|
-
return this.request(
|
|
235
|
-
{
|
|
236
|
-
method: "GET" /* GET */,
|
|
237
|
-
url,
|
|
238
|
-
config: {
|
|
239
|
-
...config,
|
|
240
|
-
params
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
async put(url, body, config) {
|
|
246
|
-
return this.request({
|
|
247
|
-
method: "PUT" /* PUT */,
|
|
248
|
-
url,
|
|
249
|
-
data: body,
|
|
250
|
-
config
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
async delete(url, params, config) {
|
|
254
|
-
return this.request({
|
|
255
|
-
method: "DELETE" /* DELETE */,
|
|
256
|
-
url,
|
|
257
|
-
data: params,
|
|
258
|
-
config
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
buildURL(path = "", params = {}) {
|
|
262
|
-
if (!this.baseUrl)
|
|
263
|
-
throw new A_HTTPChannelError(
|
|
264
|
-
A_HTTPChannelError.HttpRequestError,
|
|
265
|
-
"Base URL is not set for HTTP Channel"
|
|
266
|
-
);
|
|
267
|
-
const url = new URL(`${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}`);
|
|
268
|
-
Object.keys(params).forEach((key) => {
|
|
269
|
-
if (params[key] !== void 0 && params[key] !== null) {
|
|
270
|
-
url.searchParams.append(key, params[key]);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
return url.toString();
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
// src/constants/env.constants.ts
|
|
278
|
-
var A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES = {
|
|
279
|
-
// ----------------------------------------------------------
|
|
280
|
-
// A-Server Environment Variables
|
|
281
|
-
// ----------------------------------------------------------
|
|
282
|
-
// These environment variables are used by A-Server to configure the application
|
|
283
|
-
// ----------------------------------------------------------
|
|
284
|
-
/**
|
|
285
|
-
* Port for the server to listen on
|
|
286
|
-
* [!] Default is 3000
|
|
287
|
-
* @default 3000
|
|
288
|
-
*/
|
|
289
|
-
A_SERVER_PORT: "A_SERVER_PORT"
|
|
290
|
-
};
|
|
291
|
-
var A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY = [
|
|
292
|
-
A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES.A_SERVER_PORT
|
|
293
|
-
];
|
|
294
|
-
var A_Server = class extends aConcept.A_Fragment {
|
|
295
|
-
constructor(params) {
|
|
296
|
-
super(params);
|
|
297
|
-
this._routes = [];
|
|
298
|
-
this.port = params.port;
|
|
299
|
-
this.name = params.name;
|
|
300
|
-
this.version = params.version || "v1";
|
|
301
|
-
this._routes = params.routes || this._routes;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* A list of routes that the server will listen to
|
|
305
|
-
*/
|
|
306
|
-
get routes() {
|
|
307
|
-
return this._routes;
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
// src/entities/A-Request/A-Request.entity.types.ts
|
|
312
|
-
var A_SERVER_TYPES__RequestEvent = /* @__PURE__ */ ((A_SERVER_TYPES__RequestEvent2) => {
|
|
313
|
-
A_SERVER_TYPES__RequestEvent2["Error"] = "error";
|
|
314
|
-
A_SERVER_TYPES__RequestEvent2["Finish"] = "finish";
|
|
315
|
-
A_SERVER_TYPES__RequestEvent2["Data"] = "data";
|
|
316
|
-
A_SERVER_TYPES__RequestEvent2["End"] = "end";
|
|
317
|
-
A_SERVER_TYPES__RequestEvent2["Close"] = "close";
|
|
318
|
-
return A_SERVER_TYPES__RequestEvent2;
|
|
319
|
-
})(A_SERVER_TYPES__RequestEvent || {});
|
|
320
|
-
|
|
321
|
-
// src/entities/A-Route/A-Route.entity.ts
|
|
322
|
-
var A_Route = class {
|
|
323
|
-
constructor(param1, param2) {
|
|
324
|
-
this.url = param1 instanceof RegExp ? param1.source : param1;
|
|
325
|
-
this.method = param2 || "GET";
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* returns path only without query and hash
|
|
329
|
-
*/
|
|
330
|
-
get path() {
|
|
331
|
-
const p = this.url.split("?")[0].split("#")[0];
|
|
332
|
-
return p.endsWith("/") ? p.slice(0, -1) : p;
|
|
333
|
-
}
|
|
334
|
-
get params() {
|
|
335
|
-
return this.path.match(/:([^\/]+)/g)?.map((param) => param.slice(1)) || [];
|
|
336
|
-
}
|
|
337
|
-
extractParams(url) {
|
|
338
|
-
const cleanUrl = url.split("?")[0];
|
|
339
|
-
const urlSegments = cleanUrl.split("/").filter(Boolean);
|
|
340
|
-
const maskSegments = this.path.split("/").filter(Boolean);
|
|
341
|
-
const params = {};
|
|
342
|
-
for (let i = 0; i < maskSegments.length; i++) {
|
|
343
|
-
const maskSegment = maskSegments[i];
|
|
344
|
-
const urlSegment = urlSegments[i];
|
|
345
|
-
if (maskSegment.startsWith(":")) {
|
|
346
|
-
const paramName = maskSegment.slice(1);
|
|
347
|
-
params[paramName] = urlSegment;
|
|
348
|
-
} else if (maskSegment !== urlSegment) {
|
|
349
|
-
return {};
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return params;
|
|
353
|
-
}
|
|
354
|
-
extractQuery(url) {
|
|
355
|
-
const query = {};
|
|
356
|
-
const queryString = url.split("?")[1];
|
|
357
|
-
if (!queryString) return query;
|
|
358
|
-
const cleanQuery = queryString.split("#")[0];
|
|
359
|
-
for (const pair of cleanQuery.split("&")) {
|
|
360
|
-
if (!pair) continue;
|
|
361
|
-
const [key, value = ""] = pair.split("=");
|
|
362
|
-
query[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
363
|
-
}
|
|
364
|
-
return query;
|
|
365
|
-
}
|
|
366
|
-
toString() {
|
|
367
|
-
return `${this.method}::${this.path}`;
|
|
368
|
-
}
|
|
369
|
-
toRegExp() {
|
|
370
|
-
return new RegExp(`^${this.method}::${this.path.replace(/\/:([^\/]+)/g, "/([^/]+)")}$`);
|
|
371
|
-
}
|
|
372
|
-
toAFeatureExtension(extensionScope = []) {
|
|
373
|
-
return new RegExp(`^${extensionScope.length ? `(${extensionScope.join("|")})` : ".*"}\\.${this.method}::${this.path.replace(/\/:([^\/]+)/g, "/([^/]+)")}$`);
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
// src/entities/A-Request/A-Request.entity.ts
|
|
378
|
-
var A_Request = class extends aConcept.A_Entity {
|
|
379
|
-
constructor() {
|
|
380
|
-
super(...arguments);
|
|
381
|
-
this.body = {};
|
|
382
|
-
this.params = {};
|
|
383
|
-
this.query = {};
|
|
384
|
-
/**
|
|
385
|
-
* Duration of the request in milliseconds
|
|
386
|
-
*/
|
|
387
|
-
this.duration = 0;
|
|
388
|
-
}
|
|
389
|
-
static get namespace() {
|
|
390
|
-
return "a-server";
|
|
391
|
-
}
|
|
392
|
-
fromNew(newEntity) {
|
|
393
|
-
this.req = newEntity.request;
|
|
394
|
-
this.aseid = new aConcept.ASEID({
|
|
395
|
-
concept: aConcept.A_Context.root.name,
|
|
396
|
-
scope: newEntity.scope,
|
|
397
|
-
entity: this.constructor.entity,
|
|
398
|
-
id: newEntity.id
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
get startedAt() {
|
|
402
|
-
const timeId = aConcept.A_IdentityHelper.parseTimeId(this.aseid.id.split("-")[0]);
|
|
403
|
-
return timeId ? new Date(timeId.timestamp) : void 0;
|
|
404
|
-
}
|
|
405
|
-
// Getter for request URL
|
|
406
|
-
get url() {
|
|
407
|
-
return this.req.url;
|
|
408
|
-
}
|
|
409
|
-
// Getter for request method
|
|
410
|
-
get method() {
|
|
411
|
-
return String(this.req.method).toUpperCase() || "DEFAULT";
|
|
412
|
-
}
|
|
413
|
-
get headers() {
|
|
414
|
-
return this.req.headers;
|
|
415
|
-
}
|
|
416
|
-
get route() {
|
|
417
|
-
return new A_Route(this.url, this.method);
|
|
418
|
-
}
|
|
419
|
-
pipe(destination, options) {
|
|
420
|
-
return this.req.pipe(destination, options);
|
|
421
|
-
}
|
|
422
|
-
async init() {
|
|
423
|
-
this.req.on("error", async (err) => {
|
|
424
|
-
this.error = new A_ServerError(err);
|
|
425
|
-
await this.call("error" /* Error */);
|
|
426
|
-
});
|
|
427
|
-
this.params = this.extractParams(this.url);
|
|
428
|
-
this.query = this.extractQuery(this.url);
|
|
429
|
-
}
|
|
430
|
-
extractParams(url) {
|
|
431
|
-
const cleanUrl = url.split("?")[0];
|
|
432
|
-
const urlSegments = cleanUrl.split("/").filter(Boolean);
|
|
433
|
-
const maskSegments = this.url.split("/").filter(Boolean);
|
|
434
|
-
const params = {};
|
|
435
|
-
for (let i = 0; i < maskSegments.length; i++) {
|
|
436
|
-
const maskSegment = maskSegments[i];
|
|
437
|
-
const urlSegment = urlSegments[i];
|
|
438
|
-
if (maskSegment.startsWith(":")) {
|
|
439
|
-
const paramName = maskSegment.slice(1);
|
|
440
|
-
params[paramName] = urlSegment;
|
|
441
|
-
} else if (maskSegment !== urlSegment) {
|
|
442
|
-
return {};
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
return params;
|
|
446
|
-
}
|
|
447
|
-
extractQuery(url) {
|
|
448
|
-
const query = {};
|
|
449
|
-
const queryString = url.split("?")[1];
|
|
450
|
-
if (!queryString) return query;
|
|
451
|
-
const cleanQuery = queryString.split("#")[0];
|
|
452
|
-
for (const pair of cleanQuery.split("&")) {
|
|
453
|
-
if (!pair) continue;
|
|
454
|
-
const [key, value = ""] = pair.split("=");
|
|
455
|
-
query[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
456
|
-
}
|
|
457
|
-
return query;
|
|
458
|
-
}
|
|
459
|
-
parseBody() {
|
|
460
|
-
return new Promise((resolve, reject) => {
|
|
461
|
-
let body = "";
|
|
462
|
-
this.req.on("data", (chunk) => body += chunk);
|
|
463
|
-
this.req.on("end", () => {
|
|
464
|
-
try {
|
|
465
|
-
resolve(JSON.parse(body));
|
|
466
|
-
} catch (err) {
|
|
467
|
-
reject(err);
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
this.req.on("error", reject);
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
// src/entities/A-Response/A-Response.entity.types.ts
|
|
476
|
-
var A_SERVER_TYPES__ResponseEvent = /* @__PURE__ */ ((A_SERVER_TYPES__ResponseEvent2) => {
|
|
477
|
-
A_SERVER_TYPES__ResponseEvent2["Error"] = "error";
|
|
478
|
-
A_SERVER_TYPES__ResponseEvent2["Finish"] = "finish";
|
|
479
|
-
A_SERVER_TYPES__ResponseEvent2["Data"] = "data";
|
|
480
|
-
A_SERVER_TYPES__ResponseEvent2["End"] = "end";
|
|
481
|
-
A_SERVER_TYPES__ResponseEvent2["Close"] = "close";
|
|
482
|
-
return A_SERVER_TYPES__ResponseEvent2;
|
|
483
|
-
})(A_SERVER_TYPES__ResponseEvent || {});
|
|
484
|
-
var A_Response = class extends aConcept.A_Entity {
|
|
485
|
-
constructor() {
|
|
486
|
-
super(...arguments);
|
|
487
|
-
/**
|
|
488
|
-
* Duration of the request in milliseconds
|
|
489
|
-
*/
|
|
490
|
-
this.duration = 0;
|
|
491
|
-
this.data = /* @__PURE__ */ new Map();
|
|
492
|
-
}
|
|
493
|
-
fromNew(newEntity) {
|
|
494
|
-
this.res = newEntity.response;
|
|
495
|
-
this.aseid = new aConcept.ASEID({
|
|
496
|
-
concept: aConcept.A_Context.root.name,
|
|
497
|
-
scope: newEntity.scope,
|
|
498
|
-
entity: this.constructor.entity,
|
|
499
|
-
id: newEntity.id
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
get headersSent() {
|
|
503
|
-
return this.res.headersSent;
|
|
504
|
-
}
|
|
505
|
-
get original() {
|
|
506
|
-
return this.res;
|
|
507
|
-
}
|
|
508
|
-
get statusCode() {
|
|
509
|
-
return this.res.statusCode;
|
|
510
|
-
}
|
|
511
|
-
async init() {
|
|
512
|
-
const startTime = process.hrtime();
|
|
513
|
-
this.res.on("finish", async () => {
|
|
514
|
-
const elapsedTime = process.hrtime(startTime);
|
|
515
|
-
const elapsedMilliseconds = elapsedTime[0] * 1e3 + elapsedTime[1] / 1e6;
|
|
516
|
-
this.duration = elapsedMilliseconds;
|
|
517
|
-
await this.call("finish" /* Finish */);
|
|
518
|
-
});
|
|
519
|
-
this.res.on("close", async () => {
|
|
520
|
-
await this.call("close" /* Close */);
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
failed(error) {
|
|
524
|
-
switch (true) {
|
|
525
|
-
case error instanceof A_ServerError:
|
|
526
|
-
this.error = error;
|
|
527
|
-
break;
|
|
528
|
-
case error instanceof aConcept.A_Error:
|
|
529
|
-
this.error = new A_ServerError(error);
|
|
530
|
-
break;
|
|
531
|
-
default:
|
|
532
|
-
this.error = new A_ServerError(error);
|
|
533
|
-
break;
|
|
534
|
-
}
|
|
535
|
-
return this.status(this.error.status).json(this.error);
|
|
536
|
-
}
|
|
537
|
-
// Send a plain text or JSON response
|
|
538
|
-
send(data = this.toResponse()) {
|
|
539
|
-
const logger = aConcept.A_Context.scope(this).resolve(aUtils.A_Logger);
|
|
540
|
-
if (this.headersSent) {
|
|
541
|
-
logger.warning("Response headers already sent, cannot send response again.");
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
try {
|
|
545
|
-
switch (true) {
|
|
546
|
-
case (!!data && typeof data === "object"):
|
|
547
|
-
return this.json(data);
|
|
548
|
-
case (!!data && typeof data === "string"):
|
|
549
|
-
this.res.setHeader("Content-Type", "text/plain");
|
|
550
|
-
this.res.writeHead(this.statusCode);
|
|
551
|
-
this.res.end(data);
|
|
552
|
-
return;
|
|
553
|
-
default:
|
|
554
|
-
this.res.writeHead(this.statusCode);
|
|
555
|
-
this.res.end(data);
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
} catch (error) {
|
|
559
|
-
logger.warning("Response send error:", error);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
destroy(error, scope) {
|
|
563
|
-
this.res.end();
|
|
564
|
-
return super.destroy(scope);
|
|
565
|
-
}
|
|
566
|
-
// Explicit JSON response
|
|
567
|
-
json(data = this.toResponse()) {
|
|
568
|
-
const logger = aConcept.A_Context.scope(this).resolve(aUtils.A_Logger);
|
|
569
|
-
if (this.headersSent) {
|
|
570
|
-
logger.warning("Response headers already sent, cannot send response again.");
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
this.res.setHeader("Content-Type", "application/json");
|
|
574
|
-
this.res.writeHead(this.statusCode);
|
|
575
|
-
this.res.end(JSON.stringify(data));
|
|
576
|
-
}
|
|
577
|
-
// Set HTTP status code
|
|
578
|
-
status(code) {
|
|
579
|
-
this.res.statusCode = code;
|
|
580
|
-
return this;
|
|
581
|
-
}
|
|
582
|
-
writeHead(statusCode, headers) {
|
|
583
|
-
this.res.writeHead(statusCode, headers);
|
|
584
|
-
}
|
|
585
|
-
setHeader(key, value) {
|
|
586
|
-
this.res.setHeader(key, value);
|
|
587
|
-
}
|
|
588
|
-
getHeader(key) {
|
|
589
|
-
return this.res.getHeader(key);
|
|
590
|
-
}
|
|
591
|
-
add(key, data) {
|
|
592
|
-
this.data.set(key, data);
|
|
593
|
-
}
|
|
594
|
-
toResponse() {
|
|
595
|
-
return Array.from(this.data.entries()).reduce((acc, [key, value]) => {
|
|
596
|
-
if (value instanceof aConcept.A_Entity)
|
|
597
|
-
acc[key] = value.toJSON();
|
|
598
|
-
else
|
|
599
|
-
acc[key] = value;
|
|
600
|
-
return acc;
|
|
601
|
-
}, {});
|
|
602
|
-
}
|
|
603
|
-
};
|
|
604
|
-
var A_ServerLogger = class extends aUtils.A_Logger {
|
|
605
|
-
async onRequestEnd(request, response) {
|
|
606
|
-
this.route({
|
|
607
|
-
method: request.method,
|
|
608
|
-
url: request.url,
|
|
609
|
-
status: response.statusCode,
|
|
610
|
-
responseTime: response.duration
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
async onRequestError(request) {
|
|
614
|
-
}
|
|
615
|
-
logStart(container) {
|
|
616
|
-
this.serverReady({
|
|
617
|
-
port: container.port,
|
|
618
|
-
app: {
|
|
619
|
-
name: container.name
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
logStop(server) {
|
|
624
|
-
this.log("red", `Server ${server.name} stopped`);
|
|
625
|
-
}
|
|
626
|
-
metrics() {
|
|
627
|
-
}
|
|
628
|
-
routes(routes) {
|
|
629
|
-
const time = this.getTime();
|
|
630
|
-
console.log(`\x1B[36m[${this.scope.name}] |${time}| Exposed Routes:
|
|
631
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
632
|
-
${routes.map((route) => `${" ".repeat(this.scopeLength + 3)}| [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.path}`).join("\n")}
|
|
633
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------\x1B[0m`);
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Logs the route information based on status code
|
|
637
|
-
*
|
|
638
|
-
* @param route
|
|
639
|
-
*/
|
|
640
|
-
route(route) {
|
|
641
|
-
switch (route.status) {
|
|
642
|
-
case 200:
|
|
643
|
-
this.log200(route);
|
|
644
|
-
break;
|
|
645
|
-
case 404:
|
|
646
|
-
this.log404(route);
|
|
647
|
-
break;
|
|
648
|
-
case 500:
|
|
649
|
-
this.log500(route);
|
|
650
|
-
break;
|
|
651
|
-
case 400:
|
|
652
|
-
this.log400(route);
|
|
653
|
-
break;
|
|
654
|
-
default:
|
|
655
|
-
this.logDefault(route);
|
|
656
|
-
break;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
log200(route) {
|
|
660
|
-
if (this.config.get("SERVER_IGNORE_LOG_200"))
|
|
661
|
-
return;
|
|
662
|
-
console.log(`\x1B[32m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
|
|
663
|
-
}
|
|
664
|
-
log404(route) {
|
|
665
|
-
if (this.config.get("SERVER_IGNORE_LOG_404"))
|
|
666
|
-
return;
|
|
667
|
-
console.log(`\x1B[33m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
|
|
668
|
-
}
|
|
669
|
-
log500(route) {
|
|
670
|
-
if (this.config.get("SERVER_IGNORE_LOG_500"))
|
|
671
|
-
return;
|
|
672
|
-
console.log(`\x1B[31m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
|
|
673
|
-
}
|
|
674
|
-
log400(route) {
|
|
675
|
-
if (this.config.get("SERVER_IGNORE_LOG_400"))
|
|
676
|
-
return;
|
|
677
|
-
console.log(`\x1B[33m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
|
|
678
|
-
}
|
|
679
|
-
logDefault(route) {
|
|
680
|
-
if (this.config.get("SERVER_IGNORE_LOG_DEFAULT"))
|
|
681
|
-
return;
|
|
682
|
-
console.log(`\x1B[36m[${this.scope.name}] |${this.getTime()}| ${route.status} | [${route.method.toUpperCase()}]${" ".repeat(7 - route.method.length)} ${route.url} | ${route.responseTime}ms\x1B[0m`);
|
|
683
|
-
}
|
|
684
|
-
serverReady(params) {
|
|
685
|
-
const processId = process.pid;
|
|
686
|
-
console.log(`\x1B[36m[${this.scope.name}] |${this.getTime()}| Server Ready:
|
|
687
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
688
|
-
${" ".repeat(this.scopeLength + 3)}| ${params.app.name} v${params.app.version || "0.0.1"} is running on port ${params.port}
|
|
689
|
-
${" ".repeat(this.scopeLength + 3)}| Process ID: ${processId}
|
|
690
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------
|
|
691
|
-
${" ".repeat(this.scopeLength + 3)}| ==============================
|
|
692
|
-
${" ".repeat(this.scopeLength + 3)}| LISTENING...
|
|
693
|
-
${" ".repeat(this.scopeLength + 3)}| ==============================
|
|
694
|
-
\x1B[0m`);
|
|
695
|
-
}
|
|
696
|
-
/**
|
|
697
|
-
* Displays a proxy routes
|
|
698
|
-
*
|
|
699
|
-
* @param params
|
|
700
|
-
*/
|
|
701
|
-
proxy(params) {
|
|
702
|
-
console.log(`\x1B[35m[${this.scope.name}] |${this.getTime()}| Proxy:
|
|
703
|
-
${" ".repeat(this.scopeLength + 3)}| ${params.original} -> ${params.destination}
|
|
704
|
-
${" ".repeat(this.scopeLength + 3)}|-------------------------------\x1B[0m`);
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
__decorateClass([
|
|
708
|
-
aConcept.A_Feature.Extend({
|
|
709
|
-
name: "finish" /* Finish */,
|
|
710
|
-
scope: [A_Response]
|
|
711
|
-
}),
|
|
712
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
713
|
-
__decorateParam(1, aConcept.A_Inject(A_Response))
|
|
714
|
-
], A_ServerLogger.prototype, "onRequestEnd");
|
|
715
|
-
__decorateClass([
|
|
716
|
-
aConcept.A_Feature.Extend({
|
|
717
|
-
name: "error" /* Error */
|
|
718
|
-
}),
|
|
719
|
-
__decorateParam(0, aConcept.A_Inject(A_Request))
|
|
720
|
-
], A_ServerLogger.prototype, "onRequestError");
|
|
721
|
-
__decorateClass([
|
|
722
|
-
aConcept.A_Feature.Extend({
|
|
723
|
-
name: "afterStart" /* afterStart */,
|
|
724
|
-
scope: [A_Service]
|
|
725
|
-
}),
|
|
726
|
-
__decorateParam(0, aConcept.A_Inject(A_Service))
|
|
727
|
-
], A_ServerLogger.prototype, "logStart");
|
|
728
|
-
__decorateClass([
|
|
729
|
-
aConcept.A_Feature.Extend({
|
|
730
|
-
name: "afterStop" /* afterStop */,
|
|
731
|
-
scope: [A_Service]
|
|
732
|
-
}),
|
|
733
|
-
__decorateParam(0, aConcept.A_Inject(A_Server))
|
|
734
|
-
], A_ServerLogger.prototype, "logStop");
|
|
735
|
-
|
|
736
|
-
// src/containers/A-Service/A-Service.container.ts
|
|
737
|
-
var A_Service = class extends aConcept.A_Container {
|
|
738
|
-
async load() {
|
|
739
|
-
if (!this.scope.has(A_ServerLogger))
|
|
740
|
-
this.scope.register(A_ServerLogger);
|
|
741
|
-
this.scope.resolve(A_ServerLogger);
|
|
742
|
-
let polyfill;
|
|
743
|
-
if (!this.scope.has(aUtils.A_Polyfill))
|
|
744
|
-
this.scope.register(aUtils.A_Polyfill);
|
|
745
|
-
polyfill = this.scope.resolve(aUtils.A_Polyfill);
|
|
746
|
-
let config;
|
|
747
|
-
if (!this.scope.has(aUtils.A_Config)) {
|
|
748
|
-
const config2 = new aUtils.A_Config({
|
|
749
|
-
variables: [...Array.from(A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY)],
|
|
750
|
-
defaults: {
|
|
751
|
-
A_SERVER_PORT: 3e3
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
this.scope.register(config2);
|
|
755
|
-
}
|
|
756
|
-
config = this.scope.resolve(aUtils.A_Config);
|
|
757
|
-
if (!this.scope.has(A_Server)) {
|
|
758
|
-
new A_Server({
|
|
759
|
-
port: config.get("A_SERVER_PORT"),
|
|
760
|
-
name: this.name,
|
|
761
|
-
version: "v1"
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
this.port = config.get("A_SERVER_PORT");
|
|
765
|
-
const http = await polyfill.http();
|
|
766
|
-
this.server = http.createServer(this.onRequest.bind(this));
|
|
767
|
-
}
|
|
768
|
-
listen() {
|
|
769
|
-
return new Promise((resolve, reject) => {
|
|
770
|
-
this.server.listen(this.port, () => {
|
|
771
|
-
resolve();
|
|
772
|
-
});
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
close() {
|
|
776
|
-
return new Promise((resolve, reject) => {
|
|
777
|
-
this.server.close(() => {
|
|
778
|
-
resolve();
|
|
779
|
-
});
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Start the server
|
|
784
|
-
*/
|
|
785
|
-
async start() {
|
|
786
|
-
await this.beforeStart();
|
|
787
|
-
await this.listen();
|
|
788
|
-
await this.afterStart();
|
|
789
|
-
}
|
|
790
|
-
async beforeStart() {
|
|
791
|
-
}
|
|
792
|
-
async afterStart() {
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* Stop service
|
|
796
|
-
*/
|
|
797
|
-
async stop() {
|
|
798
|
-
await this.call("beforeStop" /* beforeStop */);
|
|
799
|
-
await this.server.close();
|
|
800
|
-
await this.call("afterStop" /* afterStop */);
|
|
801
|
-
}
|
|
802
|
-
async beforeRequest(scope) {
|
|
803
|
-
}
|
|
804
|
-
async afterRequest(scope) {
|
|
805
|
-
}
|
|
806
|
-
async onRequest(request, response) {
|
|
807
|
-
const scope = new aConcept.A_Scope({
|
|
808
|
-
name: `a-server-request::${Date.now()}`
|
|
809
|
-
});
|
|
810
|
-
const { req, res } = await this.convertToAServer(request, response);
|
|
811
|
-
try {
|
|
812
|
-
scope.register(req);
|
|
813
|
-
scope.register(res);
|
|
814
|
-
scope.inherit(this.scope);
|
|
815
|
-
await this.beforeRequest(scope);
|
|
816
|
-
await this.call("onRequest" /* onRequest */, scope);
|
|
817
|
-
await this.afterRequest(scope);
|
|
818
|
-
await res.status(200).send();
|
|
819
|
-
} catch (error) {
|
|
820
|
-
const logger = this.scope.resolve(aUtils.A_Logger);
|
|
821
|
-
logger.error(error);
|
|
822
|
-
return res.failed(error);
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
async convertToAServer(request, response) {
|
|
826
|
-
if (!request.method || !request.url)
|
|
827
|
-
throw new aConcept.A_Error("Request method or url is missing");
|
|
828
|
-
const id = await this.generateRequestId(request.method, request.url);
|
|
829
|
-
const req = new A_Request({ id, request, scope: this.scope.name });
|
|
830
|
-
const res = new A_Response({ id, response, scope: this.scope.name });
|
|
831
|
-
await req.init();
|
|
832
|
-
await res.init();
|
|
833
|
-
return { req, res };
|
|
834
|
-
}
|
|
835
|
-
async generateRequestId(method, url) {
|
|
836
|
-
const crypto = await this.scope.resolve(aUtils.A_Polyfill).crypto();
|
|
837
|
-
const timeId = aConcept.A_IdentityHelper.generateTimeId();
|
|
838
|
-
const randomValue = Math.random().toString();
|
|
839
|
-
const hash = await crypto.createTextHash(`${timeId}-${method}-${url}-${randomValue}`, "sha256");
|
|
840
|
-
return `${timeId}-${hash}`;
|
|
841
|
-
}
|
|
842
|
-
async beforeStop() {
|
|
843
|
-
}
|
|
844
|
-
async afterStop() {
|
|
845
|
-
}
|
|
846
|
-
};
|
|
847
|
-
__decorateClass([
|
|
848
|
-
aConcept.A_Concept.Load()
|
|
849
|
-
], A_Service.prototype, "load");
|
|
850
|
-
__decorateClass([
|
|
851
|
-
aConcept.A_Concept.Start()
|
|
852
|
-
], A_Service.prototype, "start");
|
|
853
|
-
__decorateClass([
|
|
854
|
-
aConcept.A_Feature.Define({ invoke: true })
|
|
855
|
-
], A_Service.prototype, "beforeStart");
|
|
856
|
-
__decorateClass([
|
|
857
|
-
aConcept.A_Feature.Define({ invoke: true })
|
|
858
|
-
], A_Service.prototype, "afterStart");
|
|
859
|
-
__decorateClass([
|
|
860
|
-
aConcept.A_Concept.Stop()
|
|
861
|
-
], A_Service.prototype, "stop");
|
|
862
|
-
__decorateClass([
|
|
863
|
-
aConcept.A_Feature.Define({
|
|
864
|
-
name: "beforeRequest" /* beforeRequest */,
|
|
865
|
-
invoke: true
|
|
866
|
-
})
|
|
867
|
-
], A_Service.prototype, "beforeRequest");
|
|
868
|
-
__decorateClass([
|
|
869
|
-
aConcept.A_Feature.Define({
|
|
870
|
-
name: "beforeRequest" /* beforeRequest */,
|
|
871
|
-
invoke: true
|
|
872
|
-
})
|
|
873
|
-
], A_Service.prototype, "afterRequest");
|
|
874
|
-
__decorateClass([
|
|
875
|
-
aConcept.A_Feature.Define({
|
|
876
|
-
name: "onRequest" /* onRequest */,
|
|
877
|
-
invoke: false
|
|
878
|
-
})
|
|
879
|
-
], A_Service.prototype, "onRequest");
|
|
880
|
-
__decorateClass([
|
|
881
|
-
aConcept.A_Feature.Define({ invoke: true })
|
|
882
|
-
], A_Service.prototype, "beforeStop");
|
|
883
|
-
__decorateClass([
|
|
884
|
-
aConcept.A_Feature.Define({ invoke: true })
|
|
885
|
-
], A_Service.prototype, "afterStop");
|
|
886
|
-
|
|
887
|
-
// src/context/A-ProxyConfig/A_ProxyConfig.constants.ts
|
|
888
|
-
var PROXY_CONFIG_DEFAULTS = {
|
|
889
|
-
path: "/",
|
|
890
|
-
hostname: "localhost",
|
|
891
|
-
port: 80,
|
|
892
|
-
method: "GET",
|
|
893
|
-
headers: {},
|
|
894
|
-
protocol: "http"
|
|
895
|
-
};
|
|
896
|
-
|
|
897
|
-
// src/context/A-ProxyConfig/A_ProxyConfig.context.ts
|
|
898
|
-
var A_ProxyConfig = class extends aConcept.A_Fragment {
|
|
899
|
-
constructor(configs = {}) {
|
|
900
|
-
super();
|
|
901
|
-
this._configs = Object.entries(configs).map(([path, config]) => {
|
|
902
|
-
const targetUrl = new URL(typeof config === "string" ? config : config.hostname || "");
|
|
903
|
-
const port = targetUrl.port || (targetUrl.protocol === "https:" ? "443" : "80");
|
|
904
|
-
const prepared = {
|
|
905
|
-
...PROXY_CONFIG_DEFAULTS,
|
|
906
|
-
...typeof config === "string" ? {
|
|
907
|
-
path,
|
|
908
|
-
port: parseInt(port),
|
|
909
|
-
protocol: targetUrl.protocol,
|
|
910
|
-
hostname: targetUrl.hostname
|
|
911
|
-
} : config
|
|
912
|
-
};
|
|
913
|
-
return {
|
|
914
|
-
route: new A_Route(prepared.path, prepared.method),
|
|
915
|
-
hostname: prepared.hostname,
|
|
916
|
-
port: prepared.port,
|
|
917
|
-
headers: prepared.headers,
|
|
918
|
-
protocol: prepared.protocol
|
|
919
|
-
};
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* Returns all configured proxy configs
|
|
924
|
-
*
|
|
925
|
-
*/
|
|
926
|
-
get configs() {
|
|
927
|
-
return this._configs;
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Checks if a given path is configured in the proxy
|
|
931
|
-
*
|
|
932
|
-
* @param path
|
|
933
|
-
* @returns
|
|
934
|
-
*/
|
|
935
|
-
has(path) {
|
|
936
|
-
return this._configs.some((route) => route.route.toRegExp().test(path));
|
|
937
|
-
}
|
|
938
|
-
/**
|
|
939
|
-
* Returns the proxy configuration for a given path, if exists
|
|
940
|
-
*
|
|
941
|
-
* @param path
|
|
942
|
-
* @returns
|
|
943
|
-
*/
|
|
944
|
-
config(path) {
|
|
945
|
-
return this._configs.find((route) => route.route.toRegExp().test(path));
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
var A_StaticConfig = class extends aConcept.A_Fragment {
|
|
949
|
-
constructor(directories = [], directoryConfigs = []) {
|
|
950
|
-
super();
|
|
951
|
-
this._aliases = /* @__PURE__ */ new Map();
|
|
952
|
-
this._directoryConfigs = [];
|
|
953
|
-
this.directories = directories;
|
|
954
|
-
this._directoryConfigs = directoryConfigs;
|
|
955
|
-
this.initializeDefaultAliases();
|
|
956
|
-
this.initializeCustomAliases();
|
|
957
|
-
}
|
|
958
|
-
initializeDefaultAliases() {
|
|
959
|
-
this.directories.forEach((dir, index) => {
|
|
960
|
-
const alias = {
|
|
961
|
-
alias: `/static${index > 0 ? index : ""}`,
|
|
962
|
-
path: `/static${index > 0 ? index : ""}`,
|
|
963
|
-
directory: dir,
|
|
964
|
-
enabled: true
|
|
965
|
-
};
|
|
966
|
-
this._aliases.set(alias.path, alias);
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
initializeCustomAliases() {
|
|
970
|
-
this._directoryConfigs.forEach((config) => {
|
|
971
|
-
const alias = {
|
|
972
|
-
alias: config.alias || config.path,
|
|
973
|
-
path: config.path,
|
|
974
|
-
directory: config.directory,
|
|
975
|
-
enabled: true
|
|
976
|
-
};
|
|
977
|
-
this._aliases.set(alias.path, alias);
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
/**
|
|
981
|
-
* Add a custom static file alias
|
|
982
|
-
* @param alias - The URL path alias (e.g., '/assets')
|
|
983
|
-
* @param directory - The local directory path
|
|
984
|
-
* @param path - Optional custom path (defaults to alias)
|
|
985
|
-
*/
|
|
986
|
-
addAlias(alias, directory, path) {
|
|
987
|
-
const staticAlias = {
|
|
988
|
-
alias,
|
|
989
|
-
path: path || alias,
|
|
990
|
-
directory,
|
|
991
|
-
enabled: true
|
|
992
|
-
};
|
|
993
|
-
this._aliases.set(staticAlias.path, staticAlias);
|
|
994
|
-
}
|
|
995
|
-
/**
|
|
996
|
-
* Remove a static file alias
|
|
997
|
-
* @param aliasPath - The path of the alias to remove
|
|
998
|
-
*/
|
|
999
|
-
removeAlias(aliasPath) {
|
|
1000
|
-
return this._aliases.delete(aliasPath);
|
|
1001
|
-
}
|
|
1002
|
-
/**
|
|
1003
|
-
* Enable or disable an alias
|
|
1004
|
-
* @param aliasPath - The path of the alias
|
|
1005
|
-
* @param enabled - Whether to enable or disable
|
|
1006
|
-
*/
|
|
1007
|
-
setAliasEnabled(aliasPath, enabled) {
|
|
1008
|
-
const alias = this._aliases.get(aliasPath);
|
|
1009
|
-
if (alias) {
|
|
1010
|
-
alias.enabled = enabled;
|
|
1011
|
-
return true;
|
|
1012
|
-
}
|
|
1013
|
-
return false;
|
|
1014
|
-
}
|
|
1015
|
-
/**
|
|
1016
|
-
* Get all configured aliases
|
|
1017
|
-
*/
|
|
1018
|
-
getAliases() {
|
|
1019
|
-
return Array.from(this._aliases.values());
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Get enabled aliases only
|
|
1023
|
-
*/
|
|
1024
|
-
getEnabledAliases() {
|
|
1025
|
-
return Array.from(this._aliases.values()).filter((alias) => alias.enabled !== false);
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
* Find the best matching alias for a given request path
|
|
1029
|
-
* @param requestPath - The request path to match
|
|
1030
|
-
*/
|
|
1031
|
-
findMatchingAlias(requestPath) {
|
|
1032
|
-
let bestMatch = null;
|
|
1033
|
-
let longestMatch = 0;
|
|
1034
|
-
for (const alias of this.getEnabledAliases()) {
|
|
1035
|
-
if (requestPath.startsWith(alias.path) && alias.path.length > longestMatch) {
|
|
1036
|
-
bestMatch = alias;
|
|
1037
|
-
longestMatch = alias.path.length;
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
return bestMatch;
|
|
1041
|
-
}
|
|
1042
|
-
/**
|
|
1043
|
-
* Check if an alias exists
|
|
1044
|
-
* @param aliasPath - The path to check
|
|
1045
|
-
*/
|
|
1046
|
-
hasAlias(aliasPath) {
|
|
1047
|
-
return this._aliases.has(aliasPath);
|
|
1048
|
-
}
|
|
1049
|
-
/**
|
|
1050
|
-
* Get a specific alias by path
|
|
1051
|
-
* @param aliasPath - The path of the alias
|
|
1052
|
-
*/
|
|
1053
|
-
getAlias(aliasPath) {
|
|
1054
|
-
return this._aliases.get(aliasPath);
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
* Add multiple aliases at once
|
|
1058
|
-
* @param aliases - Array of alias configurations
|
|
1059
|
-
*/
|
|
1060
|
-
addAliases(aliases) {
|
|
1061
|
-
aliases.forEach((config) => {
|
|
1062
|
-
this.addAlias(config.alias || config.path, config.directory, config.path);
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
/**
|
|
1066
|
-
* Clear all aliases
|
|
1067
|
-
*/
|
|
1068
|
-
clearAliases() {
|
|
1069
|
-
this._aliases.clear();
|
|
1070
|
-
}
|
|
1071
|
-
/**
|
|
1072
|
-
* Update an existing alias
|
|
1073
|
-
* @param aliasPath - The path of the alias to update
|
|
1074
|
-
* @param updates - Partial updates to apply
|
|
1075
|
-
*/
|
|
1076
|
-
updateAlias(aliasPath, updates) {
|
|
1077
|
-
const alias = this._aliases.get(aliasPath);
|
|
1078
|
-
if (alias) {
|
|
1079
|
-
Object.assign(alias, updates);
|
|
1080
|
-
return true;
|
|
1081
|
-
}
|
|
1082
|
-
return false;
|
|
1083
|
-
}
|
|
1084
|
-
/**
|
|
1085
|
-
* Get statistics about configured aliases
|
|
1086
|
-
*/
|
|
1087
|
-
getStats() {
|
|
1088
|
-
const aliases = this.getAliases();
|
|
1089
|
-
const enabled = aliases.filter((a) => a.enabled !== false);
|
|
1090
|
-
const disabled = aliases.filter((a) => a.enabled === false);
|
|
1091
|
-
const directories = [...new Set(aliases.map((a) => a.directory))];
|
|
1092
|
-
return {
|
|
1093
|
-
total: aliases.length,
|
|
1094
|
-
enabled: enabled.length,
|
|
1095
|
-
disabled: disabled.length,
|
|
1096
|
-
directories
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Checks if a given path is configured in the proxy (legacy method)
|
|
1101
|
-
* @deprecated Use findMatchingAlias instead
|
|
1102
|
-
* @param path
|
|
1103
|
-
* @returns
|
|
1104
|
-
*/
|
|
1105
|
-
has(path) {
|
|
1106
|
-
const alias = this.findMatchingAlias(path);
|
|
1107
|
-
return alias ? alias.directory : false;
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
var A_ListQueryFilter = class extends aConcept.A_Fragment {
|
|
1111
|
-
constructor(_query = {}, defaults = {}) {
|
|
1112
|
-
super();
|
|
1113
|
-
this._query = _query;
|
|
1114
|
-
this.defaults = defaults;
|
|
1115
|
-
this.parsedQuery = this.parseQueryString(_query);
|
|
1116
|
-
}
|
|
1117
|
-
get query() {
|
|
1118
|
-
return this._query;
|
|
1119
|
-
}
|
|
1120
|
-
get(property, defaultValue = "") {
|
|
1121
|
-
return this.parsedQuery[property] || this.defaults[property] || defaultValue;
|
|
1122
|
-
}
|
|
1123
|
-
parseQueryString(value = {}) {
|
|
1124
|
-
if (typeof value === "string") {
|
|
1125
|
-
return value.split("&").reduce((acc, part) => {
|
|
1126
|
-
const [key, val] = part.split("=");
|
|
1127
|
-
acc[decodeURIComponent(key)] = decodeURIComponent(val || "");
|
|
1128
|
-
return acc;
|
|
1129
|
-
}, {});
|
|
1130
|
-
}
|
|
1131
|
-
return value;
|
|
1132
|
-
}
|
|
1133
|
-
};
|
|
1134
|
-
var A_EntityFactory = class extends aConcept.A_Fragment {
|
|
1135
|
-
constructor(param1, param2) {
|
|
1136
|
-
super();
|
|
1137
|
-
this._entities = /* @__PURE__ */ new Map();
|
|
1138
|
-
this._setEntities(param1);
|
|
1139
|
-
this._setEntities(param2);
|
|
1140
|
-
}
|
|
1141
|
-
_setEntities(entities = []) {
|
|
1142
|
-
if (Array.isArray(entities)) {
|
|
1143
|
-
entities.forEach((entity) => {
|
|
1144
|
-
this._entities.set(entity.entity, entity);
|
|
1145
|
-
});
|
|
1146
|
-
} else {
|
|
1147
|
-
Object.keys(entities).forEach((key) => {
|
|
1148
|
-
this._entities.set(key, entities[key]);
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
add(param1, param2) {
|
|
1153
|
-
switch (true) {
|
|
1154
|
-
case (typeof param1 === "string" && !!param2):
|
|
1155
|
-
this._entities.set(param1, param2);
|
|
1156
|
-
break;
|
|
1157
|
-
case typeof param1 !== "string":
|
|
1158
|
-
this._entities.set(param1.entity, param1);
|
|
1159
|
-
break;
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
has(param1) {
|
|
1163
|
-
let name;
|
|
1164
|
-
switch (true) {
|
|
1165
|
-
case param1 instanceof aConcept.ASEID:
|
|
1166
|
-
name = param1.entity;
|
|
1167
|
-
break;
|
|
1168
|
-
case (!(param1 instanceof aConcept.ASEID) && aConcept.ASEID.isASEID(param1)):
|
|
1169
|
-
name = new aConcept.ASEID(param1).entity;
|
|
1170
|
-
break;
|
|
1171
|
-
default:
|
|
1172
|
-
name = param1;
|
|
1173
|
-
break;
|
|
1174
|
-
}
|
|
1175
|
-
return this._entities.has(name);
|
|
1176
|
-
}
|
|
1177
|
-
resolve(param1) {
|
|
1178
|
-
let name;
|
|
1179
|
-
switch (true) {
|
|
1180
|
-
case param1 instanceof aConcept.ASEID:
|
|
1181
|
-
name = param1.entity;
|
|
1182
|
-
break;
|
|
1183
|
-
case (typeof param1 === "string" && aConcept.ASEID.isASEID(param1)):
|
|
1184
|
-
name = new aConcept.ASEID(param1).entity;
|
|
1185
|
-
break;
|
|
1186
|
-
default:
|
|
1187
|
-
name = param1;
|
|
1188
|
-
break;
|
|
1189
|
-
}
|
|
1190
|
-
return this._entities.get(name);
|
|
1191
|
-
}
|
|
1192
|
-
resolveByName(name) {
|
|
1193
|
-
return this._entities.get(name);
|
|
1194
|
-
}
|
|
1195
|
-
};
|
|
1196
|
-
var A_EntityList = class extends aConcept.A_Entity {
|
|
1197
|
-
constructor() {
|
|
1198
|
-
super(...arguments);
|
|
1199
|
-
this._items = [];
|
|
1200
|
-
this._pagination = {
|
|
1201
|
-
total: 0,
|
|
1202
|
-
page: 1,
|
|
1203
|
-
pageSize: 10
|
|
1204
|
-
};
|
|
1205
|
-
}
|
|
1206
|
-
static get scope() {
|
|
1207
|
-
return "a-server";
|
|
1208
|
-
}
|
|
1209
|
-
/**
|
|
1210
|
-
* Returns the entity constructor used for the list
|
|
1211
|
-
*/
|
|
1212
|
-
get entityConstructor() {
|
|
1213
|
-
return this._entityConstructor;
|
|
1214
|
-
}
|
|
1215
|
-
/**
|
|
1216
|
-
* Returns the list of items contained in the entity list
|
|
1217
|
-
*/
|
|
1218
|
-
get items() {
|
|
1219
|
-
return this._items;
|
|
1220
|
-
}
|
|
1221
|
-
/**
|
|
1222
|
-
* Returns pagination information about the entity list
|
|
1223
|
-
*/
|
|
1224
|
-
get pagination() {
|
|
1225
|
-
return this._pagination;
|
|
1226
|
-
}
|
|
1227
|
-
/**
|
|
1228
|
-
* Creates a new instance of A_EntityList
|
|
1229
|
-
*
|
|
1230
|
-
* @param newEntity
|
|
1231
|
-
*/
|
|
1232
|
-
fromNew(newEntity) {
|
|
1233
|
-
this.aseid = new aConcept.ASEID({
|
|
1234
|
-
concept: aConcept.A_Context.root.name,
|
|
1235
|
-
scope: "default",
|
|
1236
|
-
entity: "a-list" + (newEntity.name ? `.${newEntity.name}` : ""),
|
|
1237
|
-
id: (/* @__PURE__ */ new Date()).getTime().toString()
|
|
1238
|
-
});
|
|
1239
|
-
this._entityConstructor = newEntity.constructor;
|
|
1240
|
-
}
|
|
1241
|
-
/**
|
|
1242
|
-
* Allows to convert Repository Response data to EntityList instance
|
|
1243
|
-
*
|
|
1244
|
-
* [!] This method does not load the data from the repository, it only converts the data to the EntityList instance
|
|
1245
|
-
*
|
|
1246
|
-
* @param items
|
|
1247
|
-
* @param pagination
|
|
1248
|
-
*/
|
|
1249
|
-
fromList(items, pagination) {
|
|
1250
|
-
this._items = items.map((item) => {
|
|
1251
|
-
if (item instanceof aConcept.A_Entity) {
|
|
1252
|
-
return item;
|
|
1253
|
-
} else {
|
|
1254
|
-
const entity = new this._entityConstructor(item);
|
|
1255
|
-
return entity;
|
|
1256
|
-
}
|
|
1257
|
-
});
|
|
1258
|
-
if (pagination) {
|
|
1259
|
-
this._pagination = {
|
|
1260
|
-
total: pagination.total,
|
|
1261
|
-
page: pagination.page,
|
|
1262
|
-
pageSize: pagination.pageSize
|
|
1263
|
-
};
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
/**
|
|
1267
|
-
* Serializes the EntityList to a JSON object
|
|
1268
|
-
*
|
|
1269
|
-
* @returns
|
|
1270
|
-
*/
|
|
1271
|
-
toJSON() {
|
|
1272
|
-
return {
|
|
1273
|
-
...super.toJSON(),
|
|
1274
|
-
items: this._items.map((i) => i.toJSON()),
|
|
1275
|
-
pagination: this._pagination
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
|
|
1280
|
-
// src/components/A-Router/A-Router.component.types.ts
|
|
1281
|
-
var A_SERVER_TYPES__RouterMethod = /* @__PURE__ */ ((A_SERVER_TYPES__RouterMethod2) => {
|
|
1282
|
-
A_SERVER_TYPES__RouterMethod2["POST"] = "POST";
|
|
1283
|
-
A_SERVER_TYPES__RouterMethod2["GET"] = "GET";
|
|
1284
|
-
A_SERVER_TYPES__RouterMethod2["PUT"] = "PUT";
|
|
1285
|
-
A_SERVER_TYPES__RouterMethod2["DELETE"] = "DELETE";
|
|
1286
|
-
A_SERVER_TYPES__RouterMethod2["PATCH"] = "PATCH";
|
|
1287
|
-
A_SERVER_TYPES__RouterMethod2["DEFAULT"] = "DEFAULT";
|
|
1288
|
-
return A_SERVER_TYPES__RouterMethod2;
|
|
1289
|
-
})(A_SERVER_TYPES__RouterMethod || {});
|
|
1290
|
-
var A_SERVER_TYPES__ARouterComponentMetaKey = /* @__PURE__ */ ((A_SERVER_TYPES__ARouterComponentMetaKey2) => {
|
|
1291
|
-
A_SERVER_TYPES__ARouterComponentMetaKey2["ROUTES"] = "ROUTES";
|
|
1292
|
-
return A_SERVER_TYPES__ARouterComponentMetaKey2;
|
|
1293
|
-
})(A_SERVER_TYPES__ARouterComponentMetaKey || {});
|
|
1294
|
-
var _A_Router = class _A_Router extends aConcept.A_Component {
|
|
1295
|
-
// =======================================================
|
|
1296
|
-
// ================ Method Definition=====================
|
|
1297
|
-
// =======================================================
|
|
1298
|
-
/**
|
|
1299
|
-
* Allows to define a custom route for POST requests
|
|
1300
|
-
*
|
|
1301
|
-
* @param path
|
|
1302
|
-
* @returns
|
|
1303
|
-
*/
|
|
1304
|
-
static Post(path) {
|
|
1305
|
-
return this.defineRoute({
|
|
1306
|
-
method: "POST" /* POST */,
|
|
1307
|
-
path: typeof path === "object" && "path" in path ? path.path : path,
|
|
1308
|
-
version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
|
|
1309
|
-
prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
/**
|
|
1313
|
-
* Allows to define a custom route for GET requests
|
|
1314
|
-
*
|
|
1315
|
-
* @param path
|
|
1316
|
-
* @returns
|
|
1317
|
-
*/
|
|
1318
|
-
static Get(path) {
|
|
1319
|
-
return this.defineRoute({
|
|
1320
|
-
method: "GET" /* GET */,
|
|
1321
|
-
path: typeof path === "object" && "path" in path ? path.path : path,
|
|
1322
|
-
version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
|
|
1323
|
-
prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
|
|
1324
|
-
});
|
|
1325
|
-
}
|
|
1326
|
-
/**
|
|
1327
|
-
* Allows to define a custom route for PUT requests
|
|
1328
|
-
*
|
|
1329
|
-
* @param path
|
|
1330
|
-
* @returns
|
|
1331
|
-
*/
|
|
1332
|
-
static Put(path) {
|
|
1333
|
-
return this.defineRoute({
|
|
1334
|
-
method: "PUT" /* PUT */,
|
|
1335
|
-
path: typeof path === "object" && "path" in path ? path.path : path,
|
|
1336
|
-
version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
|
|
1337
|
-
prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
|
|
1338
|
-
});
|
|
1339
|
-
}
|
|
1340
|
-
/**
|
|
1341
|
-
* Allows to define a custom route for DELETE requests
|
|
1342
|
-
*
|
|
1343
|
-
* @param path
|
|
1344
|
-
* @returns
|
|
1345
|
-
*/
|
|
1346
|
-
static Delete(path) {
|
|
1347
|
-
return this.defineRoute({
|
|
1348
|
-
method: "DELETE" /* DELETE */,
|
|
1349
|
-
path: typeof path === "object" && "path" in path ? path.path : path,
|
|
1350
|
-
version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
|
|
1351
|
-
prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
|
-
/**
|
|
1355
|
-
* Allows to define a custom route for PATCH requests
|
|
1356
|
-
*
|
|
1357
|
-
* @param path
|
|
1358
|
-
* @returns
|
|
1359
|
-
*/
|
|
1360
|
-
static Patch(path) {
|
|
1361
|
-
return this.defineRoute({
|
|
1362
|
-
method: "PATCH" /* PATCH */,
|
|
1363
|
-
path: typeof path === "object" && "path" in path ? path.path : path,
|
|
1364
|
-
version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
|
|
1365
|
-
prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
|
|
1366
|
-
});
|
|
1367
|
-
}
|
|
1368
|
-
/**
|
|
1369
|
-
* Allows to define a custom route for DEFAULT requests
|
|
1370
|
-
*
|
|
1371
|
-
* @param path
|
|
1372
|
-
* @returns
|
|
1373
|
-
*/
|
|
1374
|
-
static Default(path) {
|
|
1375
|
-
return this.defineRoute({
|
|
1376
|
-
method: "DEFAULT" /* DEFAULT */,
|
|
1377
|
-
path: typeof path === "object" && "path" in path ? path.path : path,
|
|
1378
|
-
version: typeof path === "object" && "version" in path && path.version ? path.version : "v1",
|
|
1379
|
-
prefix: typeof path === "object" && "prefix" in path && path.prefix ? path.prefix : "api"
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1382
|
-
/**
|
|
1383
|
-
* Private method to have the same signature for all route methods
|
|
1384
|
-
*
|
|
1385
|
-
* @param method
|
|
1386
|
-
* @param path
|
|
1387
|
-
* @returns
|
|
1388
|
-
*/
|
|
1389
|
-
static defineRoute(config) {
|
|
1390
|
-
const route = typeof config.path === "string" || config.path instanceof RegExp ? new A_Route(
|
|
1391
|
-
`/${config.prefix}/${config.version}${config.path instanceof RegExp ? config.path.source : config.path.startsWith("/") ? config.path : `/${config.path}`}`,
|
|
1392
|
-
config.method
|
|
1393
|
-
) : config.path;
|
|
1394
|
-
this.routes.push(route);
|
|
1395
|
-
return function decorator(target, propertyKey, descriptor) {
|
|
1396
|
-
const meta = aConcept.A_Context.meta(target);
|
|
1397
|
-
const routes = meta.get("ROUTES" /* ROUTES */) || /* @__PURE__ */ new Map();
|
|
1398
|
-
const searchKey = route.toAFeatureExtension(["A_Router", "A_Service"]);
|
|
1399
|
-
routes.set(searchKey.source, {
|
|
1400
|
-
component: target,
|
|
1401
|
-
handler: propertyKey,
|
|
1402
|
-
route
|
|
1403
|
-
});
|
|
1404
|
-
meta.set("ROUTES" /* ROUTES */, routes);
|
|
1405
|
-
aConcept.A_Feature_Define({
|
|
1406
|
-
name: searchKey.source,
|
|
1407
|
-
invoke: false
|
|
1408
|
-
})(target, propertyKey, descriptor);
|
|
1409
|
-
return aConcept.A_Feature_Extend(searchKey)(target, propertyKey, descriptor);
|
|
1410
|
-
};
|
|
1411
|
-
}
|
|
1412
|
-
async load(logger) {
|
|
1413
|
-
logger.routes(_A_Router.routes);
|
|
1414
|
-
}
|
|
1415
|
-
async identifyRoute(request, response, scope, config, logger) {
|
|
1416
|
-
const route = request.route;
|
|
1417
|
-
if (config.get("A_CONCEPT_ENVIRONMENT") === "development") {
|
|
1418
|
-
logger.log(`Incoming request: ${request.method} ${request.url}`);
|
|
1419
|
-
logger.log(`Identified route: ${route.toString()}`);
|
|
1420
|
-
}
|
|
1421
|
-
const feature = new aConcept.A_Feature({
|
|
1422
|
-
name: route.toString(),
|
|
1423
|
-
component: this
|
|
1424
|
-
});
|
|
1425
|
-
for (const stage of feature) {
|
|
1426
|
-
if (aConcept.A_TypeGuards.isComponentConstructor(stage.definition.component)) {
|
|
1427
|
-
const meta = aConcept.A_Context.meta(stage.definition.component);
|
|
1428
|
-
const routes = meta.get("ROUTES" /* ROUTES */);
|
|
1429
|
-
if (routes) {
|
|
1430
|
-
const currentRoute = routes.get(stage.definition.name || "");
|
|
1431
|
-
if (currentRoute) {
|
|
1432
|
-
request.params = {
|
|
1433
|
-
...request.params,
|
|
1434
|
-
...currentRoute.route.extractParams(request.url)
|
|
1435
|
-
};
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
const stageScope = new aConcept.A_Scope({
|
|
1440
|
-
name: `a-route--${aConcept.A_IdentityHelper.generateTimeId()}`,
|
|
1441
|
-
entities: [request]
|
|
1442
|
-
}, {
|
|
1443
|
-
parent: scope
|
|
1444
|
-
});
|
|
1445
|
-
await stage.process(stageScope);
|
|
1446
|
-
}
|
|
1447
|
-
console.log("Finished processing route for request:", request.method, request.url);
|
|
1448
|
-
}
|
|
1449
|
-
};
|
|
1450
|
-
_A_Router.routes = [];
|
|
1451
|
-
__decorateClass([
|
|
1452
|
-
aConcept.A_Concept.Load(),
|
|
1453
|
-
__decorateParam(0, aConcept.A_Inject(A_ServerLogger))
|
|
1454
|
-
], _A_Router.prototype, "load");
|
|
1455
|
-
__decorateClass([
|
|
1456
|
-
aConcept.A_Feature.Extend({
|
|
1457
|
-
name: "onRequest" /* onRequest */,
|
|
1458
|
-
scope: [A_Service]
|
|
1459
|
-
}),
|
|
1460
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1461
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
1462
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope)),
|
|
1463
|
-
__decorateParam(3, aConcept.A_Inject(aUtils.A_Config)),
|
|
1464
|
-
__decorateParam(4, aConcept.A_Inject(aUtils.A_Logger))
|
|
1465
|
-
], _A_Router.prototype, "identifyRoute");
|
|
1466
|
-
var A_Router = _A_Router;
|
|
1467
|
-
var A_EntityController = class extends aConcept.A_Component {
|
|
1468
|
-
async list(request, response, factory, scope, config) {
|
|
1469
|
-
const constructor = factory.resolveByName(request.params.type);
|
|
1470
|
-
if (constructor) {
|
|
1471
|
-
const entityList = new A_EntityList({
|
|
1472
|
-
name: request.params.type,
|
|
1473
|
-
scope: scope.name,
|
|
1474
|
-
constructor
|
|
1475
|
-
});
|
|
1476
|
-
scope.register(entityList);
|
|
1477
|
-
const queryFilter = new A_ListQueryFilter(request.query, {
|
|
1478
|
-
itemsPerPage: String(config.get("A_LIST_ITEMS_PER_PAGE") || "10"),
|
|
1479
|
-
page: String(config.get("A_LIST_PAGE") || "1")
|
|
1480
|
-
});
|
|
1481
|
-
const queryScope = new aConcept.A_Scope({
|
|
1482
|
-
fragments: [queryFilter]
|
|
1483
|
-
}).inherit(scope);
|
|
1484
|
-
await entityList.load(queryScope);
|
|
1485
|
-
response.add("items", entityList.items);
|
|
1486
|
-
response.add("pagination", entityList.pagination);
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
async load(request, response, scope) {
|
|
1490
|
-
if (!aConcept.ASEID.isASEID(request.params.aseid)) {
|
|
1491
|
-
response.add("A_EntityController.load", "Invalid ASEID");
|
|
1492
|
-
return;
|
|
1493
|
-
}
|
|
1494
|
-
const aseid = new aConcept.ASEID(request.params.aseid);
|
|
1495
|
-
const constructor = scope.resolveConstructor(aseid.entity);
|
|
1496
|
-
if (constructor) {
|
|
1497
|
-
const entity = new constructor(request.params.aseid);
|
|
1498
|
-
scope.register(entity);
|
|
1499
|
-
await entity.load();
|
|
1500
|
-
return response.status(200).json(entity.toJSON());
|
|
1501
|
-
} else
|
|
1502
|
-
throw new A_ServerError({
|
|
1503
|
-
title: "Entity Not Found",
|
|
1504
|
-
description: `Entity constructor for ASEID ${request.params.aseid} not found`,
|
|
1505
|
-
status: 404
|
|
1506
|
-
});
|
|
1507
|
-
}
|
|
1508
|
-
async create(request, factory, scope) {
|
|
1509
|
-
const constructor = factory.resolve(request.params.aseid);
|
|
1510
|
-
if (constructor) {
|
|
1511
|
-
const entity = new constructor(request.body);
|
|
1512
|
-
scope.register(entity);
|
|
1513
|
-
await entity.save();
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
async update(request, response, factory, scope) {
|
|
1517
|
-
if (!aConcept.ASEID.isASEID(request.params.aseid)) {
|
|
1518
|
-
response.add("A_EntityController.update", "Invalid ASEID");
|
|
1519
|
-
return;
|
|
1520
|
-
}
|
|
1521
|
-
const constructor = factory.resolve(request.params.aseid);
|
|
1522
|
-
if (constructor) {
|
|
1523
|
-
const entity = new constructor(request.body);
|
|
1524
|
-
scope.register(entity);
|
|
1525
|
-
await entity.save();
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
async delete(request, response, factory, scope) {
|
|
1529
|
-
if (!aConcept.ASEID.isASEID(request.params.aseid)) {
|
|
1530
|
-
response.add("A_EntityController.delete", "Invalid ASEID");
|
|
1531
|
-
return;
|
|
1532
|
-
}
|
|
1533
|
-
const constructor = factory.resolve(request.params.aseid);
|
|
1534
|
-
if (constructor) {
|
|
1535
|
-
const entity = new constructor(request.params.aseid);
|
|
1536
|
-
scope.register(entity);
|
|
1537
|
-
await entity.destroy();
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
async callEntity(request, response, factory, scope) {
|
|
1541
|
-
if (!aConcept.ASEID.isASEID(request.params.aseid)) {
|
|
1542
|
-
response.add("A_EntityController.callEntity", "Invalid ASEID");
|
|
1543
|
-
return;
|
|
1544
|
-
}
|
|
1545
|
-
const constructor = factory.resolve(request.params.aseid);
|
|
1546
|
-
if (!constructor) {
|
|
1547
|
-
response.add("A_EntityController.callEntity", "Entity not found");
|
|
1548
|
-
return;
|
|
1549
|
-
}
|
|
1550
|
-
const meta = aConcept.A_Context.meta(constructor);
|
|
1551
|
-
const targetFeature = meta.features().find((f) => f.name === `${constructor.name}.${request.params.action}`);
|
|
1552
|
-
if (!targetFeature) {
|
|
1553
|
-
response.add("A_EntityController.callEntity", "Feature not found");
|
|
1554
|
-
return;
|
|
1555
|
-
}
|
|
1556
|
-
const entity = new constructor(request.params.aseid);
|
|
1557
|
-
scope.register(entity);
|
|
1558
|
-
await entity.load(scope);
|
|
1559
|
-
await entity[targetFeature.handler](scope);
|
|
1560
|
-
response.add("result", scope.toJSON());
|
|
1561
|
-
response.add("entity", entity);
|
|
1562
|
-
response.add("type", entity.aseid.entity);
|
|
1563
|
-
}
|
|
1564
|
-
};
|
|
1565
|
-
__decorateClass([
|
|
1566
|
-
A_Router.Get({
|
|
1567
|
-
path: "/:type",
|
|
1568
|
-
version: "v1",
|
|
1569
|
-
prefix: "a-list"
|
|
1570
|
-
}),
|
|
1571
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1572
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
1573
|
-
__decorateParam(2, aConcept.A_Inject(A_EntityFactory)),
|
|
1574
|
-
__decorateParam(3, aConcept.A_Inject(aConcept.A_Scope)),
|
|
1575
|
-
__decorateParam(4, aConcept.A_Inject(aUtils.A_Config))
|
|
1576
|
-
], A_EntityController.prototype, "list");
|
|
1577
|
-
__decorateClass([
|
|
1578
|
-
aConcept.A_Feature.Define({
|
|
1579
|
-
name: "getEntity",
|
|
1580
|
-
invoke: false
|
|
1581
|
-
}),
|
|
1582
|
-
A_Router.Get({
|
|
1583
|
-
path: "/:aseid",
|
|
1584
|
-
version: "v1",
|
|
1585
|
-
prefix: "a-entity"
|
|
1586
|
-
}),
|
|
1587
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1588
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
1589
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope))
|
|
1590
|
-
], A_EntityController.prototype, "load");
|
|
1591
|
-
__decorateClass([
|
|
1592
|
-
A_Router.Post({
|
|
1593
|
-
path: "/",
|
|
1594
|
-
version: "v1",
|
|
1595
|
-
prefix: "a-entity"
|
|
1596
|
-
}),
|
|
1597
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1598
|
-
__decorateParam(1, aConcept.A_Inject(A_EntityFactory)),
|
|
1599
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope))
|
|
1600
|
-
], A_EntityController.prototype, "create");
|
|
1601
|
-
__decorateClass([
|
|
1602
|
-
A_Router.Put({
|
|
1603
|
-
path: "/:aseid",
|
|
1604
|
-
version: "v1",
|
|
1605
|
-
prefix: "a-entity"
|
|
1606
|
-
}),
|
|
1607
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1608
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
1609
|
-
__decorateParam(2, aConcept.A_Inject(A_EntityFactory)),
|
|
1610
|
-
__decorateParam(3, aConcept.A_Inject(aConcept.A_Scope))
|
|
1611
|
-
], A_EntityController.prototype, "update");
|
|
1612
|
-
__decorateClass([
|
|
1613
|
-
A_Router.Delete({
|
|
1614
|
-
path: "/:aseid",
|
|
1615
|
-
version: "v1",
|
|
1616
|
-
prefix: "a-entity"
|
|
1617
|
-
}),
|
|
1618
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1619
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
1620
|
-
__decorateParam(2, aConcept.A_Inject(A_EntityFactory)),
|
|
1621
|
-
__decorateParam(3, aConcept.A_Inject(aConcept.A_Scope))
|
|
1622
|
-
], A_EntityController.prototype, "delete");
|
|
1623
|
-
__decorateClass([
|
|
1624
|
-
A_Router.Post({
|
|
1625
|
-
path: "/:aseid/:action",
|
|
1626
|
-
version: "v1",
|
|
1627
|
-
prefix: "a-entity"
|
|
1628
|
-
}),
|
|
1629
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1630
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
1631
|
-
__decorateParam(2, aConcept.A_Inject(A_EntityFactory)),
|
|
1632
|
-
__decorateParam(3, aConcept.A_Inject(aConcept.A_Scope))
|
|
1633
|
-
], A_EntityController.prototype, "callEntity");
|
|
1634
|
-
var A_ServerHealthMonitor = class extends aConcept.A_Component {
|
|
1635
|
-
async get(config, request, response, logger) {
|
|
1636
|
-
logger.log("Health check requested", config.get("A_CONCEPT_ROOT_FOLDER"));
|
|
1637
|
-
const packageJSON = await import(`${config.get("A_CONCEPT_ROOT_FOLDER")}/package.json`);
|
|
1638
|
-
const exposedProperties = config.get("EXPOSED_PROPERTIES")?.split(",") || [
|
|
1639
|
-
"name",
|
|
1640
|
-
"version",
|
|
1641
|
-
"description"
|
|
1642
|
-
];
|
|
1643
|
-
exposedProperties.forEach((prop) => response.add(prop, packageJSON[prop]));
|
|
1644
|
-
console.log(`Health check accessed: ${request.method} ${request.url}`);
|
|
1645
|
-
}
|
|
1646
|
-
};
|
|
1647
|
-
__decorateClass([
|
|
1648
|
-
A_Router.Get({
|
|
1649
|
-
path: "/",
|
|
1650
|
-
prefix: "health",
|
|
1651
|
-
version: "v1"
|
|
1652
|
-
}),
|
|
1653
|
-
__decorateParam(0, aConcept.A_Inject(aUtils.A_Config)),
|
|
1654
|
-
__decorateParam(1, aConcept.A_Inject(A_Request)),
|
|
1655
|
-
__decorateParam(2, aConcept.A_Inject(A_Response)),
|
|
1656
|
-
__decorateParam(3, aConcept.A_Inject(aUtils.A_Logger))
|
|
1657
|
-
], A_ServerHealthMonitor.prototype, "get");
|
|
1658
|
-
var A_ServerProxy = class extends aConcept.A_Component {
|
|
1659
|
-
async load(logger, config) {
|
|
1660
|
-
logger.log(
|
|
1661
|
-
"pink",
|
|
1662
|
-
`Proxy routes configured:`,
|
|
1663
|
-
config.configs.map((c) => c.route).join("\n")
|
|
1664
|
-
);
|
|
1665
|
-
}
|
|
1666
|
-
async onRequest(req, res, proxyConfig, logger, polyfill) {
|
|
1667
|
-
return new Promise(async (resolve, reject) => {
|
|
1668
|
-
const { method, url } = req;
|
|
1669
|
-
const route = new A_Route(url, method);
|
|
1670
|
-
const config = proxyConfig.config(route.toString());
|
|
1671
|
-
if (!config) {
|
|
1672
|
-
return resolve();
|
|
1673
|
-
}
|
|
1674
|
-
logger.log(
|
|
1675
|
-
"yellow",
|
|
1676
|
-
`Proxying request ${method} ${url} to ${config.hostname}`,
|
|
1677
|
-
config
|
|
1678
|
-
);
|
|
1679
|
-
const client = await (config.protocol === "https:" ? polyfill.https() : polyfill.http());
|
|
1680
|
-
const proxyReq = client.request(
|
|
1681
|
-
{
|
|
1682
|
-
method: config.route.method,
|
|
1683
|
-
hostname: config.hostname,
|
|
1684
|
-
port: config.port,
|
|
1685
|
-
headers: config.headers,
|
|
1686
|
-
path: route.path
|
|
1687
|
-
},
|
|
1688
|
-
(proxyRes) => {
|
|
1689
|
-
if (!res.headersSent) {
|
|
1690
|
-
res.writeHead(proxyRes.statusCode || 200, proxyRes.headers);
|
|
1691
|
-
}
|
|
1692
|
-
proxyRes.on("end", () => {
|
|
1693
|
-
logger.log("green", `Proxy request to ${config?.hostname} completed`);
|
|
1694
|
-
resolve();
|
|
1695
|
-
});
|
|
1696
|
-
proxyRes.pipe(res.original);
|
|
1697
|
-
}
|
|
1698
|
-
);
|
|
1699
|
-
proxyReq.on("error", (err) => reject(err));
|
|
1700
|
-
req.pipe(proxyReq);
|
|
1701
|
-
});
|
|
1702
|
-
}
|
|
1703
|
-
};
|
|
1704
|
-
__decorateClass([
|
|
1705
|
-
aConcept.A_Concept.Load(),
|
|
1706
|
-
__decorateParam(0, aConcept.A_Inject(aUtils.A_Logger)),
|
|
1707
|
-
__decorateParam(1, aConcept.A_Inject(A_ProxyConfig))
|
|
1708
|
-
], A_ServerProxy.prototype, "load");
|
|
1709
|
-
__decorateClass([
|
|
1710
|
-
aConcept.A_Feature.Extend({
|
|
1711
|
-
name: "onRequest" /* onRequest */
|
|
1712
|
-
}),
|
|
1713
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1714
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
1715
|
-
__decorateParam(2, aConcept.A_Inject(A_ProxyConfig)),
|
|
1716
|
-
__decorateParam(3, aConcept.A_Inject(aUtils.A_Logger)),
|
|
1717
|
-
__decorateParam(4, aConcept.A_Inject(aUtils.A_Polyfill))
|
|
1718
|
-
], A_ServerProxy.prototype, "onRequest");
|
|
1719
|
-
|
|
1720
|
-
// src/components/A-ServerCORS/A_ServerCORS.component.defaults.ts
|
|
1721
|
-
var A_SERVER_DEFAULTS__CorsConfig = {
|
|
1722
|
-
origin: "*",
|
|
1723
|
-
// Default to allow all origins
|
|
1724
|
-
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
1725
|
-
headers: ["Content-Type"],
|
|
1726
|
-
credentials: false,
|
|
1727
|
-
maxAge: 0
|
|
1728
|
-
};
|
|
1729
|
-
var A_ServerCORS = class extends aConcept.A_Component {
|
|
1730
|
-
async init(config) {
|
|
1731
|
-
this.config = {
|
|
1732
|
-
origin: config.get("ORIGIN") || A_SERVER_DEFAULTS__CorsConfig.origin,
|
|
1733
|
-
methods: config.get("METHODS") || A_SERVER_DEFAULTS__CorsConfig.methods,
|
|
1734
|
-
headers: config.get("HEADERS") || A_SERVER_DEFAULTS__CorsConfig.headers,
|
|
1735
|
-
credentials: config.get("CREDENTIALS") || A_SERVER_DEFAULTS__CorsConfig.credentials,
|
|
1736
|
-
maxAge: config.get("MAX_AGE") || A_SERVER_DEFAULTS__CorsConfig.maxAge
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1739
|
-
apply(aReq, aRes) {
|
|
1740
|
-
aRes.setHeader("Access-Control-Allow-Origin", this.config.origin);
|
|
1741
|
-
aRes.setHeader("Access-Control-Allow-Methods", this.config.methods.join(", "));
|
|
1742
|
-
aRes.setHeader("Access-Control-Allow-Headers", this.config.headers.join(", "));
|
|
1743
|
-
if (this.config.credentials) {
|
|
1744
|
-
aRes.setHeader("Access-Control-Allow-Credentials", "true");
|
|
1745
|
-
}
|
|
1746
|
-
if (this.config.maxAge) {
|
|
1747
|
-
aRes.setHeader("Access-Control-Max-Age", this.config.maxAge.toString());
|
|
1748
|
-
}
|
|
1749
|
-
if (aReq.req.method === "OPTIONS") {
|
|
1750
|
-
aRes.status(204).send();
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
};
|
|
1754
|
-
__decorateClass([
|
|
1755
|
-
aConcept.A_Feature.Extend({
|
|
1756
|
-
name: "beforeStart" /* beforeStart */
|
|
1757
|
-
}),
|
|
1758
|
-
__decorateParam(0, aConcept.A_Inject(aUtils.A_Config))
|
|
1759
|
-
], A_ServerCORS.prototype, "init");
|
|
1760
|
-
__decorateClass([
|
|
1761
|
-
aConcept.A_Feature.Extend({
|
|
1762
|
-
name: "beforeRequest" /* beforeRequest */
|
|
1763
|
-
}),
|
|
1764
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1765
|
-
__decorateParam(1, aConcept.A_Inject(A_Response))
|
|
1766
|
-
], A_ServerCORS.prototype, "apply");
|
|
1767
|
-
var A_StaticLoader = class extends aConcept.A_Component {
|
|
1768
|
-
async load(logger, config, polyfill) {
|
|
1769
|
-
this._fsPolyfill = await polyfill.fs();
|
|
1770
|
-
this._pathPolyfill = await polyfill.path();
|
|
1771
|
-
const aliases = config.getEnabledAliases();
|
|
1772
|
-
logger.log(
|
|
1773
|
-
"pink",
|
|
1774
|
-
`Static aliases configured:`,
|
|
1775
|
-
aliases.map((alias) => `${alias.alias} -> ${alias.directory}`).join("\n")
|
|
1776
|
-
);
|
|
1777
|
-
}
|
|
1778
|
-
async onRequest(req, res, logger, config, polyfill) {
|
|
1779
|
-
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
1780
|
-
return;
|
|
1781
|
-
}
|
|
1782
|
-
const { method, url } = req;
|
|
1783
|
-
const route = new A_Route(url, method);
|
|
1784
|
-
const alias = config.findMatchingAlias(route.path);
|
|
1785
|
-
if (!alias) {
|
|
1786
|
-
return;
|
|
1787
|
-
}
|
|
1788
|
-
try {
|
|
1789
|
-
const fs = this._fsPolyfill || await polyfill.fs();
|
|
1790
|
-
const path = this._pathPolyfill || await polyfill.path();
|
|
1791
|
-
const staticDir = path.resolve(process.cwd(), alias.directory);
|
|
1792
|
-
if (!fs.existsSync(staticDir)) {
|
|
1793
|
-
logger.log("red", `Static directory ${staticDir} does not exist.`);
|
|
1794
|
-
return;
|
|
1795
|
-
}
|
|
1796
|
-
const relativePath = route.path.replace(alias.path, "");
|
|
1797
|
-
const safePath = this.safeFilePath(staticDir, relativePath, req.headers?.host, path, fs);
|
|
1798
|
-
await this.serveFile(safePath, res, logger, fs, path);
|
|
1799
|
-
} catch (error) {
|
|
1800
|
-
logger.error(`Static file serving error: ${error.message}`);
|
|
1801
|
-
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
1802
|
-
res.send("File not found");
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
/**
|
|
1806
|
-
* Add a custom static file alias through the config
|
|
1807
|
-
* @param alias - The URL path alias (e.g., '/assets')
|
|
1808
|
-
* @param directory - The local directory path
|
|
1809
|
-
* @param path - Optional custom path (defaults to alias)
|
|
1810
|
-
* @param config - Static config instance
|
|
1811
|
-
* @param logger - Logger instance for logging
|
|
1812
|
-
*/
|
|
1813
|
-
addAlias(alias, directory, config, logger, path) {
|
|
1814
|
-
config.addAlias(alias, directory, path);
|
|
1815
|
-
if (logger) {
|
|
1816
|
-
logger.log("cyan", `Static alias added: ${alias} -> ${directory}`);
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
/**
|
|
1820
|
-
* Remove a static file alias through the config
|
|
1821
|
-
* @param aliasPath - The path of the alias to remove
|
|
1822
|
-
* @param config - Static config instance
|
|
1823
|
-
* @param logger - Logger instance for logging
|
|
1824
|
-
*/
|
|
1825
|
-
removeAlias(aliasPath, config, logger) {
|
|
1826
|
-
const removed = config.removeAlias(aliasPath);
|
|
1827
|
-
if (removed && logger) {
|
|
1828
|
-
logger.log("yellow", `Static alias removed: ${aliasPath}`);
|
|
1829
|
-
}
|
|
1830
|
-
return removed;
|
|
1831
|
-
}
|
|
1832
|
-
/**
|
|
1833
|
-
* Get all configured aliases from config
|
|
1834
|
-
* @param config - Static config instance
|
|
1835
|
-
*/
|
|
1836
|
-
getAliases(config) {
|
|
1837
|
-
return config.getAliases();
|
|
1838
|
-
}
|
|
1839
|
-
/**
|
|
1840
|
-
* Enable or disable an alias
|
|
1841
|
-
* @param aliasPath - The path of the alias
|
|
1842
|
-
* @param enabled - Whether to enable or disable
|
|
1843
|
-
* @param config - Static config instance
|
|
1844
|
-
* @param logger - Logger instance for logging
|
|
1845
|
-
*/
|
|
1846
|
-
setAliasEnabled(aliasPath, enabled, config, logger) {
|
|
1847
|
-
const result = config.setAliasEnabled(aliasPath, enabled);
|
|
1848
|
-
if (result && logger) {
|
|
1849
|
-
logger.log("blue", `Static alias ${enabled ? "enabled" : "disabled"}: ${aliasPath}`);
|
|
1850
|
-
}
|
|
1851
|
-
return result;
|
|
1852
|
-
}
|
|
1853
|
-
getMimeType(ext) {
|
|
1854
|
-
const mimeTypes = {
|
|
1855
|
-
// Text
|
|
1856
|
-
".html": "text/html",
|
|
1857
|
-
".htm": "text/html",
|
|
1858
|
-
".css": "text/css",
|
|
1859
|
-
".txt": "text/plain",
|
|
1860
|
-
".md": "text/markdown",
|
|
1861
|
-
".xml": "application/xml",
|
|
1862
|
-
// JavaScript
|
|
1863
|
-
".js": "application/javascript",
|
|
1864
|
-
".mjs": "application/javascript",
|
|
1865
|
-
".jsx": "application/javascript",
|
|
1866
|
-
".ts": "application/typescript",
|
|
1867
|
-
".tsx": "application/typescript",
|
|
1868
|
-
// JSON
|
|
1869
|
-
".json": "application/json",
|
|
1870
|
-
".jsonld": "application/ld+json",
|
|
1871
|
-
// Images
|
|
1872
|
-
".png": "image/png",
|
|
1873
|
-
".jpg": "image/jpeg",
|
|
1874
|
-
".jpeg": "image/jpeg",
|
|
1875
|
-
".gif": "image/gif",
|
|
1876
|
-
".svg": "image/svg+xml",
|
|
1877
|
-
".ico": "image/x-icon",
|
|
1878
|
-
".webp": "image/webp",
|
|
1879
|
-
".bmp": "image/bmp",
|
|
1880
|
-
".tiff": "image/tiff",
|
|
1881
|
-
// Fonts
|
|
1882
|
-
".woff": "font/woff",
|
|
1883
|
-
".woff2": "font/woff2",
|
|
1884
|
-
".ttf": "font/ttf",
|
|
1885
|
-
".otf": "font/otf",
|
|
1886
|
-
".eot": "application/vnd.ms-fontobject",
|
|
1887
|
-
// Audio/Video
|
|
1888
|
-
".mp3": "audio/mpeg",
|
|
1889
|
-
".wav": "audio/wav",
|
|
1890
|
-
".mp4": "video/mp4",
|
|
1891
|
-
".webm": "video/webm",
|
|
1892
|
-
".ogg": "application/ogg",
|
|
1893
|
-
// Archives
|
|
1894
|
-
".zip": "application/zip",
|
|
1895
|
-
".tar": "application/x-tar",
|
|
1896
|
-
".gz": "application/gzip",
|
|
1897
|
-
// Documents
|
|
1898
|
-
".pdf": "application/pdf",
|
|
1899
|
-
".doc": "application/msword",
|
|
1900
|
-
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
1901
|
-
".xls": "application/vnd.ms-excel",
|
|
1902
|
-
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
1903
|
-
};
|
|
1904
|
-
return mimeTypes[ext.toLowerCase()] || "application/octet-stream";
|
|
1905
|
-
}
|
|
1906
|
-
safeFilePath(staticDir, reqUrl, host = "localhost", pathPolyfill, fsPolyfill) {
|
|
1907
|
-
const parsedUrl = new URL(reqUrl || "/", `http://${host}`);
|
|
1908
|
-
let pathname = decodeURIComponent(parsedUrl.pathname);
|
|
1909
|
-
pathname = pathname.replace(/\.\.[\/\\]/g, "");
|
|
1910
|
-
let filePath = pathPolyfill.join(staticDir, pathname);
|
|
1911
|
-
if (!fsPolyfill.existsSync(filePath)) {
|
|
1912
|
-
throw new Error(`File not found: ${filePath}`);
|
|
1913
|
-
}
|
|
1914
|
-
return filePath;
|
|
1915
|
-
}
|
|
1916
|
-
serveFile(filePath, res, logger, fsPolyfill, pathPolyfill) {
|
|
1917
|
-
return new Promise((resolve, reject) => {
|
|
1918
|
-
try {
|
|
1919
|
-
if (fsPolyfill.existsSync(filePath)) {
|
|
1920
|
-
const ext = pathPolyfill.extname(filePath);
|
|
1921
|
-
const contentType = this.getMimeType(ext);
|
|
1922
|
-
const headers = {
|
|
1923
|
-
"Content-Type": contentType,
|
|
1924
|
-
"Cache-Control": this.getCacheControl(ext),
|
|
1925
|
-
"X-Content-Type-Options": "nosniff"
|
|
1926
|
-
};
|
|
1927
|
-
res.writeHead(200, headers);
|
|
1928
|
-
const stream = fsPolyfill.createReadStream(filePath);
|
|
1929
|
-
if (stream && res.original) {
|
|
1930
|
-
stream.pipe(res.original);
|
|
1931
|
-
stream.on("end", () => {
|
|
1932
|
-
logger.log("green", `Successfully served: ${filePath}`);
|
|
1933
|
-
resolve();
|
|
1934
|
-
});
|
|
1935
|
-
stream.on("error", (err) => {
|
|
1936
|
-
logger.error(`File stream error: ${err.message}`);
|
|
1937
|
-
reject(new Error(`File stream error: ${err.message}`));
|
|
1938
|
-
});
|
|
1939
|
-
} else {
|
|
1940
|
-
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
1941
|
-
res.send("Internal server error");
|
|
1942
|
-
reject(new Error("Failed to create file stream"));
|
|
1943
|
-
}
|
|
1944
|
-
} else {
|
|
1945
|
-
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
1946
|
-
res.send("File not found");
|
|
1947
|
-
reject(new Error(`File not found: ${filePath}`));
|
|
1948
|
-
}
|
|
1949
|
-
} catch (error) {
|
|
1950
|
-
logger.error(`Error serving file: ${error.message}`);
|
|
1951
|
-
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
1952
|
-
res.send("Internal server error");
|
|
1953
|
-
reject(error);
|
|
1954
|
-
}
|
|
1955
|
-
});
|
|
1956
|
-
}
|
|
1957
|
-
getCacheControl(ext) {
|
|
1958
|
-
const staticAssets = [".css", ".js", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".woff", ".woff2", ".ttf", ".otf"];
|
|
1959
|
-
const dynamicContent = [".html", ".htm"];
|
|
1960
|
-
if (staticAssets.includes(ext.toLowerCase())) {
|
|
1961
|
-
return "public, max-age=31536000";
|
|
1962
|
-
} else if (dynamicContent.includes(ext.toLowerCase())) {
|
|
1963
|
-
return "public, max-age=3600";
|
|
1964
|
-
} else {
|
|
1965
|
-
return "public, max-age=86400";
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
};
|
|
1969
|
-
__decorateClass([
|
|
1970
|
-
aConcept.A_Concept.Load(),
|
|
1971
|
-
__decorateParam(0, aConcept.A_Inject(aUtils.A_Logger)),
|
|
1972
|
-
__decorateParam(1, aConcept.A_Inject(A_StaticConfig)),
|
|
1973
|
-
__decorateParam(2, aConcept.A_Inject(aUtils.A_Polyfill))
|
|
1974
|
-
], A_StaticLoader.prototype, "load");
|
|
1975
|
-
__decorateClass([
|
|
1976
|
-
aConcept.A_Feature.Extend({
|
|
1977
|
-
name: "onRequest" /* onRequest */
|
|
1978
|
-
}),
|
|
1979
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
1980
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
1981
|
-
__decorateParam(2, aConcept.A_Inject(aUtils.A_Logger)),
|
|
1982
|
-
__decorateParam(3, aConcept.A_Inject(A_StaticConfig)),
|
|
1983
|
-
__decorateParam(4, aConcept.A_Inject(aUtils.A_Polyfill))
|
|
1984
|
-
], A_StaticLoader.prototype, "onRequest");
|
|
1985
|
-
var A_Controller = class extends aConcept.A_Component {
|
|
1986
|
-
async callEntityMethod(request, response, scope) {
|
|
1987
|
-
if (!scope.has(request.params.component))
|
|
1988
|
-
return;
|
|
1989
|
-
if (!request.params.operation || typeof request.params.operation !== "string")
|
|
1990
|
-
return;
|
|
1991
|
-
const possibleComponent = scope.resolve(request.params.component);
|
|
1992
|
-
if (!possibleComponent || ![aConcept.A_Component, aConcept.A_Container].some((c) => possibleComponent instanceof c))
|
|
1993
|
-
return;
|
|
1994
|
-
const component = possibleComponent;
|
|
1995
|
-
const meta = aConcept.A_Context.meta(component);
|
|
1996
|
-
const targetFeature = meta.features().find((f) => f.name === `${component.constructor.name}.${request.params.operation}`);
|
|
1997
|
-
if (!targetFeature)
|
|
1998
|
-
return;
|
|
1999
|
-
await component.call(request.params.operation, scope);
|
|
2000
|
-
}
|
|
2001
|
-
};
|
|
2002
|
-
__decorateClass([
|
|
2003
|
-
A_Router.Post({
|
|
2004
|
-
path: "/:component/:operation",
|
|
2005
|
-
version: "v1",
|
|
2006
|
-
prefix: "a-component"
|
|
2007
|
-
}),
|
|
2008
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
2009
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
2010
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope))
|
|
2011
|
-
], A_Controller.prototype, "callEntityMethod");
|
|
2012
|
-
var A_ListingController = class extends aConcept.A_Component {
|
|
2013
|
-
async list(request, response, factory, scope, config) {
|
|
2014
|
-
const constructor = factory.resolveByName(request.params.type);
|
|
2015
|
-
if (constructor) {
|
|
2016
|
-
const entityList = new A_EntityList({
|
|
2017
|
-
name: request.params.type,
|
|
2018
|
-
scope: scope.name,
|
|
2019
|
-
constructor
|
|
2020
|
-
});
|
|
2021
|
-
scope.register(entityList);
|
|
2022
|
-
const queryFilter = new A_ListQueryFilter(request.query, {
|
|
2023
|
-
itemsPerPage: String(config.get("A_LIST_ITEMS_PER_PAGE") || "10"),
|
|
2024
|
-
page: String(config.get("A_LIST_PAGE") || "1")
|
|
2025
|
-
});
|
|
2026
|
-
const queryScope = new aConcept.A_Scope({
|
|
2027
|
-
fragments: [queryFilter]
|
|
2028
|
-
}).inherit(scope);
|
|
2029
|
-
await entityList.load(queryScope);
|
|
2030
|
-
response.add("items", entityList.items);
|
|
2031
|
-
response.add("pagination", entityList.pagination);
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
};
|
|
2035
|
-
__decorateClass([
|
|
2036
|
-
A_Router.Get({
|
|
2037
|
-
path: "/:type",
|
|
2038
|
-
version: "v1",
|
|
2039
|
-
prefix: "a-list"
|
|
2040
|
-
}),
|
|
2041
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
2042
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
2043
|
-
__decorateParam(2, aConcept.A_Inject(A_EntityFactory)),
|
|
2044
|
-
__decorateParam(3, aConcept.A_Inject(aConcept.A_Scope)),
|
|
2045
|
-
__decorateParam(4, aConcept.A_Inject(aUtils.A_Config))
|
|
2046
|
-
], A_ListingController.prototype, "list");
|
|
2047
|
-
var A_CommandController = class extends aConcept.A_Component {
|
|
2048
|
-
async handleCommand(req, res, scope, container) {
|
|
2049
|
-
const commandName = req.params.command;
|
|
2050
|
-
const CommandConstructor = scope.resolveConstructor(commandName);
|
|
2051
|
-
if (!CommandConstructor) {
|
|
2052
|
-
res.status(404);
|
|
2053
|
-
throw new Error(`Command ${commandName} not found`);
|
|
2054
|
-
}
|
|
2055
|
-
const command = new CommandConstructor(req.body);
|
|
2056
|
-
container.scope.register(command);
|
|
2057
|
-
await command.execute();
|
|
2058
|
-
const serialized = command.toJSON();
|
|
2059
|
-
return res.status(200).json(serialized);
|
|
2060
|
-
}
|
|
2061
|
-
};
|
|
2062
|
-
__decorateClass([
|
|
2063
|
-
A_Router.Get({
|
|
2064
|
-
path: "/:command/execute",
|
|
2065
|
-
version: "v1",
|
|
2066
|
-
prefix: "a-command"
|
|
2067
|
-
}),
|
|
2068
|
-
__decorateParam(0, aConcept.A_Inject(A_Request)),
|
|
2069
|
-
__decorateParam(1, aConcept.A_Inject(A_Response)),
|
|
2070
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope)),
|
|
2071
|
-
__decorateParam(3, aConcept.A_Inject(aConcept.A_Container))
|
|
2072
|
-
], A_CommandController.prototype, "handleCommand");
|
|
2073
|
-
var A_EntityRepository = class extends aConcept.A_Component {
|
|
2074
|
-
async list(channel, entity, scope) {
|
|
2075
|
-
if (scope.has(aUtils.A_Manifest) && !scope.resolve(aUtils.A_Manifest).isAllowed(entity.constructor, "load").for(entity.constructor))
|
|
2076
|
-
return;
|
|
2077
|
-
const response = await channel.get(`/a-list/${entity.aseid.entity}`);
|
|
2078
|
-
entity.fromJSON(response.data);
|
|
2079
|
-
}
|
|
2080
|
-
async load(channel, entity, scope) {
|
|
2081
|
-
if (scope.has(aUtils.A_Manifest) && !scope.resolve(aUtils.A_Manifest).isAllowed(entity.constructor, "load").for(entity.constructor))
|
|
2082
|
-
return;
|
|
2083
|
-
const response = await channel.get(`/a-entity/${entity.aseid.toString()}`);
|
|
2084
|
-
entity.fromJSON(response.data);
|
|
2085
|
-
}
|
|
2086
|
-
async save(channel, entity, scope) {
|
|
2087
|
-
if (scope.has(aUtils.A_Manifest) && !scope.resolve(aUtils.A_Manifest).isAllowed(entity.constructor, "save").for(entity.constructor))
|
|
2088
|
-
return;
|
|
2089
|
-
const response = await channel.post(`/a-entity/${entity.aseid.toString()}`, entity.toJSON());
|
|
2090
|
-
entity.fromJSON(response.data);
|
|
2091
|
-
}
|
|
2092
|
-
async destroy(channel, entity, scope) {
|
|
2093
|
-
if (scope.has(aUtils.A_Manifest) && !scope.resolve(aUtils.A_Manifest).isAllowed(entity.constructor, "destroy").for(entity.constructor))
|
|
2094
|
-
return;
|
|
2095
|
-
const response = await channel.delete(`/a-entity/${entity.aseid.toString()}`);
|
|
2096
|
-
entity.fromJSON(response.data);
|
|
2097
|
-
}
|
|
2098
|
-
};
|
|
2099
|
-
__decorateClass([
|
|
2100
|
-
aConcept.A_Feature.Extend({
|
|
2101
|
-
name: AEntity_constants.A_TYPES__EntityFeatures.LOAD,
|
|
2102
|
-
scope: {
|
|
2103
|
-
include: [A_EntityList]
|
|
2104
|
-
}
|
|
2105
|
-
}),
|
|
2106
|
-
__decorateParam(0, aConcept.A_Inject(A_HTTPChannel)),
|
|
2107
|
-
__decorateParam(1, aConcept.A_Inject(aConcept.A_Caller)),
|
|
2108
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope))
|
|
2109
|
-
], A_EntityRepository.prototype, "list");
|
|
2110
|
-
__decorateClass([
|
|
2111
|
-
aConcept.A_Feature.Extend({
|
|
2112
|
-
name: AEntity_constants.A_TYPES__EntityFeatures.LOAD,
|
|
2113
|
-
scope: {
|
|
2114
|
-
exclude: [A_EntityList]
|
|
2115
|
-
}
|
|
2116
|
-
}),
|
|
2117
|
-
__decorateParam(0, aConcept.A_Inject(A_HTTPChannel)),
|
|
2118
|
-
__decorateParam(1, aConcept.A_Inject(aConcept.A_Caller)),
|
|
2119
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope))
|
|
2120
|
-
], A_EntityRepository.prototype, "load");
|
|
2121
|
-
__decorateClass([
|
|
2122
|
-
aConcept.A_Feature.Extend({
|
|
2123
|
-
name: AEntity_constants.A_TYPES__EntityFeatures.SAVE,
|
|
2124
|
-
scope: {
|
|
2125
|
-
exclude: [A_EntityList]
|
|
2126
|
-
}
|
|
2127
|
-
}),
|
|
2128
|
-
__decorateParam(0, aConcept.A_Inject(A_HTTPChannel)),
|
|
2129
|
-
__decorateParam(1, aConcept.A_Inject(aConcept.A_Caller)),
|
|
2130
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope))
|
|
2131
|
-
], A_EntityRepository.prototype, "save");
|
|
2132
|
-
__decorateClass([
|
|
2133
|
-
aConcept.A_Feature.Extend({
|
|
2134
|
-
name: AEntity_constants.A_TYPES__EntityFeatures.DESTROY,
|
|
2135
|
-
scope: {
|
|
2136
|
-
exclude: [A_EntityList]
|
|
2137
|
-
}
|
|
2138
|
-
}),
|
|
2139
|
-
__decorateParam(0, aConcept.A_Inject(A_HTTPChannel)),
|
|
2140
|
-
__decorateParam(1, aConcept.A_Inject(aConcept.A_Caller)),
|
|
2141
|
-
__decorateParam(2, aConcept.A_Inject(aConcept.A_Scope))
|
|
2142
|
-
], A_EntityRepository.prototype, "destroy");
|
|
2143
|
-
|
|
2144
|
-
exports.A_CommandController = A_CommandController;
|
|
2145
|
-
exports.A_Controller = A_Controller;
|
|
2146
|
-
exports.A_EntityController = A_EntityController;
|
|
2147
|
-
exports.A_EntityFactory = A_EntityFactory;
|
|
2148
|
-
exports.A_EntityList = A_EntityList;
|
|
2149
|
-
exports.A_EntityRepository = A_EntityRepository;
|
|
2150
|
-
exports.A_HTTPChannel = A_HTTPChannel;
|
|
2151
|
-
exports.A_HTTPChannelError = A_HTTPChannelError;
|
|
2152
|
-
exports.A_HTTPChannel_RequestContext = A_HTTPChannel_RequestContext;
|
|
2153
|
-
exports.A_ListQueryFilter = A_ListQueryFilter;
|
|
2154
|
-
exports.A_ListingController = A_ListingController;
|
|
2155
|
-
exports.A_ProxyConfig = A_ProxyConfig;
|
|
2156
|
-
exports.A_Request = A_Request;
|
|
2157
|
-
exports.A_Response = A_Response;
|
|
2158
|
-
exports.A_Route = A_Route;
|
|
2159
|
-
exports.A_Router = A_Router;
|
|
2160
|
-
exports.A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle = A_SERVER_CONSTANTS__A_HttpChannel_Lifecycle;
|
|
2161
|
-
exports.A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES = A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES;
|
|
2162
|
-
exports.A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY = A_SERVER_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY;
|
|
2163
|
-
exports.A_SERVER_TYPES__ARouterComponentMetaKey = A_SERVER_TYPES__ARouterComponentMetaKey;
|
|
2164
|
-
exports.A_SERVER_TYPES__RequestEvent = A_SERVER_TYPES__RequestEvent;
|
|
2165
|
-
exports.A_SERVER_TYPES__ResponseEvent = A_SERVER_TYPES__ResponseEvent;
|
|
2166
|
-
exports.A_SERVER_TYPES__RouterMethod = A_SERVER_TYPES__RouterMethod;
|
|
2167
|
-
exports.A_SERVER_TYPES__ServerFeature = A_SERVER_TYPES__ServerFeature;
|
|
2168
|
-
exports.A_SERVER_TYPES__ServerMethod = A_SERVER_TYPES__ServerMethod;
|
|
2169
|
-
exports.A_Server = A_Server;
|
|
2170
|
-
exports.A_ServerCORS = A_ServerCORS;
|
|
2171
|
-
exports.A_ServerError = A_ServerError;
|
|
2172
|
-
exports.A_ServerHealthMonitor = A_ServerHealthMonitor;
|
|
2173
|
-
exports.A_ServerLogger = A_ServerLogger;
|
|
2174
|
-
exports.A_ServerProxy = A_ServerProxy;
|
|
2175
|
-
exports.A_Service = A_Service;
|
|
2176
|
-
exports.A_StaticConfig = A_StaticConfig;
|
|
2177
|
-
exports.A_StaticLoader = A_StaticLoader;
|
|
2178
|
-
//# sourceMappingURL=index.js.map
|
|
2179
|
-
//# sourceMappingURL=index.js.map
|