@adaas/a-server 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.conf/tsconfig.base.json +79 -0
- package/.conf/tsconfig.browser.json +32 -0
- package/.conf/tsconfig.node.json +33 -0
- package/LICENSE +10 -19
- package/dist/browser/index.d.mts +1669 -0
- package/dist/browser/index.mjs +2869 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/node/A-Request.entity-8_9MCXT2.d.ts +533 -0
- package/dist/node/A-Request.entity-r905O60G.d.mts +533 -0
- package/dist/node/A-Response.entity-BVYAc6-8.d.mts +318 -0
- package/dist/node/A-Response.entity-CRc-t-vr.d.ts +318 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.d.mts +9 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.d.ts +9 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.js +13 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.js.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.mjs +12 -0
- package/dist/node/channels/A-Http/A-Http.channel.constants.mjs.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.d.mts +23 -0
- package/dist/node/channels/A-Http/A-Http.channel.d.ts +23 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.d.mts +7 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.d.ts +7 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.js +11 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.js.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.mjs +10 -0
- package/dist/node/channels/A-Http/A-Http.channel.error.mjs.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.js +122 -0
- package/dist/node/channels/A-Http/A-Http.channel.js.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.mjs +110 -0
- package/dist/node/channels/A-Http/A-Http.channel.mjs.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.d.mts +67 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.d.ts +67 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.js +4 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.js.map +1 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.mjs +3 -0
- package/dist/node/channels/A-Http/A-Http.channel.types.mjs.map +1 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.d.mts +7 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.d.ts +7 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.js +13 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.js.map +1 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.mjs +12 -0
- package/dist/node/channels/A-Websockets/A-Websockets.channel.mjs.map +1 -0
- package/dist/node/chunk-EQQGB2QZ.mjs +15 -0
- package/dist/node/chunk-EQQGB2QZ.mjs.map +1 -0
- package/dist/node/constants/env.constants.d.mts +12 -0
- package/dist/node/constants/env.constants.d.ts +12 -0
- package/dist/node/constants/env.constants.js +23 -0
- package/dist/node/constants/env.constants.js.map +1 -0
- package/dist/node/constants/env.constants.mjs +22 -0
- package/dist/node/constants/env.constants.mjs.map +1 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.d.mts +29 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.d.ts +29 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.js +55 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.js.map +1 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.mjs +43 -0
- package/dist/node/controllers/A-CommandController/A-CommandController.component.mjs.map +1 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.d.mts +44 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.d.ts +44 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.js +189 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.js.map +1 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.mjs +177 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.mjs.map +1 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.d.mts +2 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.d.ts +2 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.js +4 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.js.map +1 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.mjs +3 -0
- package/dist/node/controllers/A-EntityController/A-EntityController.component.types.mjs.map +1 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.d.mts +28 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.d.ts +28 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.js +59 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.js.map +1 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.mjs +47 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.component.mjs.map +1 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.d.mts +2 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.d.ts +2 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.js +4 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.js.map +1 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.mjs +3 -0
- package/dist/node/controllers/A-ListingController/A-ListingController.types.mjs.map +1 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.mts +30 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.d.ts +30 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js +46 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.js.map +1 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.mjs +34 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.component.mjs.map +1 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.d.mts +2 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.d.ts +2 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.js +4 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.js.map +1 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.mjs +3 -0
- package/dist/node/controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.mjs.map +1 -0
- package/dist/node/index.d.mts +51 -0
- package/dist/node/index.d.ts +51 -0
- package/dist/node/index.js +320 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/index.mjs +48 -0
- package/dist/node/index.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.d.mts +12 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.d.ts +12 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.js +25 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.js.map +1 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.mjs +24 -0
- package/dist/node/lib/A-Request/A-HttpRequestData.context.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.d.mts +39 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.d.ts +39 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.js +56 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.js.map +1 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.mjs +55 -0
- package/dist/node/lib/A-Request/A-HttpServerRequest.context.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.constants.d.mts +18 -0
- package/dist/node/lib/A-Request/A-Request.constants.d.ts +18 -0
- package/dist/node/lib/A-Request/A-Request.constants.js +22 -0
- package/dist/node/lib/A-Request/A-Request.constants.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.constants.mjs +22 -0
- package/dist/node/lib/A-Request/A-Request.constants.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.entity.d.mts +17 -0
- package/dist/node/lib/A-Request/A-Request.entity.d.ts +17 -0
- package/dist/node/lib/A-Request/A-Request.entity.js +651 -0
- package/dist/node/lib/A-Request/A-Request.entity.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.entity.mjs +639 -0
- package/dist/node/lib/A-Request/A-Request.entity.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.env.d.mts +37 -0
- package/dist/node/lib/A-Request/A-Request.env.d.ts +37 -0
- package/dist/node/lib/A-Request/A-Request.env.js +39 -0
- package/dist/node/lib/A-Request/A-Request.env.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.env.mjs +38 -0
- package/dist/node/lib/A-Request/A-Request.env.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.error.d.mts +11 -0
- package/dist/node/lib/A-Request/A-Request.error.d.ts +11 -0
- package/dist/node/lib/A-Request/A-Request.error.js +15 -0
- package/dist/node/lib/A-Request/A-Request.error.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.error.mjs +14 -0
- package/dist/node/lib/A-Request/A-Request.error.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.helper.d.mts +105 -0
- package/dist/node/lib/A-Request/A-Request.helper.d.ts +105 -0
- package/dist/node/lib/A-Request/A-Request.helper.js +181 -0
- package/dist/node/lib/A-Request/A-Request.helper.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.helper.mjs +180 -0
- package/dist/node/lib/A-Request/A-Request.helper.mjs.map +1 -0
- package/dist/node/lib/A-Request/A-Request.types.d.mts +17 -0
- package/dist/node/lib/A-Request/A-Request.types.d.ts +17 -0
- package/dist/node/lib/A-Request/A-Request.types.js +14 -0
- package/dist/node/lib/A-Request/A-Request.types.js.map +1 -0
- package/dist/node/lib/A-Request/A-Request.types.mjs +14 -0
- package/dist/node/lib/A-Request/A-Request.types.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.constants.d.mts +24 -0
- package/dist/node/lib/A-Response/A-Response.constants.d.ts +24 -0
- package/dist/node/lib/A-Response/A-Response.constants.js +28 -0
- package/dist/node/lib/A-Response/A-Response.constants.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.constants.mjs +28 -0
- package/dist/node/lib/A-Response/A-Response.constants.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.entity.d.mts +20 -0
- package/dist/node/lib/A-Response/A-Response.entity.d.ts +20 -0
- package/dist/node/lib/A-Response/A-Response.entity.js +544 -0
- package/dist/node/lib/A-Response/A-Response.entity.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.entity.mjs +532 -0
- package/dist/node/lib/A-Response/A-Response.entity.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.env.d.mts +2 -0
- package/dist/node/lib/A-Response/A-Response.env.d.ts +2 -0
- package/dist/node/lib/A-Response/A-Response.env.js +4 -0
- package/dist/node/lib/A-Response/A-Response.env.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.env.mjs +3 -0
- package/dist/node/lib/A-Response/A-Response.env.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.error.d.mts +6 -0
- package/dist/node/lib/A-Response/A-Response.error.d.ts +6 -0
- package/dist/node/lib/A-Response/A-Response.error.js +10 -0
- package/dist/node/lib/A-Response/A-Response.error.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.error.mjs +9 -0
- package/dist/node/lib/A-Response/A-Response.error.mjs.map +1 -0
- package/dist/node/lib/A-Response/A-Response.types.d.mts +20 -0
- package/dist/node/lib/A-Response/A-Response.types.d.ts +20 -0
- package/dist/node/lib/A-Response/A-Response.types.js +4 -0
- package/dist/node/lib/A-Response/A-Response.types.js.map +1 -0
- package/dist/node/lib/A-Response/A-Response.types.mjs +3 -0
- package/dist/node/lib/A-Response/A-Response.types.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.d.mts +7 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.d.ts +7 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.js +11 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.mjs +11 -0
- package/dist/node/lib/A-Server/A-HttpServer.constants.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.d.mts +50 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.d.ts +50 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.js +194 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.mjs +182 -0
- package/dist/node/lib/A-Server/A-HttpServer.container.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.d.mts +54 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.d.ts +54 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.js +118 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.mjs +117 -0
- package/dist/node/lib/A-Server/A-HttpServer.error.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.d.mts +19 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.d.ts +19 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.js +4 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.js.map +1 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.mjs +3 -0
- package/dist/node/lib/A-Server/A-HttpServer.types.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-Server.context.d.mts +22 -0
- package/dist/node/lib/A-Server/A-Server.context.d.ts +22 -0
- package/dist/node/lib/A-Server/A-Server.context.js +24 -0
- package/dist/node/lib/A-Server/A-Server.context.js.map +1 -0
- package/dist/node/lib/A-Server/A-Server.context.mjs +23 -0
- package/dist/node/lib/A-Server/A-Server.context.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-Server.error.d.mts +14 -0
- package/dist/node/lib/A-Server/A-Server.error.d.ts +14 -0
- package/dist/node/lib/A-Server/A-Server.error.js +26 -0
- package/dist/node/lib/A-Server/A-Server.error.js.map +1 -0
- package/dist/node/lib/A-Server/A-Server.error.mjs +25 -0
- package/dist/node/lib/A-Server/A-Server.error.mjs.map +1 -0
- package/dist/node/lib/A-Server/A-Server.types.d.mts +26 -0
- package/dist/node/lib/A-Server/A-Server.types.d.ts +26 -0
- package/dist/node/lib/A-Server/A-Server.types.js +4 -0
- package/dist/node/lib/A-Server/A-Server.types.js.map +1 -0
- package/dist/node/lib/A-Server/A-Server.types.mjs +3 -0
- package/dist/node/lib/A-Server/A-Server.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.d.mts +29 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.d.ts +29 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.js +49 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.js.map +1 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.mjs +37 -0
- package/dist/node/lib/A-ServerController/A-ServerController.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.d.mts +2 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.d.ts +2 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.js +4 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.js.map +1 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.mjs +3 -0
- package/dist/node/lib/A-ServerController/A-ServerController.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.d.mts +49 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.d.ts +49 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.js +91 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.js.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.mjs +90 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.entity.mjs.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.d.mts +22 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.d.ts +22 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.js +10 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.js.map +1 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.mjs +10 -0
- package/dist/node/lib/A-ServerEntityList/A-EntityList.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.d.mts +13 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.d.ts +13 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.js +32 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.js.map +1 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.mjs +31 -0
- package/dist/node/lib/A-ServerListQuery/A-ServerListQueryFilter.context.mjs.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.d.mts +48 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.d.ts +48 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.js +88 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.js.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.mjs +76 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.d.mts +24 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.d.ts +24 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.js +33 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.js.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.mjs +33 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.d.mts +12 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.d.ts +12 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.js +4 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.js.map +1 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.mjs +3 -0
- package/dist/node/lib/A-ServerLogger/A-ServerLogger.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.d.mts +6 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.d.ts +6 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.js +18 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.js.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.mjs +17 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.d.mts +2 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.d.ts +2 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.js +4 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.js.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.mjs +3 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.d.mts +2 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.d.ts +2 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.js +4 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.js.map +1 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.mjs +3 -0
- package/dist/node/lib/A-ServerMiddleware/A-ServerMiddleware.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.d.mts +31 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.d.ts +31 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.js +90 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.js.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.mjs +78 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.d.mts +9 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.d.ts +9 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.js +14 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.js.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.mjs +14 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.d.mts +36 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.d.ts +36 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.js +60 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.js.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.mjs +59 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.context.mjs.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.d.mts +23 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.d.ts +23 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.js +4 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.js.map +1 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.mjs +3 -0
- package/dist/node/lib/A-ServerProxy/A-ServerProxy.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.d.mts +20 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.d.ts +20 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.js +25 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.js.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.mjs +24 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.d.mts +15 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.d.ts +15 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.js +24 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.js.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.mjs +23 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.entity.mjs.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.d.mts +6 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.d.ts +6 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.js +4 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.js.map +1 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.mjs +3 -0
- package/dist/node/lib/A-ServerRoute/A-ServerRoute.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.d.mts +84 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.d.ts +84 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.js +194 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.mjs +184 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.d.mts +6 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.d.ts +6 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.js +10 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.mjs +10 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.constants.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.d.mts +16 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.d.ts +16 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.js +40 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.mjs +39 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.meta.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.d.mts +24 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.d.ts +24 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.js +4 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.mjs +3 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouter.types.mjs.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.d.mts +16 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.d.ts +16 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.js +25 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.js.map +1 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.mjs +24 -0
- package/dist/node/lib/A-ServerRouter/A-ServerRouterDefine.decorator.mjs.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.d.mts +65 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.d.ts +65 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.js +260 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.js.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.mjs +248 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.component.mjs.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.d.mts +110 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.d.ts +110 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.js +180 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.js.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.mjs +179 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.context.mjs.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.d.mts +8 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.d.ts +8 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.js +4 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.js.map +1 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.mjs +3 -0
- package/dist/node/lib/A-ServerStatic/A-ServerStatic.types.mjs.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.d.mts +29 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.d.ts +29 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.js +62 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.js.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.mjs +50 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.component.mjs.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.d.mts +5 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.d.ts +5 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.js +14 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.js.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.mjs +14 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.constants.mjs.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.d.mts +9 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.d.ts +9 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.js +4 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.js.map +1 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.mjs +3 -0
- package/dist/node/middlewares/A-ServerCORS/A_ServerCORS.types.mjs.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.d.mts +24 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.d.ts +24 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.js +94 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.js.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.mjs +82 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.component.mjs.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.d.mts +2 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.d.ts +2 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.js +4 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.js.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.mjs +3 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.error.mjs.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.d.mts +2 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.d.ts +2 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.js +4 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.js.map +1 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.mjs +3 -0
- package/dist/node/repositories/A-EntityRepository/A-EntityRepository.types.mjs.map +1 -0
- package/examples/simple-server/commands/SignIn.command.ts +17 -1
- package/examples/simple-server/components/Test.controller.ts +8 -7
- package/examples/simple-server/components/Users.repository.ts +28 -26
- package/examples/simple-server/concept.ts +56 -66
- package/examples/simple-server/entities/User/User.entity.ts +17 -7
- package/jest.config.ts +24 -10
- package/package.json +267 -25
- package/src/channels/A-Http/A-Http.channel.constants.ts +6 -7
- package/src/channels/A-Http/A-Http.channel.error.ts +2 -2
- package/src/channels/A-Http/A-Http.channel.ts +76 -125
- package/src/channels/A-Http/A-Http.channel.types.ts +6 -3
- package/src/channels/A-Websockets/A-Websockets.channel.ts +1 -1
- package/src/{components → controllers}/A-CommandController/A-CommandController.component.ts +16 -10
- package/src/{components → controllers}/A-EntityController/A-EntityController.component.ts +24 -28
- package/src/{components → controllers}/A-ListingController/A-ListingController.component.ts +10 -12
- package/src/{components → controllers}/A-ServerHealthMonitor/A-ServerHealthMonitor.component.ts +11 -11
- package/src/index.ts +58 -63
- package/src/lib/A-Request/A-HttpRequestData.context.ts +30 -0
- package/src/lib/A-Request/A-HttpServerRequest.context.ts +103 -0
- package/src/lib/A-Request/A-Request.constants.ts +30 -0
- package/src/lib/A-Request/A-Request.entity.ts +844 -0
- package/src/lib/A-Request/A-Request.env.ts +50 -0
- package/src/lib/A-Request/A-Request.error.ts +11 -0
- package/src/lib/A-Request/A-Request.helper.ts +276 -0
- package/src/lib/A-Request/A-Request.types.ts +284 -0
- package/src/lib/A-Request/README.md +567 -0
- package/src/lib/A-Response/A-Response.constants.ts +24 -0
- package/src/lib/A-Response/A-Response.entity.ts +689 -0
- package/src/lib/A-Response/A-Response.error.ts +6 -0
- package/src/lib/A-Response/A-Response.types.ts +127 -0
- package/src/lib/A-Response/README.md +793 -0
- package/src/lib/A-Server/A-HttpServer.constants.ts +9 -0
- package/src/lib/A-Server/A-HttpServer.container.ts +251 -0
- package/src/lib/A-Server/A-HttpServer.error.ts +165 -0
- package/src/lib/A-Server/A-HttpServer.types.ts +37 -0
- package/src/{context/A-Server/A_Server.context.ts → lib/A-Server/A-Server.context.ts} +6 -7
- package/src/lib/A-Server/A-Server.error.ts +26 -0
- package/src/{components/A-ServerError/A-ServerError.types.ts → lib/A-Server/A-Server.types.ts} +8 -0
- package/src/{components/A-Controller/A-Controller.component.ts → lib/A-ServerController/A-ServerController.component.ts} +5 -5
- package/src/{entities/A_EntityList/A_EntityList.entity.ts → lib/A-ServerEntityList/A-EntityList.entity.ts} +2 -2
- package/src/{entities/A_EntityList/A_EntityList.entity.types.ts → lib/A-ServerEntityList/A-EntityList.types.ts} +2 -2
- package/src/{context/A-ListQueryFilter/A_ListQueryFilter.context.ts → lib/A-ServerListQuery/A-ServerListQueryFilter.context.ts} +1 -1
- package/src/lib/A-ServerLogger/A-ServerLogger.component.ts +121 -0
- package/src/lib/A-ServerLogger/A-ServerLogger.types.ts +13 -0
- package/src/lib/A-ServerMiddleware/A-ServerMiddleware.component.ts +17 -0
- package/src/{components → lib}/A-ServerProxy/A-ServerProxy.component.ts +17 -12
- package/src/{context/A-ProxyConfig/A_ProxyConfig.constants.ts → lib/A-ServerProxy/A-ServerProxy.constants.ts} +1 -1
- package/src/{context/A-ProxyConfig/A_ProxyConfig.context.ts → lib/A-ServerProxy/A-ServerProxy.context.ts} +4 -4
- package/src/{context/A-ProxyConfig/A_ProxyConfig.types.ts → lib/A-ServerProxy/A-ServerProxy.types.ts} +4 -4
- package/src/lib/A-ServerRoute/A-ServerRoute.constants.ts +20 -0
- package/src/lib/A-ServerRoute/A-ServerRoute.entity.ts +48 -0
- package/src/lib/A-ServerRoute/A-ServerRoute.types.ts +6 -0
- package/src/{components/A-Router/A-Router.component.ts → lib/A-ServerRouter/A-ServerRouter.component.ts} +77 -97
- package/src/lib/A-ServerRouter/A-ServerRouter.constants.ts +8 -0
- package/src/lib/A-ServerRouter/A-ServerRouter.meta.ts +48 -0
- package/src/lib/A-ServerRouter/A-ServerRouter.types.ts +27 -0
- package/src/lib/A-ServerRouter/A-ServerRouterDefine.decorator.ts +37 -0
- package/src/{components/A-StaticLoader/A-StaticLoader.component.ts → lib/A-ServerStatic/A-ServerStatic.component.ts} +73 -54
- package/src/{context/A-StaticConfig/A-StaticConfig.context.ts → lib/A-ServerStatic/A-ServerStatic.context.ts} +16 -6
- package/src/{components → middlewares}/A-ServerCORS/A_ServerCORS.component.ts +16 -13
- package/src/{components/A-ServerCORS/A_ServerCORS.component.defaults.ts → middlewares/A-ServerCORS/A_ServerCORS.constants.ts} +2 -2
- package/src/{components → repositories}/A-EntityRepository/A-EntityRepository.component.ts +39 -30
- package/tests/A-HttpChannel.test.ts +41 -48
- package/tests/A-HttpServerError.test.ts +204 -0
- package/tests/A-Request.test.ts +351 -0
- package/tsconfig.json +40 -50
- package/tsup.config.ts +111 -13
- package/dist/index.d.mts +0 -855
- package/dist/index.d.ts +0 -855
- package/dist/index.js +0 -2179
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -2144
- package/dist/index.mjs.map +0 -1
- package/examples/microservices-server/components/controllers/Statistics.controller.ts +0 -18
- package/examples/microservices-server/components/repositories/Memory.repository.ts +0 -66
- package/examples/microservices-server/concept.ts +0 -43
- package/examples/microservices-server/context/MemoryStore.context.ts +0 -31
- package/examples/microservices-server/entities/Order.entity.ts +0 -7
- package/examples/microservices-server/entities/User.entity.ts +0 -8
- package/src/components/A-Router/A-Router.component.types.ts +0 -38
- package/src/components/A-ServerError/A-ServerError.class.ts +0 -98
- package/src/components/A-ServerLogger/A_ServerLogger.component.ts +0 -194
- package/src/components/A-ServerLogger/A_ServerLogger.component.types.ts +0 -14
- package/src/containers/A-Service/A-Service.container.ts +0 -218
- package/src/containers/A-Service/A-Service.container.types.ts +0 -46
- package/src/context/A-EntityFactory/A-EntityFactory.context.ts +0 -163
- package/src/context/A-EntityFactory/A-EntityFactory.context.types.ts +0 -11
- package/src/context/A-HttpChannel/A-HttpChannel.context.ts +0 -36
- package/src/context/A-Server/A_Server.context.types.ts +0 -9
- package/src/entities/A-Request/A-Request.entity.ts +0 -163
- package/src/entities/A-Request/A-Request.entity.types.ts +0 -41
- package/src/entities/A-Response/A-Response.entity.ts +0 -194
- package/src/entities/A-Response/A-Response.entity.types.ts +0 -26
- package/src/entities/A-Route/A-Route.entity.ts +0 -117
- package/tests/A-Service.test.ts +0 -18
- /package/src/{components → controllers}/A-EntityController/A-EntityController.component.types.ts +0 -0
- /package/src/{components/A-Controller/A-Controller.component.types.ts → controllers/A-ListingController/A-ListingController.types.ts} +0 -0
- /package/src/{components/A-ServerHealthMonitor/A-ServerHealthMonitor.component.types.ts → controllers/A-ServerHealthMonitor/A-ServerHealthMonitor.types.ts} +0 -0
- /package/src/{components/A-EntityRepository/A-EntityRepository.error.ts → lib/A-Response/A-Response.env.ts} +0 -0
- /package/src/{components/A-EntityRepository/A-EntityRepository.types.ts → lib/A-ServerController/A-ServerController.types.ts} +0 -0
- /package/src/{components → lib}/A-ServerLogger/A-ServerLogger.constants.ts +0 -0
- /package/src/{components/A-ListingController/A-ListingController.component.types.ts → lib/A-ServerMiddleware/A-ServerMiddleware.constants.ts} +0 -0
- /package/src/{components/A-ServerError/A-ServerError.constants.ts → lib/A-ServerMiddleware/A-ServerMiddleware.types.ts} +0 -0
- /package/src/{components/A-StaticLoader/A-StaticLoader.component.types.ts → lib/A-ServerStatic/A-ServerStatic.types.ts} +0 -0
- /package/src/{components/A-ServerCORS/A_ServerCORS.component.types.ts → middlewares/A-ServerCORS/A_ServerCORS.types.ts} +0 -0
- /package/src/{context/A-StaticConfig/A-StaticConfig.context.types.ts → repositories/A-EntityRepository/A-EntityRepository.error.ts} +0 -0
- /package/src/{entities/A-Route/A-Route.entity.types.ts → repositories/A-EntityRepository/A-EntityRepository.types.ts} +0 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { __decorateClass, __decorateParam } from '../../chunk-EQQGB2QZ.mjs';
|
|
2
|
+
import { A_Component, A_Concept, A_Inject, A_Feature } from '@adaas/a-concept';
|
|
3
|
+
import { A_Request } from '@adaas/a-server/request/A-Request.entity';
|
|
4
|
+
import { A_Response } from '@adaas/a-server/response/A-Response.entity';
|
|
5
|
+
import { A_StaticConfig } from './A-ServerStatic.context';
|
|
6
|
+
import { A_HttpServerFeatures } from '@adaas/a-server/server/A-HttpServer.constants';
|
|
7
|
+
import { A_HttpServerError } from '@adaas/a-server/server/A-HttpServer.error';
|
|
8
|
+
import { A_Logger } from '@adaas/a-utils/a-logger';
|
|
9
|
+
import { A_Polyfill } from '@adaas/a-utils/a-polyfill';
|
|
10
|
+
import { A_ServerRoute } from '@adaas/a-server/route/A-ServerRoute.entity';
|
|
11
|
+
|
|
12
|
+
var _a;
|
|
13
|
+
class A_StaticLoader extends A_Component {
|
|
14
|
+
async load(logger, config, polyfill) {
|
|
15
|
+
this._fsPolyfill = await polyfill.fs();
|
|
16
|
+
this._pathPolyfill = await polyfill.path();
|
|
17
|
+
const aliases = config.getEnabledAliases();
|
|
18
|
+
logger.info(
|
|
19
|
+
"cyan",
|
|
20
|
+
`Static aliases configured:`,
|
|
21
|
+
...aliases.map((alias) => `${alias.alias} -> ${alias.directory}`)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
async [_a = A_HttpServerFeatures.onRequest](req, res, logger, config, polyfill) {
|
|
25
|
+
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const { method, url } = req;
|
|
29
|
+
const route = new A_ServerRoute(url, method);
|
|
30
|
+
const alias = config.findMatchingAlias(route.path);
|
|
31
|
+
if (!alias) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const fs = this._fsPolyfill || await polyfill.fs();
|
|
36
|
+
const path = this._pathPolyfill || await polyfill.path();
|
|
37
|
+
const staticDir = path.resolve(process.cwd(), alias.directory);
|
|
38
|
+
if (!fs.existsSync(staticDir)) {
|
|
39
|
+
logger.log("red", `Static directory ${staticDir} does not exist.`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const relativePath = route.path.replace(alias.path, "");
|
|
43
|
+
const safePath = this.safeFilePath(staticDir, relativePath, req.headers?.host, path, fs);
|
|
44
|
+
await this.serveFile(safePath, res, logger, fs, path);
|
|
45
|
+
logger.log("green", `Successfully served: ${safePath}`);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw new A_HttpServerError({
|
|
48
|
+
status: 500,
|
|
49
|
+
title: "Static File Serving Error",
|
|
50
|
+
description: `Error serving static file for ${route.path}: ${error.message}`,
|
|
51
|
+
originalError: error
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Add a custom static file alias through the config
|
|
57
|
+
* @param alias - The URL path alias (e.g., '/assets')
|
|
58
|
+
* @param directory - The local directory path
|
|
59
|
+
* @param path - Optional custom path (defaults to alias)
|
|
60
|
+
* @param config - Static config instance
|
|
61
|
+
* @param logger - Logger instance for logging
|
|
62
|
+
*/
|
|
63
|
+
addAlias(alias, directory, config, logger, path) {
|
|
64
|
+
config.addAlias(alias, directory, path);
|
|
65
|
+
if (logger) {
|
|
66
|
+
logger.log("cyan", `Static alias added: ${alias} -> ${directory}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Remove a static file alias through the config
|
|
71
|
+
* @param aliasPath - The path of the alias to remove
|
|
72
|
+
* @param config - Static config instance
|
|
73
|
+
* @param logger - Logger instance for logging
|
|
74
|
+
*/
|
|
75
|
+
removeAlias(aliasPath, config, logger) {
|
|
76
|
+
const removed = config.removeAlias(aliasPath);
|
|
77
|
+
if (removed && logger) {
|
|
78
|
+
logger.log("yellow", `Static alias removed: ${aliasPath}`);
|
|
79
|
+
}
|
|
80
|
+
return removed;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get all configured aliases from config
|
|
84
|
+
* @param config - Static config instance
|
|
85
|
+
*/
|
|
86
|
+
getAliases(config) {
|
|
87
|
+
return config.getAliases();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Enable or disable an alias
|
|
91
|
+
* @param aliasPath - The path of the alias
|
|
92
|
+
* @param enabled - Whether to enable or disable
|
|
93
|
+
* @param config - Static config instance
|
|
94
|
+
* @param logger - Logger instance for logging
|
|
95
|
+
*/
|
|
96
|
+
setAliasEnabled(aliasPath, enabled, config, logger) {
|
|
97
|
+
const result = config.setAliasEnabled(aliasPath, enabled);
|
|
98
|
+
if (result && logger) {
|
|
99
|
+
logger.log("blue", `Static alias ${enabled ? "enabled" : "disabled"}: ${aliasPath}`);
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
getMimeType(ext) {
|
|
104
|
+
const mimeTypes = {
|
|
105
|
+
// Text
|
|
106
|
+
".html": "text/html",
|
|
107
|
+
".htm": "text/html",
|
|
108
|
+
".css": "text/css",
|
|
109
|
+
".txt": "text/plain",
|
|
110
|
+
".md": "text/markdown",
|
|
111
|
+
".xml": "application/xml",
|
|
112
|
+
// JavaScript
|
|
113
|
+
".js": "application/javascript",
|
|
114
|
+
".mjs": "application/javascript",
|
|
115
|
+
".jsx": "application/javascript",
|
|
116
|
+
".ts": "application/typescript",
|
|
117
|
+
".tsx": "application/typescript",
|
|
118
|
+
// JSON
|
|
119
|
+
".json": "application/json",
|
|
120
|
+
".jsonld": "application/ld+json",
|
|
121
|
+
// Images
|
|
122
|
+
".png": "image/png",
|
|
123
|
+
".jpg": "image/jpeg",
|
|
124
|
+
".jpeg": "image/jpeg",
|
|
125
|
+
".gif": "image/gif",
|
|
126
|
+
".svg": "image/svg+xml",
|
|
127
|
+
".ico": "image/x-icon",
|
|
128
|
+
".webp": "image/webp",
|
|
129
|
+
".bmp": "image/bmp",
|
|
130
|
+
".tiff": "image/tiff",
|
|
131
|
+
// Fonts
|
|
132
|
+
".woff": "font/woff",
|
|
133
|
+
".woff2": "font/woff2",
|
|
134
|
+
".ttf": "font/ttf",
|
|
135
|
+
".otf": "font/otf",
|
|
136
|
+
".eot": "application/vnd.ms-fontobject",
|
|
137
|
+
// Audio/Video
|
|
138
|
+
".mp3": "audio/mpeg",
|
|
139
|
+
".wav": "audio/wav",
|
|
140
|
+
".mp4": "video/mp4",
|
|
141
|
+
".webm": "video/webm",
|
|
142
|
+
".ogg": "application/ogg",
|
|
143
|
+
// Archives
|
|
144
|
+
".zip": "application/zip",
|
|
145
|
+
".tar": "application/x-tar",
|
|
146
|
+
".gz": "application/gzip",
|
|
147
|
+
// Documents
|
|
148
|
+
".pdf": "application/pdf",
|
|
149
|
+
".doc": "application/msword",
|
|
150
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
151
|
+
".xls": "application/vnd.ms-excel",
|
|
152
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
153
|
+
};
|
|
154
|
+
return mimeTypes[ext.toLowerCase()] || "application/octet-stream";
|
|
155
|
+
}
|
|
156
|
+
safeFilePath(staticDir, reqUrl, host = "localhost", pathPolyfill, fsPolyfill) {
|
|
157
|
+
const parsedUrl = new URL(reqUrl || "/", `http://${host}`);
|
|
158
|
+
let pathname = decodeURIComponent(parsedUrl.pathname);
|
|
159
|
+
pathname = pathname.replace(/\.\.[\/\\]/g, "");
|
|
160
|
+
let filePath = pathPolyfill.join(staticDir, pathname);
|
|
161
|
+
if (!fsPolyfill.existsSync(filePath)) {
|
|
162
|
+
throw new Error(`File not found: ${filePath}`);
|
|
163
|
+
}
|
|
164
|
+
return filePath;
|
|
165
|
+
}
|
|
166
|
+
serveFile(filePath, res, logger, fsPolyfill, pathPolyfill) {
|
|
167
|
+
return new Promise((resolve, reject) => {
|
|
168
|
+
try {
|
|
169
|
+
if (fsPolyfill.existsSync(filePath)) {
|
|
170
|
+
const ext = pathPolyfill.extname(filePath);
|
|
171
|
+
const contentType = this.getMimeType(ext);
|
|
172
|
+
const headers = {
|
|
173
|
+
"Content-Type": contentType,
|
|
174
|
+
"Cache-Control": this.getCacheControl(ext),
|
|
175
|
+
"X-Content-Type-Options": "nosniff"
|
|
176
|
+
};
|
|
177
|
+
res.writeHead(200, headers);
|
|
178
|
+
const stream = fsPolyfill.createReadStream(filePath);
|
|
179
|
+
if (stream && res.original) {
|
|
180
|
+
stream.pipe(res.original);
|
|
181
|
+
stream.on("end", () => {
|
|
182
|
+
resolve();
|
|
183
|
+
});
|
|
184
|
+
stream.on("error", (err) => {
|
|
185
|
+
reject(new A_HttpServerError({
|
|
186
|
+
status: 500,
|
|
187
|
+
title: "File Stream Error",
|
|
188
|
+
description: `Error reading file stream for ${filePath}: ${err.message}`,
|
|
189
|
+
originalError: err
|
|
190
|
+
}));
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
reject(new A_HttpServerError({
|
|
194
|
+
status: 500,
|
|
195
|
+
title: "Response Stream Error",
|
|
196
|
+
description: `Unable to pipe file stream for ${filePath}`
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
reject(new A_HttpServerError({
|
|
201
|
+
status: 404,
|
|
202
|
+
title: "File Not Found",
|
|
203
|
+
description: `File not found: ${filePath}`
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
} catch (error) {
|
|
207
|
+
logger.error(`Error serving file: ${error.message}`);
|
|
208
|
+
reject(new A_HttpServerError({
|
|
209
|
+
status: 500,
|
|
210
|
+
title: "Internal Server Error",
|
|
211
|
+
description: `Error serving file: ${error.message}`,
|
|
212
|
+
originalError: error
|
|
213
|
+
}));
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
getCacheControl(ext) {
|
|
218
|
+
const staticAssets = [".css", ".js", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".woff", ".woff2", ".ttf", ".otf"];
|
|
219
|
+
const dynamicContent = [".html", ".htm"];
|
|
220
|
+
if (staticAssets.includes(ext.toLowerCase())) {
|
|
221
|
+
return "public, max-age=31536000";
|
|
222
|
+
} else if (dynamicContent.includes(ext.toLowerCase())) {
|
|
223
|
+
return "public, max-age=3600";
|
|
224
|
+
} else {
|
|
225
|
+
return "public, max-age=86400";
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
__decorateClass([
|
|
230
|
+
A_Concept.Load(),
|
|
231
|
+
__decorateParam(0, A_Inject(A_Logger)),
|
|
232
|
+
__decorateParam(1, A_Inject(A_StaticConfig)),
|
|
233
|
+
__decorateParam(2, A_Inject(A_Polyfill))
|
|
234
|
+
], A_StaticLoader.prototype, "load", 1);
|
|
235
|
+
__decorateClass([
|
|
236
|
+
A_Feature.Extend({
|
|
237
|
+
before: /.*/
|
|
238
|
+
}),
|
|
239
|
+
__decorateParam(0, A_Inject(A_Request)),
|
|
240
|
+
__decorateParam(1, A_Inject(A_Response)),
|
|
241
|
+
__decorateParam(2, A_Inject(A_Logger)),
|
|
242
|
+
__decorateParam(3, A_Inject(A_StaticConfig)),
|
|
243
|
+
__decorateParam(4, A_Inject(A_Polyfill))
|
|
244
|
+
], A_StaticLoader.prototype, _a, 1);
|
|
245
|
+
|
|
246
|
+
export { A_StaticLoader };
|
|
247
|
+
//# sourceMappingURL=A-ServerStatic.component.mjs.map
|
|
248
|
+
//# sourceMappingURL=A-ServerStatic.component.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/A-ServerStatic/A-ServerStatic.component.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,IAAA,EAAA;AAUO,MAAM,uBAAuB,WAAA,CAAY;AAAA,EAM5C,MAAM,IAAA,CACkB,MAAA,EACM,MAAA,EACJ,QAAA,EACxB;AAEE,IAAA,IAAA,CAAK,WAAA,GAAc,MAAM,QAAA,CAAS,EAAA,EAAG;AACrC,IAAA,IAA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AA,EAAS,QAAA,EAAU,QAAQ,MAAM,CAAA;AACvH,IAAA,MAAM,cAAA,GAAiB,CAAC,OAAA,EAAS,MAAM,CAAA;AAEvC,IAAA,IAAI,YAAA,CAAa,QAAA,CAAS,GAAA,CAAI,WAAA,EAAa,CAAA,EAAG;AAC1C,MAAA,OAAO,0BAAA;AAAA,IACX,WAAW,cAAA,CAAe,QAAA,CAAS,GAAA,CAAI,WAAA,EAAa,CAAA,EAAG;AACnD,MAAA,OAAO,sBAAA;AAAA,IACX,CAAA,MAAO;AACH,MAAA,OAAO,uBAAA;AAAA,IACX;AAAA,EACJ;AAEJ;AAhTU,eAAA,CAAA;AAAA,EADL,UAAU,IAAA,EAAK;AAAA,EAEX,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,cAAc,CAAA,CAAA;AAAA,EACvB,4BAAS,UAAU,CAAA;AAAA,CAAA,EATf,cAAA,CAMH,SAAA,EAAA,MAAA,EAAA,CAAA,CAAA;AA0BC,eAAA,CAAA;AAAA,EAHN,UAAU,MAAA,CAAO;AAAA,IACd,MAAA,EAAQ;AAAA,GACX,CAAA;AAAA,EAEI,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,UAAU,CAAA,CAAA;AAAA,EACnB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,cAAc,CAAA,CAAA;AAAA,EACvB,4BAAS,UAAU,CAAA;AAAA,CAAA,EArCf,cAAA,CAgCF,SAAA,EAAA,EAAA,EAAA,CAAA,CAAA","file":"A-ServerStatic.component.mjs","sourcesContent":["import { A_Component, A_Concept, A_Feature, A_Inject } from \"@adaas/a-concept\"\nimport { A_Request } from \"@adaas/a-server/request/A-Request.entity\";\nimport { A_Response } from \"@adaas/a-server/response/A-Response.entity\";\nimport { A_StaticConfig, A_StaticAlias } from \"./A-ServerStatic.context\";\nimport { A_HttpServerFeatures } from \"@adaas/a-server/server/A-HttpServer.constants\";\nimport { A_HttpServerError } from \"@adaas/a-server/server/A-HttpServer.error\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Polyfill } from \"@adaas/a-utils/a-polyfill\";\nimport { A_ServerRoute } from \"@adaas/a-server/route/A-ServerRoute.entity\";\n\nexport class A_StaticLoader extends A_Component {\n\n private _fsPolyfill: any;\n private _pathPolyfill: any;\n\n @A_Concept.Load()\n async load(\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(A_StaticConfig) config: A_StaticConfig,\n @A_Inject(A_Polyfill) polyfill: A_Polyfill\n ) {\n // Initialize polyfills\n this._fsPolyfill = await polyfill.fs();\n this._pathPolyfill = await polyfill.path();\n\n // Log configured aliases\n const aliases = config.getEnabledAliases();\n logger.info('cyan',\n\n `Static aliases configured:`,\n ...aliases.map(alias => `${alias.alias} -> ${alias.directory}`)\n );\n }\n\n\n // =======================================================\n // ================ Method Definition=====================\n // =======================================================\n\n @A_Feature.Extend({\n before: /.*/\n })\n async [A_HttpServerFeatures.onRequest](\n @A_Inject(A_Request) req: A_Request,\n @A_Inject(A_Response) res: A_Response,\n @A_Inject(A_Logger) logger: A_Logger,\n @A_Inject(A_StaticConfig) config: A_StaticConfig,\n @A_Inject(A_Polyfill) polyfill: A_Polyfill\n ) {\n\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n return; // Only handle GET and HEAD requests\n }\n\n const { method, url } = req;\n const route = new A_ServerRoute(url, method);\n\n // Check if this request matches any of our configured aliases\n const alias = config.findMatchingAlias(route.path);\n if (!alias) {\n return; // No static config for this path\n }\n\n try {\n // Ensure polyfills are available\n const fs = this._fsPolyfill || await polyfill.fs();\n const path = this._pathPolyfill || await polyfill.path();\n\n const staticDir = path.resolve(process.cwd(), alias.directory);\n\n // Validate static directory exists\n if (!fs.existsSync(staticDir)) {\n logger.log(\"red\", `Static directory ${staticDir} does not exist.`);\n return;\n }\n\n // Get the file path relative to the alias\n const relativePath = route.path.replace(alias.path, '');\n const safePath = this.safeFilePath(staticDir, relativePath, req.headers?.host, path, fs);\n\n await this.serveFile(safePath, res, logger, fs, path);\n\n logger.log('green', `Successfully served: ${safePath}`);\n\n } catch (error: any) {\n throw new A_HttpServerError({\n status: 500,\n title: 'Static File Serving Error',\n description: `Error serving static file for ${route.path}: ${error.message}`,\n originalError: error\n });\n }\n }\n\n /**\n * Add a custom static file alias through the config\n * @param alias - The URL path alias (e.g., '/assets')\n * @param directory - The local directory path\n * @param path - Optional custom path (defaults to alias)\n * @param config - Static config instance\n * @param logger - Logger instance for logging\n */\n public addAlias(\n alias: string,\n directory: string,\n config: A_StaticConfig,\n logger?: A_Logger,\n path?: string\n ): void {\n config.addAlias(alias, directory, path);\n\n if (logger) {\n logger.log('cyan', `Static alias added: ${alias} -> ${directory}`);\n }\n }\n\n /**\n * Remove a static file alias through the config\n * @param aliasPath - The path of the alias to remove\n * @param config - Static config instance\n * @param logger - Logger instance for logging\n */\n public removeAlias(aliasPath: string, config: A_StaticConfig, logger?: A_Logger): boolean {\n const removed = config.removeAlias(aliasPath);\n\n if (removed && logger) {\n logger.log('yellow', `Static alias removed: ${aliasPath}`);\n }\n\n return removed;\n }\n\n /**\n * Get all configured aliases from config\n * @param config - Static config instance\n */\n public getAliases(config: A_StaticConfig): A_StaticAlias[] {\n return config.getAliases();\n }\n\n /**\n * Enable or disable an alias\n * @param aliasPath - The path of the alias\n * @param enabled - Whether to enable or disable\n * @param config - Static config instance\n * @param logger - Logger instance for logging\n */\n public setAliasEnabled(\n aliasPath: string,\n enabled: boolean,\n config: A_StaticConfig,\n logger?: A_Logger\n ): boolean {\n const result = config.setAliasEnabled(aliasPath, enabled);\n\n if (result && logger) {\n logger.log('blue', `Static alias ${enabled ? 'enabled' : 'disabled'}: ${aliasPath}`);\n }\n\n return result;\n }\n\n protected getMimeType(ext: string): string {\n const mimeTypes: Record<string, string> = {\n // Text\n \".html\": \"text/html\",\n \".htm\": \"text/html\",\n \".css\": \"text/css\",\n \".txt\": \"text/plain\",\n \".md\": \"text/markdown\",\n \".xml\": \"application/xml\",\n\n // JavaScript\n \".js\": \"application/javascript\",\n \".mjs\": \"application/javascript\",\n \".jsx\": \"application/javascript\",\n \".ts\": \"application/typescript\",\n \".tsx\": \"application/typescript\",\n\n // JSON\n \".json\": \"application/json\",\n \".jsonld\": \"application/ld+json\",\n\n // Images\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".gif\": \"image/gif\",\n \".svg\": \"image/svg+xml\",\n \".ico\": \"image/x-icon\",\n \".webp\": \"image/webp\",\n \".bmp\": \"image/bmp\",\n \".tiff\": \"image/tiff\",\n\n // Fonts\n \".woff\": \"font/woff\",\n \".woff2\": \"font/woff2\",\n \".ttf\": \"font/ttf\",\n \".otf\": \"font/otf\",\n \".eot\": \"application/vnd.ms-fontobject\",\n\n // Audio/Video\n \".mp3\": \"audio/mpeg\",\n \".wav\": \"audio/wav\",\n \".mp4\": \"video/mp4\",\n \".webm\": \"video/webm\",\n \".ogg\": \"application/ogg\",\n\n // Archives\n \".zip\": \"application/zip\",\n \".tar\": \"application/x-tar\",\n \".gz\": \"application/gzip\",\n\n // Documents\n \".pdf\": \"application/pdf\",\n \".doc\": \"application/msword\",\n \".docx\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \".xls\": \"application/vnd.ms-excel\",\n \".xlsx\": \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n };\n\n return mimeTypes[ext.toLowerCase()] || \"application/octet-stream\";\n }\n\n\n protected safeFilePath(staticDir: string, reqUrl: string, host: string = 'localhost', pathPolyfill: any, fsPolyfill: any): string {\n const parsedUrl = new URL(reqUrl || \"/\", `http://${host}`);\n let pathname = decodeURIComponent(parsedUrl.pathname);\n\n // Prevent path traversal attacks\n pathname = pathname.replace(/\\.\\.[\\/\\\\]/g, \"\");\n\n let filePath = pathPolyfill.join(staticDir, pathname);\n\n if (!fsPolyfill.existsSync(filePath)) {\n throw new Error(`File not found: ${filePath}`);\n }\n\n return filePath;\n }\n\n protected serveFile(\n filePath: string,\n res: A_Response,\n logger: A_Logger,\n fsPolyfill: any,\n pathPolyfill: any\n ): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n try {\n if (fsPolyfill.existsSync(filePath)) {\n const ext = pathPolyfill.extname(filePath);\n const contentType = this.getMimeType(ext);\n\n // Set appropriate headers\n const headers: Record<string, string> = {\n \"Content-Type\": contentType,\n \"Cache-Control\": this.getCacheControl(ext),\n \"X-Content-Type-Options\": \"nosniff\"\n };\n\n res.writeHead(200, headers);\n\n const stream = fsPolyfill.createReadStream(filePath);\n\n if (stream && res.original) {\n stream.pipe(res.original);\n\n stream.on('end', () => {\n resolve();\n });\n\n stream.on(\"error\", (err: any) => {\n reject(new A_HttpServerError({\n status: 500,\n title: 'File Stream Error',\n description: `Error reading file stream for ${filePath}: ${err.message}`,\n originalError: err\n }));\n });\n } else {\n reject(new A_HttpServerError({\n status: 500,\n title: 'Response Stream Error',\n description: `Unable to pipe file stream for ${filePath}`,\n }));\n }\n } else {\n reject(new A_HttpServerError({\n status: 404,\n title: 'File Not Found',\n description: `File not found: ${filePath}`,\n }));\n }\n } catch (error: any) {\n logger.error(`Error serving file: ${error.message}`);\n reject(new A_HttpServerError({\n status: 500,\n title: 'Internal Server Error',\n description: `Error serving file: ${error.message}`,\n originalError: error\n }));\n }\n });\n }\n\n protected getCacheControl(ext: string): string {\n // Different cache strategies for different file types\n const staticAssets = ['.css', '.js', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.woff', '.woff2', '.ttf', '.otf'];\n const dynamicContent = ['.html', '.htm'];\n\n if (staticAssets.includes(ext.toLowerCase())) {\n return \"public, max-age=31536000\"; // 1 year for static assets\n } else if (dynamicContent.includes(ext.toLowerCase())) {\n return \"public, max-age=3600\"; // 1 hour for HTML\n } else {\n return \"public, max-age=86400\"; // 1 day for other files\n }\n }\n\n}\n\n\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { A_Fragment } from '@adaas/a-concept';
|
|
2
|
+
|
|
3
|
+
interface A_StaticAlias {
|
|
4
|
+
alias: string;
|
|
5
|
+
path: string;
|
|
6
|
+
directory: string;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface A_StaticDirectoryConfig {
|
|
10
|
+
path: string;
|
|
11
|
+
directory: string;
|
|
12
|
+
alias?: string;
|
|
13
|
+
}
|
|
14
|
+
declare class A_StaticConfig extends A_Fragment {
|
|
15
|
+
readonly directories: Array<string>;
|
|
16
|
+
private _aliases;
|
|
17
|
+
private _directoryConfigs;
|
|
18
|
+
constructor(
|
|
19
|
+
/**
|
|
20
|
+
* Setup directories to serve static files from, comma separated
|
|
21
|
+
*/
|
|
22
|
+
directories?: string[],
|
|
23
|
+
/**
|
|
24
|
+
* Custom directory configurations with aliases
|
|
25
|
+
*/
|
|
26
|
+
directoryConfigs?: A_StaticDirectoryConfig[]);
|
|
27
|
+
private initializeDefaultAliases;
|
|
28
|
+
private initializeCustomAliases;
|
|
29
|
+
/**
|
|
30
|
+
* Add a custom static file alias
|
|
31
|
+
* @param alias - The URL path alias (e.g., '/assets')
|
|
32
|
+
* @param directory - The local directory path
|
|
33
|
+
* @param path - Optional custom path (defaults to alias)
|
|
34
|
+
*/
|
|
35
|
+
addAlias(alias: string, directory: string, path?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Remove a static file alias
|
|
38
|
+
* @param aliasPath - The path of the alias to remove
|
|
39
|
+
*/
|
|
40
|
+
removeAlias(aliasPath: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Enable or disable an alias
|
|
43
|
+
* @param aliasPath - The path of the alias
|
|
44
|
+
* @param enabled - Whether to enable or disable
|
|
45
|
+
*/
|
|
46
|
+
setAliasEnabled(aliasPath: string, enabled: boolean): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get all configured aliases
|
|
49
|
+
*/
|
|
50
|
+
getAliases(): A_StaticAlias[];
|
|
51
|
+
/**
|
|
52
|
+
* Get enabled aliases only
|
|
53
|
+
*/
|
|
54
|
+
getEnabledAliases(): A_StaticAlias[];
|
|
55
|
+
/**
|
|
56
|
+
* Find the best matching alias for a given request path
|
|
57
|
+
* @param requestPath - The request path to match
|
|
58
|
+
*/
|
|
59
|
+
findMatchingAlias(requestPath: string): A_StaticAlias | null;
|
|
60
|
+
/**
|
|
61
|
+
* Check if an alias exists
|
|
62
|
+
* @param aliasPath - The path to check
|
|
63
|
+
*/
|
|
64
|
+
hasAlias(aliasPath: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Get a specific alias by path
|
|
67
|
+
* @param aliasPath - The path of the alias
|
|
68
|
+
*/
|
|
69
|
+
getAlias(aliasPath: string): A_StaticAlias | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Add multiple aliases at once
|
|
72
|
+
* @param aliases - Array of alias configurations
|
|
73
|
+
*/
|
|
74
|
+
addAliases(aliases: A_StaticDirectoryConfig[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* Clear all aliases
|
|
77
|
+
*/
|
|
78
|
+
clearAliases(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Update an existing alias
|
|
81
|
+
* @param aliasPath - The path of the alias to update
|
|
82
|
+
* @param updates - Partial updates to apply
|
|
83
|
+
*/
|
|
84
|
+
updateAlias(aliasPath: string, updates: Partial<A_StaticAlias>): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Get statistics about configured aliases
|
|
87
|
+
*/
|
|
88
|
+
getStats(): {
|
|
89
|
+
total: number;
|
|
90
|
+
enabled: number;
|
|
91
|
+
disabled: number;
|
|
92
|
+
directories: string[];
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Checks if a given path is configured in the proxy (legacy method)
|
|
96
|
+
* @deprecated Use findMatchingAlias instead
|
|
97
|
+
* @param path
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
has(path: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Gets the directory for a given path if configured (legacy method)
|
|
103
|
+
*
|
|
104
|
+
* @param path
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
get(path: string): string | undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { type A_StaticAlias, A_StaticConfig, type A_StaticDirectoryConfig };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { A_Fragment } from '@adaas/a-concept';
|
|
2
|
+
|
|
3
|
+
interface A_StaticAlias {
|
|
4
|
+
alias: string;
|
|
5
|
+
path: string;
|
|
6
|
+
directory: string;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface A_StaticDirectoryConfig {
|
|
10
|
+
path: string;
|
|
11
|
+
directory: string;
|
|
12
|
+
alias?: string;
|
|
13
|
+
}
|
|
14
|
+
declare class A_StaticConfig extends A_Fragment {
|
|
15
|
+
readonly directories: Array<string>;
|
|
16
|
+
private _aliases;
|
|
17
|
+
private _directoryConfigs;
|
|
18
|
+
constructor(
|
|
19
|
+
/**
|
|
20
|
+
* Setup directories to serve static files from, comma separated
|
|
21
|
+
*/
|
|
22
|
+
directories?: string[],
|
|
23
|
+
/**
|
|
24
|
+
* Custom directory configurations with aliases
|
|
25
|
+
*/
|
|
26
|
+
directoryConfigs?: A_StaticDirectoryConfig[]);
|
|
27
|
+
private initializeDefaultAliases;
|
|
28
|
+
private initializeCustomAliases;
|
|
29
|
+
/**
|
|
30
|
+
* Add a custom static file alias
|
|
31
|
+
* @param alias - The URL path alias (e.g., '/assets')
|
|
32
|
+
* @param directory - The local directory path
|
|
33
|
+
* @param path - Optional custom path (defaults to alias)
|
|
34
|
+
*/
|
|
35
|
+
addAlias(alias: string, directory: string, path?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Remove a static file alias
|
|
38
|
+
* @param aliasPath - The path of the alias to remove
|
|
39
|
+
*/
|
|
40
|
+
removeAlias(aliasPath: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Enable or disable an alias
|
|
43
|
+
* @param aliasPath - The path of the alias
|
|
44
|
+
* @param enabled - Whether to enable or disable
|
|
45
|
+
*/
|
|
46
|
+
setAliasEnabled(aliasPath: string, enabled: boolean): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get all configured aliases
|
|
49
|
+
*/
|
|
50
|
+
getAliases(): A_StaticAlias[];
|
|
51
|
+
/**
|
|
52
|
+
* Get enabled aliases only
|
|
53
|
+
*/
|
|
54
|
+
getEnabledAliases(): A_StaticAlias[];
|
|
55
|
+
/**
|
|
56
|
+
* Find the best matching alias for a given request path
|
|
57
|
+
* @param requestPath - The request path to match
|
|
58
|
+
*/
|
|
59
|
+
findMatchingAlias(requestPath: string): A_StaticAlias | null;
|
|
60
|
+
/**
|
|
61
|
+
* Check if an alias exists
|
|
62
|
+
* @param aliasPath - The path to check
|
|
63
|
+
*/
|
|
64
|
+
hasAlias(aliasPath: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Get a specific alias by path
|
|
67
|
+
* @param aliasPath - The path of the alias
|
|
68
|
+
*/
|
|
69
|
+
getAlias(aliasPath: string): A_StaticAlias | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Add multiple aliases at once
|
|
72
|
+
* @param aliases - Array of alias configurations
|
|
73
|
+
*/
|
|
74
|
+
addAliases(aliases: A_StaticDirectoryConfig[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* Clear all aliases
|
|
77
|
+
*/
|
|
78
|
+
clearAliases(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Update an existing alias
|
|
81
|
+
* @param aliasPath - The path of the alias to update
|
|
82
|
+
* @param updates - Partial updates to apply
|
|
83
|
+
*/
|
|
84
|
+
updateAlias(aliasPath: string, updates: Partial<A_StaticAlias>): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Get statistics about configured aliases
|
|
87
|
+
*/
|
|
88
|
+
getStats(): {
|
|
89
|
+
total: number;
|
|
90
|
+
enabled: number;
|
|
91
|
+
disabled: number;
|
|
92
|
+
directories: string[];
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Checks if a given path is configured in the proxy (legacy method)
|
|
96
|
+
* @deprecated Use findMatchingAlias instead
|
|
97
|
+
* @param path
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
has(path: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Gets the directory for a given path if configured (legacy method)
|
|
103
|
+
*
|
|
104
|
+
* @param path
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
get(path: string): string | undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { type A_StaticAlias, A_StaticConfig, type A_StaticDirectoryConfig };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var aConcept = require('@adaas/a-concept');
|
|
4
|
+
|
|
5
|
+
class A_StaticConfig extends aConcept.A_Fragment {
|
|
6
|
+
constructor(directories = [], directoryConfigs = []) {
|
|
7
|
+
super();
|
|
8
|
+
this._aliases = /* @__PURE__ */ new Map();
|
|
9
|
+
this._directoryConfigs = [];
|
|
10
|
+
this.directories = directories;
|
|
11
|
+
this._directoryConfigs = directoryConfigs;
|
|
12
|
+
this.initializeDefaultAliases();
|
|
13
|
+
this.initializeCustomAliases();
|
|
14
|
+
}
|
|
15
|
+
initializeDefaultAliases() {
|
|
16
|
+
this.directories.forEach((dir, index) => {
|
|
17
|
+
const alias = {
|
|
18
|
+
alias: `/static${index > 0 ? index : ""}`,
|
|
19
|
+
path: `/static${index > 0 ? index : ""}`,
|
|
20
|
+
directory: dir,
|
|
21
|
+
enabled: true
|
|
22
|
+
};
|
|
23
|
+
this._aliases.set(alias.path, alias);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
initializeCustomAliases() {
|
|
27
|
+
this._directoryConfigs.forEach((config) => {
|
|
28
|
+
const alias = {
|
|
29
|
+
alias: config.alias || config.path,
|
|
30
|
+
path: config.path,
|
|
31
|
+
directory: config.directory,
|
|
32
|
+
enabled: true
|
|
33
|
+
};
|
|
34
|
+
this._aliases.set(alias.path, alias);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Add a custom static file alias
|
|
39
|
+
* @param alias - The URL path alias (e.g., '/assets')
|
|
40
|
+
* @param directory - The local directory path
|
|
41
|
+
* @param path - Optional custom path (defaults to alias)
|
|
42
|
+
*/
|
|
43
|
+
addAlias(alias, directory, path) {
|
|
44
|
+
const staticAlias = {
|
|
45
|
+
alias,
|
|
46
|
+
path: path || alias,
|
|
47
|
+
directory,
|
|
48
|
+
enabled: true
|
|
49
|
+
};
|
|
50
|
+
this._aliases.set(staticAlias.path, staticAlias);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Remove a static file alias
|
|
54
|
+
* @param aliasPath - The path of the alias to remove
|
|
55
|
+
*/
|
|
56
|
+
removeAlias(aliasPath) {
|
|
57
|
+
return this._aliases.delete(aliasPath);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Enable or disable an alias
|
|
61
|
+
* @param aliasPath - The path of the alias
|
|
62
|
+
* @param enabled - Whether to enable or disable
|
|
63
|
+
*/
|
|
64
|
+
setAliasEnabled(aliasPath, enabled) {
|
|
65
|
+
const alias = this._aliases.get(aliasPath);
|
|
66
|
+
if (alias) {
|
|
67
|
+
alias.enabled = enabled;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get all configured aliases
|
|
74
|
+
*/
|
|
75
|
+
getAliases() {
|
|
76
|
+
return Array.from(this._aliases.values());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get enabled aliases only
|
|
80
|
+
*/
|
|
81
|
+
getEnabledAliases() {
|
|
82
|
+
return Array.from(this._aliases.values()).filter((alias) => alias.enabled !== false);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Find the best matching alias for a given request path
|
|
86
|
+
* @param requestPath - The request path to match
|
|
87
|
+
*/
|
|
88
|
+
findMatchingAlias(requestPath) {
|
|
89
|
+
let bestMatch = null;
|
|
90
|
+
let longestMatch = 0;
|
|
91
|
+
for (const alias of this.getEnabledAliases()) {
|
|
92
|
+
if (requestPath.startsWith(alias.path) && alias.path.length > longestMatch) {
|
|
93
|
+
bestMatch = alias;
|
|
94
|
+
longestMatch = alias.path.length;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return bestMatch;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Check if an alias exists
|
|
101
|
+
* @param aliasPath - The path to check
|
|
102
|
+
*/
|
|
103
|
+
hasAlias(aliasPath) {
|
|
104
|
+
return this._aliases.has(aliasPath);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get a specific alias by path
|
|
108
|
+
* @param aliasPath - The path of the alias
|
|
109
|
+
*/
|
|
110
|
+
getAlias(aliasPath) {
|
|
111
|
+
return this._aliases.get(aliasPath);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Add multiple aliases at once
|
|
115
|
+
* @param aliases - Array of alias configurations
|
|
116
|
+
*/
|
|
117
|
+
addAliases(aliases) {
|
|
118
|
+
aliases.forEach((config) => {
|
|
119
|
+
this.addAlias(config.alias || config.path, config.directory, config.path);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Clear all aliases
|
|
124
|
+
*/
|
|
125
|
+
clearAliases() {
|
|
126
|
+
this._aliases.clear();
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Update an existing alias
|
|
130
|
+
* @param aliasPath - The path of the alias to update
|
|
131
|
+
* @param updates - Partial updates to apply
|
|
132
|
+
*/
|
|
133
|
+
updateAlias(aliasPath, updates) {
|
|
134
|
+
const alias = this._aliases.get(aliasPath);
|
|
135
|
+
if (alias) {
|
|
136
|
+
Object.assign(alias, updates);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get statistics about configured aliases
|
|
143
|
+
*/
|
|
144
|
+
getStats() {
|
|
145
|
+
const aliases = this.getAliases();
|
|
146
|
+
const enabled = aliases.filter((a) => a.enabled !== false);
|
|
147
|
+
const disabled = aliases.filter((a) => a.enabled === false);
|
|
148
|
+
const directories = [...new Set(aliases.map((a) => a.directory))];
|
|
149
|
+
return {
|
|
150
|
+
total: aliases.length,
|
|
151
|
+
enabled: enabled.length,
|
|
152
|
+
disabled: disabled.length,
|
|
153
|
+
directories
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Checks if a given path is configured in the proxy (legacy method)
|
|
158
|
+
* @deprecated Use findMatchingAlias instead
|
|
159
|
+
* @param path
|
|
160
|
+
* @returns
|
|
161
|
+
*/
|
|
162
|
+
has(path) {
|
|
163
|
+
const alias = this.findMatchingAlias(path);
|
|
164
|
+
return alias ? !!alias.directory : false;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Gets the directory for a given path if configured (legacy method)
|
|
168
|
+
*
|
|
169
|
+
* @param path
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
get(path) {
|
|
173
|
+
const alias = this.findMatchingAlias(path);
|
|
174
|
+
return alias ? alias.directory : void 0;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
exports.A_StaticConfig = A_StaticConfig;
|
|
179
|
+
//# sourceMappingURL=A-ServerStatic.context.js.map
|
|
180
|
+
//# sourceMappingURL=A-ServerStatic.context.js.map
|