@dooboostore/simple-boot-http-server 1.0.16 → 1.0.18
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/LICENSE.md +7 -0
- package/README.MD +6 -47
- package/dist/cjs/SimpleBootHttpServer.d.ts.map +1 -0
- package/dist/cjs/SimpleBootHttpServer.js +930 -0
- package/dist/cjs/SimpleBootHttpServer.js.map +7 -0
- package/dist/cjs/codes/HttpHeaders.d.ts.map +1 -0
- package/dist/cjs/codes/HttpHeaders.js +71 -0
- package/dist/cjs/codes/HttpHeaders.js.map +7 -0
- package/dist/cjs/codes/HttpMethod.d.ts.map +1 -0
- package/dist/cjs/codes/HttpMethod.js +41 -0
- package/dist/cjs/codes/HttpMethod.js.map +7 -0
- package/dist/cjs/codes/HttpStatus.d.ts +45 -0
- package/dist/cjs/codes/HttpStatus.d.ts.map +1 -0
- package/dist/cjs/codes/HttpStatus.js +49 -0
- package/dist/cjs/codes/HttpStatus.js.map +7 -0
- package/dist/cjs/codes/Mimes.d.ts.map +1 -0
- package/dist/cjs/codes/Mimes.js +57 -0
- package/dist/cjs/codes/Mimes.js.map +7 -0
- package/dist/cjs/codes/index.d.ts +5 -0
- package/dist/cjs/codes/index.d.ts.map +1 -0
- package/dist/cjs/codes/index.js +145 -0
- package/dist/cjs/codes/index.js.map +7 -0
- package/dist/cjs/decorators/MethodMapping.d.ts.map +1 -0
- package/dist/cjs/decorators/MethodMapping.js +265 -0
- package/dist/cjs/decorators/MethodMapping.js.map +7 -0
- package/dist/cjs/decorators/index.d.ts +2 -0
- package/dist/cjs/decorators/index.d.ts.map +1 -0
- package/dist/cjs/decorators/index.js +267 -0
- package/dist/cjs/decorators/index.js.map +7 -0
- package/dist/cjs/endpoints/CrossDomainHeaderEndPoint.d.ts.map +1 -0
- package/dist/cjs/endpoints/CrossDomainHeaderEndPoint.js +55 -0
- package/dist/cjs/endpoints/CrossDomainHeaderEndPoint.js.map +7 -0
- package/dist/cjs/endpoints/EndPoint.d.ts.map +1 -0
- package/dist/cjs/endpoints/EndPoint.js +18 -0
- package/dist/cjs/endpoints/EndPoint.js.map +7 -0
- package/dist/cjs/endpoints/HeaderEndPoint.d.ts.map +1 -0
- package/dist/cjs/endpoints/HeaderEndPoint.js +41 -0
- package/dist/cjs/endpoints/HeaderEndPoint.js.map +7 -0
- package/dist/cjs/endpoints/index.d.ts +4 -0
- package/dist/cjs/endpoints/index.d.ts.map +1 -0
- package/dist/cjs/endpoints/index.js +73 -0
- package/dist/cjs/endpoints/index.js.map +7 -0
- package/dist/cjs/errors/BadRequestError.d.ts.map +1 -0
- package/dist/cjs/errors/BadRequestError.js +45 -0
- package/dist/cjs/errors/BadRequestError.js.map +7 -0
- package/dist/cjs/errors/ForbiddenError.d.ts.map +1 -0
- package/dist/cjs/errors/ForbiddenError.js +45 -0
- package/dist/cjs/errors/ForbiddenError.js.map +7 -0
- package/dist/cjs/errors/HttpError.d.ts.map +1 -0
- package/dist/cjs/errors/HttpError.js +36 -0
- package/dist/cjs/errors/HttpError.js.map +7 -0
- package/dist/cjs/errors/InternalServerError.d.ts.map +1 -0
- package/dist/cjs/errors/InternalServerError.js +45 -0
- package/dist/cjs/errors/InternalServerError.js.map +7 -0
- package/dist/cjs/errors/NotFoundError.d.ts.map +1 -0
- package/dist/cjs/errors/NotFoundError.js +45 -0
- package/dist/cjs/errors/NotFoundError.js.map +7 -0
- package/dist/cjs/errors/UnauthorizedError.d.ts.map +1 -0
- package/dist/cjs/errors/UnauthorizedError.js +45 -0
- package/dist/cjs/errors/UnauthorizedError.js.map +7 -0
- package/dist/cjs/errors/index.d.ts +7 -0
- package/dist/cjs/errors/index.d.ts.map +1 -0
- package/dist/cjs/errors/index.js +83 -0
- package/dist/cjs/errors/index.js.map +7 -0
- package/dist/cjs/filters/CacheFilter.d.ts.map +1 -0
- package/dist/cjs/filters/CacheFilter.js +153 -0
- package/dist/cjs/filters/CacheFilter.js.map +7 -0
- package/dist/cjs/filters/Filter.d.ts.map +1 -0
- package/dist/cjs/filters/Filter.js +18 -0
- package/dist/cjs/filters/Filter.js.map +7 -0
- package/dist/cjs/filters/HttpStatusFilter.d.ts.map +1 -0
- package/dist/cjs/filters/HttpStatusFilter.js +44 -0
- package/dist/cjs/filters/HttpStatusFilter.js.map +7 -0
- package/dist/cjs/filters/OpenApi3Filter.d.ts.map +1 -0
- package/dist/cjs/filters/OpenApi3Filter.js +83 -0
- package/dist/cjs/filters/OpenApi3Filter.js.map +7 -0
- package/dist/cjs/filters/ResourceFilter.d.ts.map +1 -0
- package/dist/cjs/filters/ResourceFilter.js +91 -0
- package/dist/cjs/filters/ResourceFilter.js.map +7 -0
- package/dist/cjs/filters/ThrowFilter.d.ts.map +1 -0
- package/dist/cjs/filters/ThrowFilter.js +47 -0
- package/dist/cjs/filters/ThrowFilter.js.map +7 -0
- package/dist/cjs/filters/index.d.ts +7 -0
- package/dist/cjs/filters/index.d.ts.map +1 -0
- package/dist/cjs/filters/index.js +318 -0
- package/dist/cjs/filters/index.js.map +7 -0
- package/dist/cjs/index.d.ts +13 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +1756 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/inject/InjectSituationType.d.ts.map +1 -0
- package/dist/cjs/inject/InjectSituationType.js +33 -0
- package/dist/cjs/inject/InjectSituationType.js.map +7 -0
- package/dist/cjs/inject/index.d.ts +2 -0
- package/dist/cjs/inject/index.d.ts.map +1 -0
- package/dist/cjs/inject/index.js +35 -0
- package/dist/cjs/inject/index.js.map +7 -0
- package/dist/cjs/lifecycle/OnInit.d.ts.map +1 -0
- package/dist/cjs/lifecycle/OnInit.js +18 -0
- package/dist/cjs/lifecycle/OnInit.js.map +7 -0
- package/dist/cjs/lifecycle/index.d.ts +2 -0
- package/dist/cjs/lifecycle/index.d.ts.map +1 -0
- package/dist/cjs/lifecycle/index.js +18 -0
- package/dist/cjs/lifecycle/index.js.map +7 -0
- package/{models → dist/cjs/models}/RequestResponse.d.ts +1 -3
- package/dist/cjs/models/RequestResponse.d.ts.map +1 -0
- package/dist/cjs/models/RequestResponse.js +500 -0
- package/dist/cjs/models/RequestResponse.js.map +7 -0
- package/dist/cjs/models/datas/HeaderData.d.ts.map +1 -0
- package/dist/cjs/models/datas/HeaderData.js +35 -0
- package/dist/cjs/models/datas/HeaderData.js.map +7 -0
- package/dist/cjs/models/datas/MultipartData.d.ts.map +1 -0
- package/dist/cjs/models/datas/MultipartData.js +18 -0
- package/dist/cjs/models/datas/MultipartData.js.map +7 -0
- package/dist/cjs/models/datas/ReqHeader.d.ts.map +1 -0
- package/dist/cjs/models/datas/ReqHeader.js +31 -0
- package/dist/cjs/models/datas/ReqHeader.js.map +7 -0
- package/dist/cjs/models/datas/Resource.d.ts.map +1 -0
- package/dist/cjs/models/datas/Resource.js +550 -0
- package/dist/cjs/models/datas/Resource.js.map +7 -0
- package/dist/cjs/models/datas/body/ReqFormUrlBody.d.ts.map +1 -0
- package/dist/cjs/models/datas/body/ReqFormUrlBody.js +31 -0
- package/dist/cjs/models/datas/body/ReqFormUrlBody.js.map +7 -0
- package/dist/cjs/models/datas/body/ReqJsonBody.d.ts.map +1 -0
- package/dist/cjs/models/datas/body/ReqJsonBody.js +31 -0
- package/dist/cjs/models/datas/body/ReqJsonBody.js.map +7 -0
- package/dist/cjs/models/datas/body/ReqMultipartFormBody.d.ts.map +1 -0
- package/dist/cjs/models/datas/body/ReqMultipartFormBody.js +34 -0
- package/dist/cjs/models/datas/body/ReqMultipartFormBody.js.map +7 -0
- package/dist/cjs/models/index.d.ts +10 -0
- package/dist/cjs/models/index.d.ts.map +1 -0
- package/dist/cjs/models/index.js +593 -0
- package/dist/cjs/models/index.js.map +7 -0
- package/dist/cjs/models/method/patch/PatchJson.d.ts.map +1 -0
- package/dist/cjs/models/method/patch/PatchJson.js +49 -0
- package/dist/cjs/models/method/patch/PatchJson.js.map +7 -0
- package/dist/cjs/option/HttpServerOption.d.ts.map +1 -0
- package/dist/cjs/option/HttpServerOption.js +67 -0
- package/dist/cjs/option/HttpServerOption.js.map +7 -0
- package/dist/cjs/option/index.d.ts +2 -0
- package/dist/cjs/option/index.d.ts.map +1 -0
- package/dist/cjs/option/index.js +69 -0
- package/dist/cjs/option/index.js.map +7 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/resolvers/Resolver.d.ts.map +1 -0
- package/dist/cjs/resolvers/Resolver.js +18 -0
- package/dist/cjs/resolvers/Resolver.js.map +7 -0
- package/{resolvers/ResourceResorver.d.ts → dist/cjs/resolvers/ResourceResolver.d.ts} +2 -2
- package/dist/cjs/resolvers/ResourceResolver.d.ts.map +1 -0
- package/dist/cjs/resolvers/ResourceResolver.js +571 -0
- package/dist/cjs/resolvers/ResourceResolver.js.map +7 -0
- package/dist/cjs/resolvers/index.d.ts +3 -0
- package/dist/cjs/resolvers/index.d.ts.map +1 -0
- package/dist/cjs/resolvers/index.js +571 -0
- package/dist/cjs/resolvers/index.js.map +7 -0
- package/dist/cjs/session/SessionManager.d.ts.map +1 -0
- package/dist/cjs/session/SessionManager.js +577 -0
- package/dist/cjs/session/SessionManager.js.map +7 -0
- package/dist/cjs/session/index.d.ts +2 -0
- package/dist/cjs/session/index.d.ts.map +1 -0
- package/dist/cjs/session/index.js +579 -0
- package/dist/cjs/session/index.js.map +7 -0
- package/dist/esm/SimpleBootHttpServer.d.ts +14 -0
- package/dist/esm/SimpleBootHttpServer.d.ts.map +1 -0
- package/dist/esm/SimpleBootHttpServer.js +906 -0
- package/dist/esm/SimpleBootHttpServer.js.map +7 -0
- package/dist/esm/codes/HttpHeaders.d.ts +42 -0
- package/dist/esm/codes/HttpHeaders.d.ts.map +1 -0
- package/dist/esm/codes/HttpHeaders.js +47 -0
- package/dist/esm/codes/HttpHeaders.js.map +7 -0
- package/dist/esm/codes/HttpMethod.d.ts +12 -0
- package/dist/esm/codes/HttpMethod.d.ts.map +1 -0
- package/dist/esm/codes/HttpMethod.js +17 -0
- package/dist/esm/codes/HttpMethod.js.map +7 -0
- package/dist/esm/codes/HttpStatus.d.ts +45 -0
- package/dist/esm/codes/HttpStatus.d.ts.map +1 -0
- package/dist/esm/codes/HttpStatus.js +25 -0
- package/dist/esm/codes/HttpStatus.js.map +7 -0
- package/dist/esm/codes/Mimes.d.ts +28 -0
- package/dist/esm/codes/Mimes.d.ts.map +1 -0
- package/dist/esm/codes/Mimes.js +33 -0
- package/dist/esm/codes/Mimes.js.map +7 -0
- package/dist/esm/codes/index.d.ts +5 -0
- package/dist/esm/codes/index.d.ts.map +1 -0
- package/dist/esm/codes/index.js +116 -0
- package/dist/esm/codes/index.js.map +7 -0
- package/dist/esm/decorators/MethodMapping.d.ts +74 -0
- package/dist/esm/decorators/MethodMapping.d.ts.map +1 -0
- package/dist/esm/decorators/MethodMapping.js +211 -0
- package/dist/esm/decorators/MethodMapping.js.map +7 -0
- package/dist/esm/decorators/index.d.ts +2 -0
- package/dist/esm/decorators/index.d.ts.map +1 -0
- package/dist/esm/decorators/index.js +211 -0
- package/dist/esm/decorators/index.js.map +7 -0
- package/dist/esm/endpoints/CrossDomainHeaderEndPoint.d.ts +16 -0
- package/dist/esm/endpoints/CrossDomainHeaderEndPoint.d.ts.map +1 -0
- package/dist/esm/endpoints/CrossDomainHeaderEndPoint.js +31 -0
- package/dist/esm/endpoints/CrossDomainHeaderEndPoint.js.map +7 -0
- package/dist/esm/endpoints/EndPoint.d.ts +7 -0
- package/dist/esm/endpoints/EndPoint.d.ts.map +1 -0
- package/dist/esm/endpoints/EndPoint.js +1 -0
- package/dist/esm/endpoints/EndPoint.js.map +7 -0
- package/dist/esm/endpoints/HeaderEndPoint.d.ts +12 -0
- package/dist/esm/endpoints/HeaderEndPoint.d.ts.map +1 -0
- package/dist/esm/endpoints/HeaderEndPoint.js +17 -0
- package/dist/esm/endpoints/HeaderEndPoint.js.map +7 -0
- package/dist/esm/endpoints/index.d.ts +4 -0
- package/dist/esm/endpoints/index.d.ts.map +1 -0
- package/dist/esm/endpoints/index.js +46 -0
- package/dist/esm/endpoints/index.js.map +7 -0
- package/dist/esm/errors/BadRequestError.d.ts +8 -0
- package/dist/esm/errors/BadRequestError.d.ts.map +1 -0
- package/dist/esm/errors/BadRequestError.js +19 -0
- package/dist/esm/errors/BadRequestError.js.map +7 -0
- package/dist/esm/errors/ForbiddenError.d.ts +8 -0
- package/dist/esm/errors/ForbiddenError.d.ts.map +1 -0
- package/dist/esm/errors/ForbiddenError.js +19 -0
- package/dist/esm/errors/ForbiddenError.js.map +7 -0
- package/dist/esm/errors/HttpError.d.ts +12 -0
- package/dist/esm/errors/HttpError.d.ts.map +1 -0
- package/dist/esm/errors/HttpError.js +12 -0
- package/dist/esm/errors/HttpError.js.map +7 -0
- package/dist/esm/errors/InternalServerError.d.ts +8 -0
- package/dist/esm/errors/InternalServerError.d.ts.map +1 -0
- package/dist/esm/errors/InternalServerError.js +19 -0
- package/dist/esm/errors/InternalServerError.js.map +7 -0
- package/dist/esm/errors/NotFoundError.d.ts +8 -0
- package/dist/esm/errors/NotFoundError.d.ts.map +1 -0
- package/dist/esm/errors/NotFoundError.js +19 -0
- package/dist/esm/errors/NotFoundError.js.map +7 -0
- package/dist/esm/errors/UnauthorizedError.d.ts +8 -0
- package/dist/esm/errors/UnauthorizedError.d.ts.map +1 -0
- package/dist/esm/errors/UnauthorizedError.js +19 -0
- package/dist/esm/errors/UnauthorizedError.js.map +7 -0
- package/dist/esm/errors/index.d.ts +7 -0
- package/dist/esm/errors/index.d.ts.map +1 -0
- package/dist/esm/errors/index.js +52 -0
- package/dist/esm/errors/index.js.map +7 -0
- package/dist/esm/filters/CacheFilter.d.ts +45 -0
- package/dist/esm/filters/CacheFilter.d.ts.map +1 -0
- package/dist/esm/filters/CacheFilter.js +129 -0
- package/dist/esm/filters/CacheFilter.js.map +7 -0
- package/dist/esm/filters/Filter.d.ts +17 -0
- package/dist/esm/filters/Filter.d.ts.map +1 -0
- package/dist/esm/filters/Filter.js +1 -0
- package/dist/esm/filters/Filter.js.map +7 -0
- package/dist/esm/filters/HttpStatusFilter.d.ts +20 -0
- package/dist/esm/filters/HttpStatusFilter.d.ts.map +1 -0
- package/dist/esm/filters/HttpStatusFilter.js +20 -0
- package/dist/esm/filters/HttpStatusFilter.js.map +7 -0
- package/dist/esm/filters/OpenApi3Filter.d.ts +142 -0
- package/dist/esm/filters/OpenApi3Filter.d.ts.map +1 -0
- package/dist/esm/filters/OpenApi3Filter.js +57 -0
- package/dist/esm/filters/OpenApi3Filter.js.map +7 -0
- package/dist/esm/filters/ResourceFilter.d.ts +24 -0
- package/dist/esm/filters/ResourceFilter.d.ts.map +1 -0
- package/dist/esm/filters/ResourceFilter.js +57 -0
- package/dist/esm/filters/ResourceFilter.js.map +7 -0
- package/dist/esm/filters/ThrowFilter.d.ts +19 -0
- package/dist/esm/filters/ThrowFilter.d.ts.map +1 -0
- package/dist/esm/filters/ThrowFilter.js +23 -0
- package/dist/esm/filters/ThrowFilter.js.map +7 -0
- package/dist/esm/filters/index.d.ts +7 -0
- package/dist/esm/filters/index.d.ts.map +1 -0
- package/dist/esm/filters/index.js +278 -0
- package/dist/esm/filters/index.js.map +7 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +1662 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/inject/InjectSituationType.d.ts +4 -0
- package/dist/esm/inject/InjectSituationType.d.ts.map +1 -0
- package/dist/esm/inject/InjectSituationType.js +9 -0
- package/dist/esm/inject/InjectSituationType.js.map +7 -0
- package/dist/esm/inject/index.d.ts +2 -0
- package/dist/esm/inject/index.d.ts.map +1 -0
- package/dist/esm/inject/index.js +9 -0
- package/dist/esm/inject/index.js.map +7 -0
- package/dist/esm/lifecycle/OnInit.d.ts +5 -0
- package/dist/esm/lifecycle/OnInit.d.ts.map +1 -0
- package/dist/esm/lifecycle/OnInit.js +1 -0
- package/dist/esm/lifecycle/OnInit.js.map +7 -0
- package/dist/esm/lifecycle/index.d.ts +2 -0
- package/dist/esm/lifecycle/index.d.ts.map +1 -0
- package/dist/esm/lifecycle/index.js +1 -0
- package/dist/esm/lifecycle/index.js.map +7 -0
- package/dist/esm/models/RequestResponse.d.ts +100 -0
- package/dist/esm/models/RequestResponse.d.ts.map +1 -0
- package/dist/esm/models/RequestResponse.js +475 -0
- package/dist/esm/models/RequestResponse.js.map +7 -0
- package/dist/esm/models/datas/HeaderData.d.ts +10 -0
- package/dist/esm/models/datas/HeaderData.d.ts.map +1 -0
- package/dist/esm/models/datas/HeaderData.js +11 -0
- package/dist/esm/models/datas/HeaderData.js.map +7 -0
- package/dist/esm/models/datas/MultipartData.d.ts +12 -0
- package/dist/esm/models/datas/MultipartData.d.ts.map +1 -0
- package/dist/esm/models/datas/MultipartData.js +1 -0
- package/dist/esm/models/datas/MultipartData.js.map +7 -0
- package/dist/esm/models/datas/ReqHeader.d.ts +68 -0
- package/dist/esm/models/datas/ReqHeader.d.ts.map +1 -0
- package/dist/esm/models/datas/ReqHeader.js +7 -0
- package/dist/esm/models/datas/ReqHeader.js.map +7 -0
- package/dist/esm/models/datas/Resource.d.ts +11 -0
- package/dist/esm/models/datas/Resource.d.ts.map +1 -0
- package/dist/esm/models/datas/Resource.js +516 -0
- package/dist/esm/models/datas/Resource.js.map +7 -0
- package/dist/esm/models/datas/body/ReqFormUrlBody.d.ts +4 -0
- package/dist/esm/models/datas/body/ReqFormUrlBody.d.ts.map +1 -0
- package/dist/esm/models/datas/body/ReqFormUrlBody.js +7 -0
- package/dist/esm/models/datas/body/ReqFormUrlBody.js.map +7 -0
- package/dist/esm/models/datas/body/ReqJsonBody.d.ts +4 -0
- package/dist/esm/models/datas/body/ReqJsonBody.d.ts.map +1 -0
- package/dist/esm/models/datas/body/ReqJsonBody.js +7 -0
- package/dist/esm/models/datas/body/ReqJsonBody.js.map +7 -0
- package/dist/esm/models/datas/body/ReqMultipartFormBody.d.ts +6 -0
- package/dist/esm/models/datas/body/ReqMultipartFormBody.d.ts.map +1 -0
- package/dist/esm/models/datas/body/ReqMultipartFormBody.js +10 -0
- package/dist/esm/models/datas/body/ReqMultipartFormBody.js.map +7 -0
- package/dist/esm/models/index.d.ts +10 -0
- package/dist/esm/models/index.d.ts.map +1 -0
- package/dist/esm/models/index.js +549 -0
- package/dist/esm/models/index.js.map +7 -0
- package/dist/esm/models/method/patch/PatchJson.d.ts +8 -0
- package/dist/esm/models/method/patch/PatchJson.d.ts.map +1 -0
- package/dist/esm/models/method/patch/PatchJson.js +15 -0
- package/dist/esm/models/method/patch/PatchJson.js.map +7 -0
- package/dist/esm/option/HttpServerOption.d.ts +83 -0
- package/dist/esm/option/HttpServerOption.d.ts.map +1 -0
- package/dist/esm/option/HttpServerOption.js +43 -0
- package/dist/esm/option/HttpServerOption.js.map +7 -0
- package/dist/esm/option/index.d.ts +2 -0
- package/dist/esm/option/index.d.ts.map +1 -0
- package/dist/esm/option/index.js +43 -0
- package/dist/esm/option/index.js.map +7 -0
- package/dist/esm/resolvers/Resolver.d.ts +5 -0
- package/dist/esm/resolvers/Resolver.d.ts.map +1 -0
- package/dist/esm/resolvers/Resolver.js +1 -0
- package/dist/esm/resolvers/Resolver.js.map +7 -0
- package/dist/esm/resolvers/ResourceResolver.d.ts +6 -0
- package/dist/esm/resolvers/ResourceResolver.d.ts.map +1 -0
- package/dist/esm/resolvers/ResourceResolver.js +538 -0
- package/dist/esm/resolvers/ResourceResolver.js.map +7 -0
- package/dist/esm/resolvers/index.d.ts +3 -0
- package/dist/esm/resolvers/index.d.ts.map +1 -0
- package/dist/esm/resolvers/index.js +538 -0
- package/dist/esm/resolvers/index.js.map +7 -0
- package/dist/esm/session/SessionManager.d.ts +57 -0
- package/dist/esm/session/SessionManager.d.ts.map +1 -0
- package/dist/esm/session/SessionManager.js +553 -0
- package/dist/esm/session/SessionManager.js.map +7 -0
- package/dist/esm/session/index.d.ts +2 -0
- package/dist/esm/session/index.d.ts.map +1 -0
- package/dist/esm/session/index.js +553 -0
- package/dist/esm/session/index.js.map +7 -0
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +1662 -0
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +7 -0
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +1699 -0
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +7 -0
- package/package.json +65 -46
- package/SimpleBootHttpServer.js +0 -313
- package/codes/HttpHeaders.js +0 -43
- package/codes/HttpMethod.js +0 -13
- package/codes/HttpStatus.d.ts +0 -20
- package/codes/HttpStatus.js +0 -21
- package/codes/Mimes.js +0 -29
- package/decorators/MethodMapping.js +0 -198
- package/endpoints/CrossDomainHeaderEndPoint.js +0 -37
- package/endpoints/EndPoint.js +0 -2
- package/endpoints/HeaderEndPoint.js +0 -26
- package/errors/BadRequestError.js +0 -8
- package/errors/ForbiddenError.js +0 -8
- package/errors/HttpError.js +0 -8
- package/errors/InternalServerError.js +0 -8
- package/errors/NotFoundError.js +0 -8
- package/errors/UnauthorizedError.js +0 -8
- package/filters/CacheFilter.js +0 -145
- package/filters/Filter.js +0 -2
- package/filters/HttpStatusFilter.js +0 -31
- package/filters/OpenApi3Filter.js +0 -57
- package/filters/ResourceFilter.js +0 -72
- package/filters/ThrowFilter.js +0 -34
- package/inject/InjectSituationType.js +0 -5
- package/lifecycle/OnInit.js +0 -2
- package/models/RequestResponse.js +0 -467
- package/models/datas/HeaderData.js +0 -7
- package/models/datas/MultipartData.js +0 -2
- package/models/datas/ReqHeader.js +0 -3
- package/models/datas/Resource.js +0 -55
- package/models/datas/body/ReqFormUrlBody.js +0 -3
- package/models/datas/body/ReqJsonBody.js +0 -3
- package/models/datas/body/ReqMultipartFormBody.js +0 -6
- package/models/method/patch/PatchJson.js +0 -11
- package/option/HttpServerOption.js +0 -35
- package/resolvers/Resolver.js +0 -2
- package/resolvers/ResourceResorver.js +0 -18
- package/session/SessionManager.js +0 -108
- /package/{SimpleBootHttpServer.d.ts → dist/cjs/SimpleBootHttpServer.d.ts} +0 -0
- /package/{codes → dist/cjs/codes}/HttpHeaders.d.ts +0 -0
- /package/{codes → dist/cjs/codes}/HttpMethod.d.ts +0 -0
- /package/{codes → dist/cjs/codes}/Mimes.d.ts +0 -0
- /package/{decorators → dist/cjs/decorators}/MethodMapping.d.ts +0 -0
- /package/{endpoints → dist/cjs/endpoints}/CrossDomainHeaderEndPoint.d.ts +0 -0
- /package/{endpoints → dist/cjs/endpoints}/EndPoint.d.ts +0 -0
- /package/{endpoints → dist/cjs/endpoints}/HeaderEndPoint.d.ts +0 -0
- /package/{errors → dist/cjs/errors}/BadRequestError.d.ts +0 -0
- /package/{errors → dist/cjs/errors}/ForbiddenError.d.ts +0 -0
- /package/{errors → dist/cjs/errors}/HttpError.d.ts +0 -0
- /package/{errors → dist/cjs/errors}/InternalServerError.d.ts +0 -0
- /package/{errors → dist/cjs/errors}/NotFoundError.d.ts +0 -0
- /package/{errors → dist/cjs/errors}/UnauthorizedError.d.ts +0 -0
- /package/{filters → dist/cjs/filters}/CacheFilter.d.ts +0 -0
- /package/{filters → dist/cjs/filters}/Filter.d.ts +0 -0
- /package/{filters → dist/cjs/filters}/HttpStatusFilter.d.ts +0 -0
- /package/{filters → dist/cjs/filters}/OpenApi3Filter.d.ts +0 -0
- /package/{filters → dist/cjs/filters}/ResourceFilter.d.ts +0 -0
- /package/{filters → dist/cjs/filters}/ThrowFilter.d.ts +0 -0
- /package/{inject → dist/cjs/inject}/InjectSituationType.d.ts +0 -0
- /package/{lifecycle → dist/cjs/lifecycle}/OnInit.d.ts +0 -0
- /package/{models → dist/cjs/models}/datas/HeaderData.d.ts +0 -0
- /package/{models → dist/cjs/models}/datas/MultipartData.d.ts +0 -0
- /package/{models → dist/cjs/models}/datas/ReqHeader.d.ts +0 -0
- /package/{models → dist/cjs/models}/datas/Resource.d.ts +0 -0
- /package/{models → dist/cjs/models}/datas/body/ReqFormUrlBody.d.ts +0 -0
- /package/{models → dist/cjs/models}/datas/body/ReqJsonBody.d.ts +0 -0
- /package/{models → dist/cjs/models}/datas/body/ReqMultipartFormBody.d.ts +0 -0
- /package/{models → dist/cjs/models}/method/patch/PatchJson.d.ts +0 -0
- /package/{option → dist/cjs/option}/HttpServerOption.d.ts +0 -0
- /package/{resolvers → dist/cjs/resolvers}/Resolver.d.ts +0 -0
- /package/{session → dist/cjs/session}/SessionManager.d.ts +0 -0
|
@@ -0,0 +1,1756 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
29
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
30
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
31
|
+
if (decorator = decorators[i])
|
|
32
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
33
|
+
if (kind && result) __defProp(target, key, result);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/index.ts
|
|
38
|
+
var src_exports = {};
|
|
39
|
+
__export(src_exports, {
|
|
40
|
+
BadRequestError: () => BadRequestError,
|
|
41
|
+
CONNECT: () => CONNECT,
|
|
42
|
+
CacheFilter: () => CacheFilter,
|
|
43
|
+
CrossDomainHeaderEndPoint: () => CrossDomainHeaderEndPoint,
|
|
44
|
+
DELETE: () => DELETE,
|
|
45
|
+
ForbiddenError: () => ForbiddenError,
|
|
46
|
+
GET: () => GET,
|
|
47
|
+
HEAD: () => HEAD,
|
|
48
|
+
HeaderData: () => HeaderData,
|
|
49
|
+
HeaderEndPoint: () => HeaderEndPoint,
|
|
50
|
+
HttpError: () => HttpError,
|
|
51
|
+
HttpHeaders: () => HttpHeaders,
|
|
52
|
+
HttpMethod: () => HttpMethod,
|
|
53
|
+
HttpServerOption: () => HttpServerOption,
|
|
54
|
+
HttpStatus: () => HttpStatus,
|
|
55
|
+
HttpStatusFilter: () => HttpStatusFilter,
|
|
56
|
+
InjectSituationType: () => InjectSituationType,
|
|
57
|
+
InternalServerError: () => InternalServerError,
|
|
58
|
+
Mimes: () => Mimes,
|
|
59
|
+
NotFoundError: () => NotFoundError,
|
|
60
|
+
OPTIONS: () => OPTIONS,
|
|
61
|
+
OpenApi3Filter: () => OpenApi3Filter,
|
|
62
|
+
PATCH: () => PATCH,
|
|
63
|
+
POST: () => POST,
|
|
64
|
+
PUT: () => PUT,
|
|
65
|
+
PatchJson: () => PatchJson,
|
|
66
|
+
ReqFormUrlBody: () => ReqFormUrlBody,
|
|
67
|
+
ReqHeader: () => ReqHeader,
|
|
68
|
+
ReqJsonBody: () => ReqJsonBody,
|
|
69
|
+
ReqMultipartFormBody: () => ReqMultipartFormBody,
|
|
70
|
+
RequestResponse: () => RequestResponse,
|
|
71
|
+
RequestResponseChain: () => RequestResponseChain,
|
|
72
|
+
Resource: () => Resource,
|
|
73
|
+
ResourceFilter: () => ResourceFilter,
|
|
74
|
+
ResourceResolver: () => ResourceResolver,
|
|
75
|
+
SessionManager: () => SessionManager,
|
|
76
|
+
SimpleBootHttpServer: () => SimpleBootHttpServer,
|
|
77
|
+
TRACE: () => TRACE,
|
|
78
|
+
ThrowFilter: () => ThrowFilter,
|
|
79
|
+
UnauthorizedError: () => UnauthorizedError,
|
|
80
|
+
UrlMapping: () => UrlMapping,
|
|
81
|
+
UrlMappingSituationType: () => UrlMappingSituationType,
|
|
82
|
+
getCONNECT: () => getCONNECT,
|
|
83
|
+
getCONNECTS: () => getCONNECTS,
|
|
84
|
+
getDELETE: () => getDELETE,
|
|
85
|
+
getDELETES: () => getDELETES,
|
|
86
|
+
getGET: () => getGET,
|
|
87
|
+
getGETS: () => getGETS,
|
|
88
|
+
getHEAD: () => getHEAD,
|
|
89
|
+
getHEADS: () => getHEADS,
|
|
90
|
+
getOPTIONS: () => getOPTIONS,
|
|
91
|
+
getOPTIONSS: () => getOPTIONSS,
|
|
92
|
+
getPATCH: () => getPATCH,
|
|
93
|
+
getPATCHS: () => getPATCHS,
|
|
94
|
+
getPOST: () => getPOST,
|
|
95
|
+
getPOSTS: () => getPOSTS,
|
|
96
|
+
getPUT: () => getPUT,
|
|
97
|
+
getPUTS: () => getPUTS,
|
|
98
|
+
getTRACE: () => getTRACE,
|
|
99
|
+
getTRACES: () => getTRACES,
|
|
100
|
+
getUrlMapping: () => getUrlMapping,
|
|
101
|
+
getUrlMappings: () => getUrlMappings
|
|
102
|
+
});
|
|
103
|
+
module.exports = __toCommonJS(src_exports);
|
|
104
|
+
|
|
105
|
+
// src/SimpleBootHttpServer.ts
|
|
106
|
+
var import_SimpleApplication = require("@dooboostore/simple-boot/SimpleApplication");
|
|
107
|
+
|
|
108
|
+
// src/option/HttpServerOption.ts
|
|
109
|
+
var import_SimOption = require("@dooboostore/simple-boot/SimOption");
|
|
110
|
+
var HttpServerOption = class _HttpServerOption extends import_SimOption.SimOption {
|
|
111
|
+
static {
|
|
112
|
+
this.DEFAULT_PORT = 8081;
|
|
113
|
+
}
|
|
114
|
+
static {
|
|
115
|
+
this.DEFAULT_HOSTNAME = "127.0.0.1";
|
|
116
|
+
}
|
|
117
|
+
constructor({ serverOption, listen, filters, requestEndPoints, closeEndPoints, errorEndPoints, sessionOption, globalAdvice, fileUploadTempPath, noSuchRouteEndPointMappingThrow, transactionManagerFactory } = {}, initSimOption) {
|
|
118
|
+
super(initSimOption);
|
|
119
|
+
this.serverOption = serverOption;
|
|
120
|
+
this.listen = Object.assign({ port: _HttpServerOption.DEFAULT_PORT, hostname: _HttpServerOption.DEFAULT_HOSTNAME }, listen);
|
|
121
|
+
this.filters = filters;
|
|
122
|
+
this.requestEndPoints = requestEndPoints;
|
|
123
|
+
this.closeEndPoints = closeEndPoints;
|
|
124
|
+
this.errorEndPoints = errorEndPoints;
|
|
125
|
+
this.sessionOption = Object.assign({ key: "SBSESSIONID", expiredTime: 1e3 * 60 * 30 }, sessionOption);
|
|
126
|
+
this.globalAdvice = globalAdvice;
|
|
127
|
+
this.fileUploadTempPath = fileUploadTempPath;
|
|
128
|
+
this.noSuchRouteEndPointMappingThrow = noSuchRouteEndPointMappingThrow;
|
|
129
|
+
this.transactionManagerFactory = transactionManagerFactory;
|
|
130
|
+
}
|
|
131
|
+
get hostname() {
|
|
132
|
+
return this.listen.hostname;
|
|
133
|
+
}
|
|
134
|
+
get port() {
|
|
135
|
+
return this.listen.port;
|
|
136
|
+
}
|
|
137
|
+
get protocol() {
|
|
138
|
+
return this.isSecure ? "https" : "http";
|
|
139
|
+
}
|
|
140
|
+
get address() {
|
|
141
|
+
return `${this.protocol}://${this.hostname}:${this.port}`;
|
|
142
|
+
}
|
|
143
|
+
get isSecure() {
|
|
144
|
+
return this.serverOption && "key" in this.serverOption && "cert" in this.serverOption;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/SimpleBootHttpServer.ts
|
|
149
|
+
var import_http = require("http");
|
|
150
|
+
var import_https = require("https");
|
|
151
|
+
|
|
152
|
+
// src/codes/HttpHeaders.ts
|
|
153
|
+
var HttpHeaders = /* @__PURE__ */ ((HttpHeaders2) => {
|
|
154
|
+
HttpHeaders2["ContentLength"] = "Content-Length";
|
|
155
|
+
HttpHeaders2["ContentType"] = "Content-Type";
|
|
156
|
+
HttpHeaders2["ContentEncoding"] = "Content-Encoding";
|
|
157
|
+
HttpHeaders2["Accept"] = "Accept";
|
|
158
|
+
HttpHeaders2["Authorization"] = "Authorization";
|
|
159
|
+
HttpHeaders2["CacheControl"] = "Cache-Control";
|
|
160
|
+
HttpHeaders2["Connection"] = "Connection";
|
|
161
|
+
HttpHeaders2["Date"] = "Date";
|
|
162
|
+
HttpHeaders2["Host"] = "Host";
|
|
163
|
+
HttpHeaders2["Pragma"] = "Pragma";
|
|
164
|
+
HttpHeaders2["Trailer"] = "Trailer";
|
|
165
|
+
HttpHeaders2["TransferEncoding"] = "Transfer-Encoding";
|
|
166
|
+
HttpHeaders2["Upgrade"] = "Upgrade";
|
|
167
|
+
HttpHeaders2["Via"] = "Via";
|
|
168
|
+
HttpHeaders2["Warning"] = "Warning";
|
|
169
|
+
HttpHeaders2["AcceptCharset"] = "Accept-Charset";
|
|
170
|
+
HttpHeaders2["AcceptEncoding"] = "Accept-Encoding";
|
|
171
|
+
HttpHeaders2["AcceptLanguage"] = "Accept-Language";
|
|
172
|
+
HttpHeaders2["AccessControlAllowOrigin"] = "Access-Control-Allow-Origin";
|
|
173
|
+
HttpHeaders2["AccessControlAllowMethods"] = "Access-Control-Allow-Methods";
|
|
174
|
+
HttpHeaders2["AccessControlAllowHeaders"] = "Access-Control-Allow-Headers";
|
|
175
|
+
HttpHeaders2["AccessControlExposeHeaders"] = "Access-Control-Expose-Headers";
|
|
176
|
+
HttpHeaders2["Expect"] = "Expect";
|
|
177
|
+
HttpHeaders2["From"] = "From";
|
|
178
|
+
HttpHeaders2["MaxForwards"] = "Max-Forwards";
|
|
179
|
+
HttpHeaders2["Referer"] = "Referer";
|
|
180
|
+
HttpHeaders2["UserAgent"] = "User-Agent";
|
|
181
|
+
HttpHeaders2["Cookie"] = "Cookie";
|
|
182
|
+
HttpHeaders2["SetCookie"] = "Set-Cookie";
|
|
183
|
+
HttpHeaders2["Cookie2"] = "Cookie2";
|
|
184
|
+
HttpHeaders2["SetCookie2"] = "Set-Cookie2";
|
|
185
|
+
HttpHeaders2["Location"] = "Location";
|
|
186
|
+
HttpHeaders2["IfModifiedSince"] = "If-Modified-Since";
|
|
187
|
+
HttpHeaders2["IfUnmodifiedSince"] = "If-Unmodified-Since";
|
|
188
|
+
HttpHeaders2["IfMatch"] = "If-Match";
|
|
189
|
+
HttpHeaders2["IfNoneMatch"] = "If-None-Match";
|
|
190
|
+
HttpHeaders2["IfRange"] = "If-Range";
|
|
191
|
+
HttpHeaders2["Allow"] = "Allow";
|
|
192
|
+
HttpHeaders2["Server"] = "Server";
|
|
193
|
+
return HttpHeaders2;
|
|
194
|
+
})(HttpHeaders || {});
|
|
195
|
+
|
|
196
|
+
// src/models/RequestResponse.ts
|
|
197
|
+
var import_Intent = require("@dooboostore/simple-boot/intent/Intent");
|
|
198
|
+
var import_url = require("url");
|
|
199
|
+
var import_buffer = require("buffer");
|
|
200
|
+
|
|
201
|
+
// src/models/datas/body/ReqFormUrlBody.ts
|
|
202
|
+
var ReqFormUrlBody = class {
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// src/models/datas/body/ReqJsonBody.ts
|
|
206
|
+
var ReqJsonBody = class {
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/models/datas/ReqHeader.ts
|
|
210
|
+
var ReqHeader = class {
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// src/models/RequestResponse.ts
|
|
214
|
+
var import_node_gzip = require("node-gzip");
|
|
215
|
+
var import_FileUtils = require("@dooboostore/core-node/file/FileUtils");
|
|
216
|
+
var import_ConvertUtils = require("@dooboostore/core/convert/ConvertUtils");
|
|
217
|
+
var import_ConvertUtils2 = require("@dooboostore/core-node/convert/ConvertUtils");
|
|
218
|
+
var RequestResponse = class _RequestResponse {
|
|
219
|
+
// protected sessionManager?: SessionManager;
|
|
220
|
+
// constructor(req: IncomingMessage, res: ServerResponse);
|
|
221
|
+
// constructor(req: RequestResponse);
|
|
222
|
+
// constructor(req: IncomingMessage, res: ServerResponse, sessionManager?: SessionManager);
|
|
223
|
+
// constructor(req: IncomingMessage | RequestResponse, res?: ServerResponse, sessionManager?: SessionManager) {
|
|
224
|
+
// // this.req = req;
|
|
225
|
+
// // this.res = res;
|
|
226
|
+
// if (req instanceof RequestResponse) {
|
|
227
|
+
// this.req = req.req;
|
|
228
|
+
// this.res = req.res;
|
|
229
|
+
// this.sessionManager = req.sessionManager;
|
|
230
|
+
// } else {
|
|
231
|
+
// this.req = req;
|
|
232
|
+
// this.res = res!;
|
|
233
|
+
// this.sessionManager = sessionManager;
|
|
234
|
+
// }
|
|
235
|
+
// }
|
|
236
|
+
constructor(req, res, config) {
|
|
237
|
+
if (req instanceof _RequestResponse) {
|
|
238
|
+
this.req = req.req;
|
|
239
|
+
this.res = req.res;
|
|
240
|
+
this.config = config;
|
|
241
|
+
} else {
|
|
242
|
+
this.req = req;
|
|
243
|
+
this.res = res;
|
|
244
|
+
this.config = config;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
get reqSocket() {
|
|
248
|
+
return this.req.socket;
|
|
249
|
+
}
|
|
250
|
+
get reqCookieMap() {
|
|
251
|
+
let cookies = this.reqHeader("Cookie" /* Cookie */) ?? "";
|
|
252
|
+
if (Array.isArray(cookies)) {
|
|
253
|
+
cookies = cookies.join(";");
|
|
254
|
+
}
|
|
255
|
+
const map = /* @__PURE__ */ new Map();
|
|
256
|
+
cookies.split(";").map((it) => it.trim().split("=")).forEach((it) => {
|
|
257
|
+
map.set(it[0], it[1]);
|
|
258
|
+
});
|
|
259
|
+
return map;
|
|
260
|
+
}
|
|
261
|
+
reqCookieGet(key) {
|
|
262
|
+
return this.reqCookieMap.get(key);
|
|
263
|
+
}
|
|
264
|
+
get reqRemoteAddress() {
|
|
265
|
+
const ipHeader = this.req.headers["x-forwarded-for"];
|
|
266
|
+
let ip = this.req.socket.remoteAddress;
|
|
267
|
+
if (Array.isArray(ipHeader)) {
|
|
268
|
+
ip = ipHeader.join(",").split(",").shift();
|
|
269
|
+
} else if (typeof ipHeader === "string") {
|
|
270
|
+
ip = ipHeader.split(",").shift();
|
|
271
|
+
}
|
|
272
|
+
return ip;
|
|
273
|
+
}
|
|
274
|
+
get reqUrlObject() {
|
|
275
|
+
return new import_url.URL(this.reqUrl, `${this.reqSocket ? "https://" : "http"}${this.reqHost ?? "localhost"}`);
|
|
276
|
+
}
|
|
277
|
+
get reqUrlPathName() {
|
|
278
|
+
return this.reqUrlObj().pathname ?? "";
|
|
279
|
+
}
|
|
280
|
+
get reqUrl() {
|
|
281
|
+
return this.req.url ?? "";
|
|
282
|
+
}
|
|
283
|
+
reqUrlObj(config) {
|
|
284
|
+
return new import_url.URL(`${config?.scheme ?? "http"}://${config?.host ? config?.host : this.reqHeaderFirst("Host" /* Host */) ?? "localhost"}${this.req.url ?? ""}`);
|
|
285
|
+
}
|
|
286
|
+
get reqUrlSearchParamTuples() {
|
|
287
|
+
return Array.from(this.reqUrlObj().searchParams);
|
|
288
|
+
}
|
|
289
|
+
get reqUrlSearchParams() {
|
|
290
|
+
return this.reqUrlObj().searchParams;
|
|
291
|
+
}
|
|
292
|
+
get reqUrlSearchParamsObj() {
|
|
293
|
+
const entries = this.reqUrlObj().searchParams;
|
|
294
|
+
return import_ConvertUtils.ConvertUtils.toObject(entries);
|
|
295
|
+
}
|
|
296
|
+
get reqPathSearchParamUrl() {
|
|
297
|
+
const reqUrlObj = this.reqUrlObj();
|
|
298
|
+
return reqUrlObj.pathname + (reqUrlObj.searchParams.toString() ? "?" + reqUrlObj.searchParams.toString() : "");
|
|
299
|
+
}
|
|
300
|
+
get reqReadable() {
|
|
301
|
+
return this.req.readable;
|
|
302
|
+
}
|
|
303
|
+
get reqIntent() {
|
|
304
|
+
return new import_Intent.Intent(this.reqPathSearchParamUrl);
|
|
305
|
+
}
|
|
306
|
+
reqHasContentTypeHeader(mime3) {
|
|
307
|
+
return (this.reqHeaderFirst("Content-Type" /* ContentType */) ?? "").toLowerCase().indexOf(mime3.toLocaleLowerCase()) > -1;
|
|
308
|
+
}
|
|
309
|
+
reqHasAcceptHeader(mime3) {
|
|
310
|
+
return (this.reqHeaderFirst("Accept" /* Accept */) ?? "").toLowerCase().indexOf(mime3.toLocaleLowerCase()) > -1;
|
|
311
|
+
}
|
|
312
|
+
reqBodyData() {
|
|
313
|
+
return new Promise((resolve, reject) => {
|
|
314
|
+
if (this.reqReadable) {
|
|
315
|
+
const data = [];
|
|
316
|
+
this.req.on("data", (chunk) => data.push(chunk));
|
|
317
|
+
this.req.on("error", (err) => reject(err));
|
|
318
|
+
this.req.on("end", () => {
|
|
319
|
+
this.reqBodyChunk = import_buffer.Buffer.concat(data);
|
|
320
|
+
resolve(this.reqBodyChunk);
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
resolve(this.reqBodyChunk ?? import_buffer.Buffer.alloc(0));
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
resBodyData() {
|
|
328
|
+
return this.resWriteChunk;
|
|
329
|
+
}
|
|
330
|
+
async reqBodyMultipartFormDataObject() {
|
|
331
|
+
const m = await this.reqBodyMultipartFormData();
|
|
332
|
+
const formData = {};
|
|
333
|
+
for (const it of m) {
|
|
334
|
+
if (it.isFile) {
|
|
335
|
+
formData[it.name] = await import_FileUtils.FileUtils.writeFile(it.value, { originalName: it.filename });
|
|
336
|
+
} else {
|
|
337
|
+
const target = formData[it.name];
|
|
338
|
+
if (Array.isArray(target)) {
|
|
339
|
+
target.push(it.value);
|
|
340
|
+
} else if (typeof target === "string") {
|
|
341
|
+
formData[it.name] = [target, it.value];
|
|
342
|
+
} else {
|
|
343
|
+
formData[it.name] = it.value;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
;
|
|
348
|
+
return formData;
|
|
349
|
+
}
|
|
350
|
+
reqBodyMultipartFormData() {
|
|
351
|
+
return new Promise((resolve, reject) => {
|
|
352
|
+
const contentTypeHeader = this.req.headers["content-type"];
|
|
353
|
+
if (!contentTypeHeader || !contentTypeHeader.startsWith("multipart/form-data")) {
|
|
354
|
+
return reject(new Error("Invalid Content-Type. Expected multipart/form-data."));
|
|
355
|
+
}
|
|
356
|
+
const boundaryMatch = contentTypeHeader.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
|
357
|
+
if (!boundaryMatch) {
|
|
358
|
+
return reject(new Error("Boundary not found in Content-Type header."));
|
|
359
|
+
}
|
|
360
|
+
const boundary = boundaryMatch[1] || boundaryMatch[2];
|
|
361
|
+
if (!boundary) {
|
|
362
|
+
return reject(new Error("Failed to extract boundary."));
|
|
363
|
+
}
|
|
364
|
+
const boundaryBuffer = import_buffer.Buffer.from(`--${boundary}`);
|
|
365
|
+
const crlfBuffer = import_buffer.Buffer.from("\r\n");
|
|
366
|
+
const doubleCrlfBuffer = import_buffer.Buffer.from("\r\n\r\n");
|
|
367
|
+
const chunks = [];
|
|
368
|
+
let totalLength = 0;
|
|
369
|
+
this.req.on("data", (chunk) => {
|
|
370
|
+
chunks.push(chunk);
|
|
371
|
+
totalLength += chunk.length;
|
|
372
|
+
});
|
|
373
|
+
this.req.on("error", (err) => {
|
|
374
|
+
reject(err);
|
|
375
|
+
});
|
|
376
|
+
this.req.on("end", () => {
|
|
377
|
+
if (totalLength === 0) {
|
|
378
|
+
return resolve([]);
|
|
379
|
+
}
|
|
380
|
+
const fullBuffer = import_buffer.Buffer.concat(chunks, totalLength);
|
|
381
|
+
const parsedParts = [];
|
|
382
|
+
let currentPosition = 0;
|
|
383
|
+
let boundaryStartIndex = fullBuffer.indexOf(boundaryBuffer, currentPosition);
|
|
384
|
+
if (boundaryStartIndex === -1) {
|
|
385
|
+
return reject(new Error("Initial boundary not found."));
|
|
386
|
+
}
|
|
387
|
+
currentPosition = boundaryStartIndex + boundaryBuffer.length;
|
|
388
|
+
if (fullBuffer.slice(currentPosition, currentPosition + crlfBuffer.length).equals(crlfBuffer)) {
|
|
389
|
+
currentPosition += crlfBuffer.length;
|
|
390
|
+
}
|
|
391
|
+
while (currentPosition < fullBuffer.length) {
|
|
392
|
+
const nextBoundaryIndex = fullBuffer.indexOf(boundaryBuffer, currentPosition);
|
|
393
|
+
if (nextBoundaryIndex === -1) {
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
let partEndIndex = nextBoundaryIndex;
|
|
397
|
+
if (partEndIndex > crlfBuffer.length && fullBuffer.slice(partEndIndex - crlfBuffer.length, partEndIndex).equals(crlfBuffer)) {
|
|
398
|
+
partEndIndex -= crlfBuffer.length;
|
|
399
|
+
}
|
|
400
|
+
const partBuffer = fullBuffer.slice(currentPosition, partEndIndex);
|
|
401
|
+
const headerBodySeparatorIndex = partBuffer.indexOf(doubleCrlfBuffer);
|
|
402
|
+
if (headerBodySeparatorIndex === -1) {
|
|
403
|
+
console.warn("Skipping malformed part: no header/body separator found.");
|
|
404
|
+
currentPosition = nextBoundaryIndex + boundaryBuffer.length;
|
|
405
|
+
if (fullBuffer.slice(currentPosition, currentPosition + crlfBuffer.length).equals(crlfBuffer)) {
|
|
406
|
+
currentPosition += crlfBuffer.length;
|
|
407
|
+
}
|
|
408
|
+
if (fullBuffer.slice(currentPosition, currentPosition + 2).toString() === "--") break;
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
const headerBuffer = partBuffer.slice(0, headerBodySeparatorIndex);
|
|
412
|
+
const bodyBuffer = partBuffer.slice(headerBodySeparatorIndex + doubleCrlfBuffer.length);
|
|
413
|
+
const headersStr = headerBuffer.toString("utf-8");
|
|
414
|
+
const headers = {};
|
|
415
|
+
headersStr.split("\r\n").forEach((line) => {
|
|
416
|
+
const colonIndex = line.indexOf(":");
|
|
417
|
+
if (colonIndex > 0) {
|
|
418
|
+
const key = line.substring(0, colonIndex).trim().toLowerCase();
|
|
419
|
+
const value = line.substring(colonIndex + 1).trim();
|
|
420
|
+
headers[key] = value;
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
const contentDisposition = headers["content-disposition"];
|
|
424
|
+
if (!contentDisposition) {
|
|
425
|
+
console.warn("Skipping part: no Content-Disposition header.");
|
|
426
|
+
currentPosition = nextBoundaryIndex + boundaryBuffer.length;
|
|
427
|
+
if (fullBuffer.slice(currentPosition, currentPosition + crlfBuffer.length).equals(crlfBuffer)) {
|
|
428
|
+
currentPosition += crlfBuffer.length;
|
|
429
|
+
}
|
|
430
|
+
if (fullBuffer.slice(currentPosition, currentPosition + 2).toString() === "--") break;
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
const nameMatch = contentDisposition.match(/name="([^"]+)"/i);
|
|
434
|
+
const filenameMatch = contentDisposition.match(/filename="([^"]+)"/i);
|
|
435
|
+
const name = nameMatch ? nameMatch[1] : null;
|
|
436
|
+
const filename = filenameMatch ? filenameMatch[1] : null;
|
|
437
|
+
const contentType = headers["content-type"] || null;
|
|
438
|
+
if (name) {
|
|
439
|
+
const isFile = !!filename;
|
|
440
|
+
const multipartData = {
|
|
441
|
+
name,
|
|
442
|
+
isFile,
|
|
443
|
+
// filename이 있으면 파일로 간주
|
|
444
|
+
filename,
|
|
445
|
+
contentType,
|
|
446
|
+
value: isFile ? bodyBuffer : bodyBuffer.toString("utf-8")
|
|
447
|
+
};
|
|
448
|
+
parsedParts.push(multipartData);
|
|
449
|
+
} else {
|
|
450
|
+
console.warn("Skipping part: 'name' not found in Content-Disposition.");
|
|
451
|
+
}
|
|
452
|
+
currentPosition = nextBoundaryIndex + boundaryBuffer.length;
|
|
453
|
+
if (fullBuffer.slice(currentPosition, currentPosition + crlfBuffer.length).equals(crlfBuffer)) {
|
|
454
|
+
currentPosition += crlfBuffer.length;
|
|
455
|
+
}
|
|
456
|
+
if (fullBuffer.slice(currentPosition, currentPosition + 2).toString() === "--") {
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
resolve(parsedParts);
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
async reqBodyStringData() {
|
|
465
|
+
const data = (await this.reqBodyData()).toString();
|
|
466
|
+
return data;
|
|
467
|
+
}
|
|
468
|
+
async reqBodyJsonData() {
|
|
469
|
+
return JSON.parse(await this.reqBodyStringData());
|
|
470
|
+
}
|
|
471
|
+
async reqBodyFormUrlData() {
|
|
472
|
+
const data = await this.reqBodyStringData();
|
|
473
|
+
const formData = {};
|
|
474
|
+
Array.from(new import_url.URLSearchParams(data).entries()).forEach(([k, v]) => {
|
|
475
|
+
const target = formData[k];
|
|
476
|
+
if (Array.isArray(target)) {
|
|
477
|
+
target.push(v);
|
|
478
|
+
} else if (typeof target === "string") {
|
|
479
|
+
formData[k] = [target, v];
|
|
480
|
+
} else {
|
|
481
|
+
formData[k] = v;
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
return formData;
|
|
485
|
+
}
|
|
486
|
+
async reqBodyReqFormUrlBody() {
|
|
487
|
+
const data = await this.reqBodyFormUrlData();
|
|
488
|
+
return Object.assign(new ReqFormUrlBody(), data);
|
|
489
|
+
}
|
|
490
|
+
async reqBodyReqJsonBody() {
|
|
491
|
+
const data = await this.reqBodyStringData();
|
|
492
|
+
return Object.assign(new ReqJsonBody(), data ? JSON.parse(data) : {});
|
|
493
|
+
}
|
|
494
|
+
// reqBodyReqMultipartFormBody(): Promise<ReqMultipartFormBody> {
|
|
495
|
+
// return this.reqBodyMultipartFormData().then(it => new ReqMultipartFormBody(it))
|
|
496
|
+
// }
|
|
497
|
+
resBodyJsonData() {
|
|
498
|
+
const data = import_ConvertUtils2.ConvertUtils.toString(this.resBodyData());
|
|
499
|
+
return data ? JSON.parse(data) : null;
|
|
500
|
+
}
|
|
501
|
+
resBodyStringData() {
|
|
502
|
+
return import_ConvertUtils2.ConvertUtils.toString(this.resBodyData());
|
|
503
|
+
}
|
|
504
|
+
reqMethod() {
|
|
505
|
+
return this.req.method?.toUpperCase();
|
|
506
|
+
}
|
|
507
|
+
reqHeader(key) {
|
|
508
|
+
return this.req.headers[key.toLowerCase()];
|
|
509
|
+
}
|
|
510
|
+
get reqHost() {
|
|
511
|
+
return this.reqHeaderFirst("Host" /* Host */);
|
|
512
|
+
}
|
|
513
|
+
get reqHeaderObj() {
|
|
514
|
+
const h = new ReqHeader();
|
|
515
|
+
Object.entries(this.req.headers).forEach(([k, v]) => {
|
|
516
|
+
h[k] = v;
|
|
517
|
+
});
|
|
518
|
+
return h;
|
|
519
|
+
}
|
|
520
|
+
reqHeaderFirst(key, defaultValue) {
|
|
521
|
+
const header = this.req.headers[key.toLowerCase()];
|
|
522
|
+
if (header && Array.isArray(header)) {
|
|
523
|
+
return header[0] ?? defaultValue;
|
|
524
|
+
} else {
|
|
525
|
+
return header ?? defaultValue;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
reqAuthorizationHeader() {
|
|
529
|
+
return this.reqHeaderFirst("Authorization" /* Authorization */);
|
|
530
|
+
}
|
|
531
|
+
reqRefreshTokenHeader() {
|
|
532
|
+
return this.reqHeaderFirst("Authorization" /* Authorization */);
|
|
533
|
+
}
|
|
534
|
+
// eslint-disable-next-line no-dupe-class-members
|
|
535
|
+
resStatusCode(code) {
|
|
536
|
+
if (code) {
|
|
537
|
+
this.res.statusCode = code;
|
|
538
|
+
return new RequestResponseChain(this.req, this.res, this.config, this.res.statusCode);
|
|
539
|
+
} else {
|
|
540
|
+
return this.res.statusCode;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
resHeader(key) {
|
|
544
|
+
return this.res.getHeader(key.toLowerCase());
|
|
545
|
+
}
|
|
546
|
+
resHeaderFirst(key, defaultValue) {
|
|
547
|
+
const header = this.res.getHeader(key.toLowerCase());
|
|
548
|
+
if (header && Array.isArray(header)) {
|
|
549
|
+
return header[0] ?? defaultValue;
|
|
550
|
+
} else {
|
|
551
|
+
return header ?? defaultValue;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
async reqSession() {
|
|
555
|
+
if (this.config.sessionManager) {
|
|
556
|
+
return (await this.config.sessionManager.session(this)).dataSet.data;
|
|
557
|
+
} else {
|
|
558
|
+
return Promise.reject(new Error("Not SessionManager"));
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
reqSessionSet(key, value) {
|
|
562
|
+
this.reqSession[key] = value;
|
|
563
|
+
}
|
|
564
|
+
reqSessionGet(key) {
|
|
565
|
+
const session = this.reqSession;
|
|
566
|
+
if (session) {
|
|
567
|
+
return session[key];
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
resSetStatusCode(statusCode) {
|
|
571
|
+
this.res.statusCode = statusCode;
|
|
572
|
+
return this.createRequestResponseChain(this.res.statusCode);
|
|
573
|
+
}
|
|
574
|
+
// resEnd() {
|
|
575
|
+
// this.res.end();
|
|
576
|
+
// }
|
|
577
|
+
// eslint-disable-next-line no-undef
|
|
578
|
+
resWrite(chunk, encoding = "utf8") {
|
|
579
|
+
this.resWriteChunk = chunk;
|
|
580
|
+
return this.createRequestResponseChain(this.resWriteChunk);
|
|
581
|
+
}
|
|
582
|
+
// eslint-disable-next-line no-undef
|
|
583
|
+
resWriteJson(chunk, encoding = "utf8") {
|
|
584
|
+
return this.resWrite(JSON.stringify(chunk), encoding);
|
|
585
|
+
}
|
|
586
|
+
resSetHeader(key, value) {
|
|
587
|
+
return this.createRequestResponseChain(this.res.setHeader(key.toLowerCase(), value));
|
|
588
|
+
}
|
|
589
|
+
resAddHeader(key, value) {
|
|
590
|
+
const existingValue = this.res.getHeader(key.toLowerCase());
|
|
591
|
+
const newValue = Array.isArray(existingValue) ? existingValue.concat(value) : existingValue ? [existingValue.toString(), ...[].concat(value)] : value;
|
|
592
|
+
return this.createRequestResponseChain(this.res.setHeader(key.toLowerCase(), newValue));
|
|
593
|
+
}
|
|
594
|
+
resSetHeaders(headers) {
|
|
595
|
+
Object.entries(headers).forEach(([key, value]) => this.resSetHeader(key, value));
|
|
596
|
+
return this.createRequestResponseChain();
|
|
597
|
+
}
|
|
598
|
+
resAddHeaders(headers) {
|
|
599
|
+
Object.entries(headers).forEach(([key, value]) => this.resAddHeader(key, value));
|
|
600
|
+
return this.createRequestResponseChain();
|
|
601
|
+
}
|
|
602
|
+
// 마지막 종료될때 타는거.
|
|
603
|
+
async resEndChunk() {
|
|
604
|
+
const encoding = this.reqHeaderFirst("Accept-Encoding" /* AcceptEncoding */);
|
|
605
|
+
let data = this.resWriteChunk;
|
|
606
|
+
if (encoding?.includes("gzip")) {
|
|
607
|
+
data = await (0, import_node_gzip.gzip)(data);
|
|
608
|
+
this.resSetHeader("Content-Encoding" /* ContentEncoding */, "gzip");
|
|
609
|
+
}
|
|
610
|
+
this.res.end(data);
|
|
611
|
+
}
|
|
612
|
+
async resEnd(chunk) {
|
|
613
|
+
this.resWriteChunk = chunk ?? this.resWriteChunk;
|
|
614
|
+
if (this.req.readable) {
|
|
615
|
+
await this.reqBodyData();
|
|
616
|
+
await this.resEndChunk();
|
|
617
|
+
} else {
|
|
618
|
+
await this.resEndChunk();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
// writeContinue(callback?: () => void) {
|
|
622
|
+
// this.res.writeContinue(callback);
|
|
623
|
+
// return new RequestResponseChain(this.req, this.res);
|
|
624
|
+
// }
|
|
625
|
+
// reqWrite(chunk?: any) {
|
|
626
|
+
// this.resWriteChunk = chunk;
|
|
627
|
+
// // this.res.write(chunk);
|
|
628
|
+
// return this.createRequestResponseChain();
|
|
629
|
+
// }
|
|
630
|
+
resWriteHead(statusCode, headers) {
|
|
631
|
+
return this.createRequestResponseChain(this.res.writeHead(statusCode, headers));
|
|
632
|
+
}
|
|
633
|
+
resWriteHeadEnd(statusCode, headers) {
|
|
634
|
+
this.createRequestResponseChain(this.res.writeHead(statusCode, headers));
|
|
635
|
+
this.res.end();
|
|
636
|
+
}
|
|
637
|
+
resIsDone() {
|
|
638
|
+
return this.res.finished || this.res.writableEnded || this.res.headersSent;
|
|
639
|
+
}
|
|
640
|
+
createRequestResponseChain(data) {
|
|
641
|
+
const requestResponseChain = new RequestResponseChain(this.req, this.res, this.config, data);
|
|
642
|
+
requestResponseChain.resWriteChunk = this.resWriteChunk;
|
|
643
|
+
requestResponseChain.reqBodyChunk = this.reqBodyChunk;
|
|
644
|
+
return requestResponseChain;
|
|
645
|
+
}
|
|
646
|
+
// res.on("readable", () => {
|
|
647
|
+
// console.log('readable???')
|
|
648
|
+
// });
|
|
649
|
+
// res.on('complete', function (details) {
|
|
650
|
+
// var size = details.req.bytes;
|
|
651
|
+
// console.log('complete-->', size)
|
|
652
|
+
// });
|
|
653
|
+
// res.on('finish', function() {
|
|
654
|
+
// console.log('finish??');
|
|
655
|
+
// });
|
|
656
|
+
// res.on('end', () => {
|
|
657
|
+
// console.log('end--?')
|
|
658
|
+
// });
|
|
659
|
+
};
|
|
660
|
+
var RequestResponseChain = class extends RequestResponse {
|
|
661
|
+
constructor(req, res, config, result) {
|
|
662
|
+
super(req, res, config);
|
|
663
|
+
this.result = result;
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
// src/decorators/MethodMapping.ts
|
|
668
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
669
|
+
var import_ReflectUtils = require("@dooboostore/core/reflect/ReflectUtils");
|
|
670
|
+
|
|
671
|
+
// src/codes/HttpMethod.ts
|
|
672
|
+
var HttpMethod = /* @__PURE__ */ ((HttpMethod2) => {
|
|
673
|
+
HttpMethod2["GET"] = "GET";
|
|
674
|
+
HttpMethod2["POST"] = "POST";
|
|
675
|
+
HttpMethod2["PUT"] = "PUT";
|
|
676
|
+
HttpMethod2["DELETE"] = "DELETE";
|
|
677
|
+
HttpMethod2["PATCH"] = "PATCH";
|
|
678
|
+
HttpMethod2["HEAD"] = "HEAD";
|
|
679
|
+
HttpMethod2["OPTIONS"] = "OPTIONS";
|
|
680
|
+
HttpMethod2["TRACE"] = "TRACE";
|
|
681
|
+
HttpMethod2["CONNECT"] = "CONNECT";
|
|
682
|
+
return HttpMethod2;
|
|
683
|
+
})(HttpMethod || {});
|
|
684
|
+
|
|
685
|
+
// src/decorators/MethodMapping.ts
|
|
686
|
+
var UrlMappingSituationType = /* @__PURE__ */ ((UrlMappingSituationType2) => {
|
|
687
|
+
UrlMappingSituationType2["REQ_JSON_BODY"] = "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY";
|
|
688
|
+
UrlMappingSituationType2["REQ_FORM_URL_BODY"] = "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY";
|
|
689
|
+
return UrlMappingSituationType2;
|
|
690
|
+
})(UrlMappingSituationType || {});
|
|
691
|
+
var MappingMetadataKey = Symbol("MappingMetadataKey");
|
|
692
|
+
var process2 = (config, target, propertyKey, descriptor) => {
|
|
693
|
+
const saveMappingConfigs = import_ReflectUtils.ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? [];
|
|
694
|
+
saveMappingConfigs.push({ propertyKey, config });
|
|
695
|
+
import_ReflectUtils.ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);
|
|
696
|
+
import_ReflectUtils.ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey);
|
|
697
|
+
};
|
|
698
|
+
function UrlMapping(configOrtarget, propertyKey, descriptor) {
|
|
699
|
+
if (propertyKey && descriptor) {
|
|
700
|
+
process2({ method: "GET" /* GET */ }, configOrtarget, propertyKey, descriptor);
|
|
701
|
+
} else {
|
|
702
|
+
return (target, propertyKey2, descriptor2) => {
|
|
703
|
+
process2(configOrtarget, target, propertyKey2, descriptor2);
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
var getUrlMapping = (target, propertyKey) => {
|
|
708
|
+
return import_ReflectUtils.ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);
|
|
709
|
+
};
|
|
710
|
+
var getUrlMappings = (target) => {
|
|
711
|
+
if (target !== null && void 0 !== target && typeof target === "object") {
|
|
712
|
+
target = target.constructor;
|
|
713
|
+
}
|
|
714
|
+
return import_ReflectUtils.ReflectUtils.getMetadata(MappingMetadataKey, target);
|
|
715
|
+
};
|
|
716
|
+
function GET(configOrTarget, propertyKey, descriptor) {
|
|
717
|
+
if (propertyKey && descriptor) {
|
|
718
|
+
process2({ method: "GET" /* GET */ }, configOrTarget, propertyKey, descriptor);
|
|
719
|
+
} else {
|
|
720
|
+
return (target, propertyKey2, descriptor2) => {
|
|
721
|
+
configOrTarget.method = "GET" /* GET */;
|
|
722
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
var getGET = (target, propertyKey) => {
|
|
727
|
+
return getUrlMapping(target, propertyKey);
|
|
728
|
+
};
|
|
729
|
+
var getGETS = (target) => {
|
|
730
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "GET" /* GET */);
|
|
731
|
+
};
|
|
732
|
+
function POST(configOrTarget, propertyKey, descriptor) {
|
|
733
|
+
if (propertyKey && descriptor) {
|
|
734
|
+
process2({ method: "POST" /* POST */ }, configOrTarget, propertyKey, descriptor);
|
|
735
|
+
} else {
|
|
736
|
+
return (target, propertyKey2, descriptor2) => {
|
|
737
|
+
configOrTarget.method = "POST" /* POST */;
|
|
738
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
var getPOST = (target, propertyKey) => {
|
|
743
|
+
return getUrlMapping(target, propertyKey);
|
|
744
|
+
};
|
|
745
|
+
var getPOSTS = (target) => {
|
|
746
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "POST" /* POST */);
|
|
747
|
+
};
|
|
748
|
+
function DELETE(configOrTarget, propertyKey, descriptor) {
|
|
749
|
+
if (propertyKey && descriptor) {
|
|
750
|
+
process2({ method: "DELETE" /* DELETE */ }, configOrTarget, propertyKey, descriptor);
|
|
751
|
+
} else {
|
|
752
|
+
return (target, propertyKey2, descriptor2) => {
|
|
753
|
+
configOrTarget.method = "DELETE" /* DELETE */;
|
|
754
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
var getDELETE = (target, propertyKey) => {
|
|
759
|
+
return getUrlMapping(target, propertyKey);
|
|
760
|
+
};
|
|
761
|
+
var getDELETES = (target) => {
|
|
762
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "DELETE" /* DELETE */);
|
|
763
|
+
};
|
|
764
|
+
function PUT(configOrTarget, propertyKey, descriptor) {
|
|
765
|
+
if (propertyKey && descriptor) {
|
|
766
|
+
process2({ method: "PUT" /* PUT */ }, configOrTarget, propertyKey, descriptor);
|
|
767
|
+
} else {
|
|
768
|
+
return (target, propertyKey2, descriptor2) => {
|
|
769
|
+
configOrTarget.method = "PUT" /* PUT */;
|
|
770
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
var getPUT = (target, propertyKey) => {
|
|
775
|
+
return getUrlMapping(target, propertyKey);
|
|
776
|
+
};
|
|
777
|
+
var getPUTS = (target) => {
|
|
778
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "PUT" /* PUT */);
|
|
779
|
+
};
|
|
780
|
+
function PATCH(configOrTarget, propertyKey, descriptor) {
|
|
781
|
+
if (propertyKey && descriptor) {
|
|
782
|
+
process2({ method: "PATCH" /* PATCH */ }, configOrTarget, propertyKey, descriptor);
|
|
783
|
+
} else {
|
|
784
|
+
return (target, propertyKey2, descriptor2) => {
|
|
785
|
+
configOrTarget.method = "PATCH" /* PATCH */;
|
|
786
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
var getPATCH = (target, propertyKey) => {
|
|
791
|
+
return getUrlMapping(target, propertyKey);
|
|
792
|
+
};
|
|
793
|
+
var getPATCHS = (target) => {
|
|
794
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "GET" /* GET */);
|
|
795
|
+
};
|
|
796
|
+
function OPTIONS(configOrTarget, propertyKey, descriptor) {
|
|
797
|
+
if (propertyKey && descriptor) {
|
|
798
|
+
process2({ method: "OPTIONS" /* OPTIONS */ }, configOrTarget, propertyKey, descriptor);
|
|
799
|
+
} else {
|
|
800
|
+
return (target, propertyKey2, descriptor2) => {
|
|
801
|
+
configOrTarget.method = "OPTIONS" /* OPTIONS */;
|
|
802
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
var getOPTIONS = (target, propertyKey) => {
|
|
807
|
+
return getUrlMapping(target, propertyKey);
|
|
808
|
+
};
|
|
809
|
+
var getOPTIONSS = (target) => {
|
|
810
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "OPTIONS" /* OPTIONS */);
|
|
811
|
+
};
|
|
812
|
+
function HEAD(configOrTarget, propertyKey, descriptor) {
|
|
813
|
+
if (propertyKey && descriptor) {
|
|
814
|
+
process2({ method: "HEAD" /* HEAD */ }, configOrTarget, propertyKey, descriptor);
|
|
815
|
+
} else {
|
|
816
|
+
return (target, propertyKey2, descriptor2) => {
|
|
817
|
+
configOrTarget.method = "HEAD" /* HEAD */;
|
|
818
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
var getHEAD = (target, propertyKey) => {
|
|
823
|
+
return getUrlMapping(target, propertyKey);
|
|
824
|
+
};
|
|
825
|
+
var getHEADS = (target) => {
|
|
826
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "GET" /* GET */);
|
|
827
|
+
};
|
|
828
|
+
function TRACE(configOrTarget, propertyKey, descriptor) {
|
|
829
|
+
if (propertyKey && descriptor) {
|
|
830
|
+
process2({ method: "TRACE" /* TRACE */ }, configOrTarget, propertyKey, descriptor);
|
|
831
|
+
} else {
|
|
832
|
+
return (target, propertyKey2, descriptor2) => {
|
|
833
|
+
configOrTarget.method = "TRACE" /* TRACE */;
|
|
834
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
var getTRACE = (target, propertyKey) => {
|
|
839
|
+
return getUrlMapping(target, propertyKey);
|
|
840
|
+
};
|
|
841
|
+
var getTRACES = (target) => {
|
|
842
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "TRACE" /* TRACE */);
|
|
843
|
+
};
|
|
844
|
+
function CONNECT(configOrTarget, propertyKey, descriptor) {
|
|
845
|
+
if (propertyKey && descriptor) {
|
|
846
|
+
process2({ method: "CONNECT" /* CONNECT */ }, configOrTarget, propertyKey, descriptor);
|
|
847
|
+
} else {
|
|
848
|
+
return (target, propertyKey2, descriptor2) => {
|
|
849
|
+
configOrTarget.method = "CONNECT" /* CONNECT */;
|
|
850
|
+
process2(configOrTarget, target, propertyKey2, descriptor2);
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
var getCONNECT = (target, propertyKey) => {
|
|
855
|
+
return getUrlMapping(target, propertyKey);
|
|
856
|
+
};
|
|
857
|
+
var getCONNECTS = (target) => {
|
|
858
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "CONNECT" /* CONNECT */);
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
// src/codes/HttpStatus.ts
|
|
862
|
+
var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
|
|
863
|
+
HttpStatus2[HttpStatus2["Ok"] = 200] = "Ok";
|
|
864
|
+
HttpStatus2[HttpStatus2["MovedPermanently"] = 301] = "MovedPermanently";
|
|
865
|
+
HttpStatus2[HttpStatus2["Found"] = 302] = "Found";
|
|
866
|
+
HttpStatus2[HttpStatus2["SeeOther"] = 303] = "SeeOther";
|
|
867
|
+
HttpStatus2[HttpStatus2["NotModified"] = 304] = "NotModified";
|
|
868
|
+
HttpStatus2[HttpStatus2["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
869
|
+
HttpStatus2[HttpStatus2["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
870
|
+
HttpStatus2[HttpStatus2["BadRequest"] = 400] = "BadRequest";
|
|
871
|
+
HttpStatus2[HttpStatus2["Unauthorized"] = 401] = "Unauthorized";
|
|
872
|
+
HttpStatus2[HttpStatus2["Forbidden"] = 403] = "Forbidden";
|
|
873
|
+
HttpStatus2[HttpStatus2["NotFound"] = 404] = "NotFound";
|
|
874
|
+
HttpStatus2[HttpStatus2["InternalServerError"] = 500] = "InternalServerError";
|
|
875
|
+
HttpStatus2[HttpStatus2["NotImplemented"] = 501] = "NotImplemented";
|
|
876
|
+
HttpStatus2[HttpStatus2["BadGateway"] = 502] = "BadGateway";
|
|
877
|
+
HttpStatus2[HttpStatus2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
878
|
+
HttpStatus2[HttpStatus2["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
879
|
+
HttpStatus2[HttpStatus2["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
|
|
880
|
+
return HttpStatus2;
|
|
881
|
+
})(HttpStatus || {});
|
|
882
|
+
|
|
883
|
+
// src/codes/Mimes.ts
|
|
884
|
+
var Mimes = /* @__PURE__ */ ((Mimes2) => {
|
|
885
|
+
Mimes2["ApplicationJson"] = "application/json";
|
|
886
|
+
Mimes2["ApplicationOctetStream"] = "application/octet-stream";
|
|
887
|
+
Mimes2["ApplicationXml"] = "application/xml";
|
|
888
|
+
Mimes2["ApplicationJsonPatch"] = "application/json-patch+json";
|
|
889
|
+
Mimes2["ApplicationXWwwFormUrlencoded"] = "application/x-www-form-urlencoded";
|
|
890
|
+
Mimes2["TextPlain"] = "text/plain";
|
|
891
|
+
Mimes2["TextHtml"] = "text/html";
|
|
892
|
+
Mimes2["All"] = "*/*";
|
|
893
|
+
Mimes2["TextCss"] = "text/css";
|
|
894
|
+
Mimes2["TextJavascript"] = "text/javascript";
|
|
895
|
+
Mimes2["TextXml"] = "text/xml";
|
|
896
|
+
Mimes2["TextXslt"] = "text/xslt";
|
|
897
|
+
Mimes2["TextXmlDtd"] = "text/xml-dtd";
|
|
898
|
+
Mimes2["TextPlainUtf8"] = "text/plain; charset=utf-8";
|
|
899
|
+
Mimes2["ImagePng"] = "image/png";
|
|
900
|
+
Mimes2["ImageGif"] = "image/gif";
|
|
901
|
+
Mimes2["ImageJpeg"] = "image/jpeg";
|
|
902
|
+
Mimes2["ImageSvg"] = "image/svg+xml";
|
|
903
|
+
Mimes2["ImageBmp"] = "image/bmp";
|
|
904
|
+
Mimes2["ImageTiff"] = "image/tiff";
|
|
905
|
+
Mimes2["ImagePdf"] = "application/pdf";
|
|
906
|
+
Mimes2["ImageXBmp"] = "image/x-bmp";
|
|
907
|
+
Mimes2["ImageXpixmap"] = "image/x-xpixmap";
|
|
908
|
+
Mimes2["ImageXxbm"] = "image/x-xbm";
|
|
909
|
+
Mimes2["MultipartFormData"] = "multipart/form-data";
|
|
910
|
+
return Mimes2;
|
|
911
|
+
})(Mimes || {});
|
|
912
|
+
|
|
913
|
+
// src/SimpleBootHttpServer.ts
|
|
914
|
+
var import_ExceptionDecorator = require("@dooboostore/simple-boot/decorators/exception/ExceptionDecorator");
|
|
915
|
+
var import_Inject = require("@dooboostore/simple-boot/decorators/inject/Inject");
|
|
916
|
+
var import_ReflectUtils2 = require("@dooboostore/core/reflect/ReflectUtils");
|
|
917
|
+
var import_RouterModule = require("@dooboostore/simple-boot/route/RouterModule");
|
|
918
|
+
|
|
919
|
+
// src/models/datas/body/ReqMultipartFormBody.ts
|
|
920
|
+
var ReqMultipartFormBody = class {
|
|
921
|
+
constructor(field = []) {
|
|
922
|
+
this.field = field;
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
// src/SimpleBootHttpServer.ts
|
|
927
|
+
var import_Validation = require("@dooboostore/simple-boot/decorators/validate/Validation");
|
|
928
|
+
var import_ValidException = require("@dooboostore/simple-boot/errors/ValidException");
|
|
929
|
+
|
|
930
|
+
// src/errors/HttpError.ts
|
|
931
|
+
var HttpError = class {
|
|
932
|
+
constructor({ status, message = "HttpError" }) {
|
|
933
|
+
this.name = "Error";
|
|
934
|
+
this.message = message;
|
|
935
|
+
this.status = status;
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
// src/SimpleBootHttpServer.ts
|
|
940
|
+
var import_Router = require("@dooboostore/simple-boot/decorators/route/Router");
|
|
941
|
+
var import_url2 = require("url");
|
|
942
|
+
|
|
943
|
+
// src/session/SessionManager.ts
|
|
944
|
+
var import_RandomUtils = require("@dooboostore/core/random/RandomUtils");
|
|
945
|
+
var SessionManager = class {
|
|
946
|
+
constructor(option) {
|
|
947
|
+
this.option = option;
|
|
948
|
+
this.sessions = /* @__PURE__ */ new Map();
|
|
949
|
+
this.sessionOption = option.sessionOption;
|
|
950
|
+
setInterval(async () => {
|
|
951
|
+
const uuids = await this.getSessionUUIDs();
|
|
952
|
+
for (const uuid of uuids) {
|
|
953
|
+
const dataSet = await this.getSessionDataSet(uuid);
|
|
954
|
+
if (dataSet && this.isExpired(dataSet.access)) {
|
|
955
|
+
await this.deleteSession(uuid);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}, this.sessionOption.expiredTime);
|
|
959
|
+
}
|
|
960
|
+
async getSessionUUIDs() {
|
|
961
|
+
if (this.sessionOption.provider?.uuids) {
|
|
962
|
+
return this.sessionOption.provider.uuids();
|
|
963
|
+
} else {
|
|
964
|
+
return Array.from(this.sessions.keys());
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
async deleteSession(uuid) {
|
|
968
|
+
if (this.sessionOption.provider?.delete) {
|
|
969
|
+
this.sessionOption.provider.delete(uuid);
|
|
970
|
+
} else {
|
|
971
|
+
this.sessions.delete(uuid);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
async getSessionDataSet(uuid) {
|
|
975
|
+
if (this.sessionOption.provider?.get) {
|
|
976
|
+
return this.sessionOption.provider.get(uuid);
|
|
977
|
+
} else {
|
|
978
|
+
return this.sessions.get(uuid);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
async setSessionDataSet(uuid, dataSet) {
|
|
982
|
+
if (this.sessionOption.provider?.set) {
|
|
983
|
+
this.sessionOption.provider.set(uuid, dataSet);
|
|
984
|
+
} else {
|
|
985
|
+
this.sessions.set(uuid, dataSet);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
isExpired(access, now = Date.now()) {
|
|
989
|
+
return now - access >= this.option.sessionOption.expiredTime;
|
|
990
|
+
}
|
|
991
|
+
makeUUID() {
|
|
992
|
+
return import_RandomUtils.RandomUtils.uuid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
|
993
|
+
}
|
|
994
|
+
async session(rrOrUUID) {
|
|
995
|
+
let uuid;
|
|
996
|
+
if (rrOrUUID instanceof RequestResponse) {
|
|
997
|
+
uuid = rrOrUUID.reqCookieGet(this.sessionOption.key) ?? this.makeUUID();
|
|
998
|
+
} else if (typeof rrOrUUID === "string") {
|
|
999
|
+
uuid = rrOrUUID;
|
|
1000
|
+
} else {
|
|
1001
|
+
uuid = this.makeUUID();
|
|
1002
|
+
}
|
|
1003
|
+
let dataSet = await this.getSessionDataSet(uuid);
|
|
1004
|
+
const now = Date.now();
|
|
1005
|
+
if (dataSet) {
|
|
1006
|
+
if (this.isExpired(dataSet.access, now)) {
|
|
1007
|
+
delete dataSet.data;
|
|
1008
|
+
}
|
|
1009
|
+
dataSet.access = now;
|
|
1010
|
+
} else {
|
|
1011
|
+
dataSet = {
|
|
1012
|
+
access: now
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
await this.setSessionDataSet(uuid, dataSet);
|
|
1016
|
+
return { uuid, dataSet };
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
// src/inject/InjectSituationType.ts
|
|
1021
|
+
var InjectSituationType;
|
|
1022
|
+
((InjectSituationType2) => {
|
|
1023
|
+
InjectSituationType2.TransactionManager = Symbol("TransactionManager");
|
|
1024
|
+
})(InjectSituationType || (InjectSituationType = {}));
|
|
1025
|
+
|
|
1026
|
+
// src/SimpleBootHttpServer.ts
|
|
1027
|
+
var SimpleBootHttpServer = class extends import_SimpleApplication.SimpleApplication {
|
|
1028
|
+
constructor(option = new HttpServerOption()) {
|
|
1029
|
+
super(option);
|
|
1030
|
+
this.option = option;
|
|
1031
|
+
this.sessionManager = new SessionManager(this.option);
|
|
1032
|
+
}
|
|
1033
|
+
run(otherInstanceSim) {
|
|
1034
|
+
const simstanceManager = super.run(otherInstanceSim);
|
|
1035
|
+
const targets = [...this.option.closeEndPoints ?? [], ...this.option.errorEndPoints ?? [], ...this.option.requestEndPoints ?? [], ...this.option.filters ?? []];
|
|
1036
|
+
Promise.all(targets.map((it) => typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it).map((it) => it.onInit(this))).then((it) => {
|
|
1037
|
+
this.startServer();
|
|
1038
|
+
});
|
|
1039
|
+
return simstanceManager;
|
|
1040
|
+
}
|
|
1041
|
+
startServer() {
|
|
1042
|
+
if (this.option.serverOption && "key" in this.option.serverOption && "cert" in this.option.serverOption) {
|
|
1043
|
+
this.server = new import_https.Server(this.option.serverOption);
|
|
1044
|
+
const httpServer = new import_http.Server();
|
|
1045
|
+
httpServer.on("request", (req, res) => {
|
|
1046
|
+
res.writeHead(301, { Location: `https://${req.headers.host}${req.url}` });
|
|
1047
|
+
res.end();
|
|
1048
|
+
});
|
|
1049
|
+
httpServer.listen(80, this.option.listen.hostname, () => {
|
|
1050
|
+
console.log("HTTP redirect server running on port 80");
|
|
1051
|
+
});
|
|
1052
|
+
} else if (this.option.serverOption) {
|
|
1053
|
+
this.server = new import_http.Server(this.option.serverOption);
|
|
1054
|
+
} else {
|
|
1055
|
+
this.server = new import_http.Server();
|
|
1056
|
+
}
|
|
1057
|
+
this.server.on("request", async (req, res) => {
|
|
1058
|
+
const transactionManager = this.option.transactionManagerFactory ? await this.option.transactionManagerFactory() : void 0;
|
|
1059
|
+
res.on("close", async () => {
|
|
1060
|
+
if (this.option.closeEndPoints) {
|
|
1061
|
+
for (const it of this.option.closeEndPoints) {
|
|
1062
|
+
try {
|
|
1063
|
+
const execute = typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it;
|
|
1064
|
+
const endPoint = execute?.endPoint(rr, this);
|
|
1065
|
+
if (endPoint instanceof Promise) {
|
|
1066
|
+
await endPoint;
|
|
1067
|
+
}
|
|
1068
|
+
} catch (e) {
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
if (!rr.resIsDone()) {
|
|
1073
|
+
rr.resEnd();
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
res.on("error", async () => {
|
|
1077
|
+
if (this.option.errorEndPoints) {
|
|
1078
|
+
for (const it of this.option.errorEndPoints) {
|
|
1079
|
+
try {
|
|
1080
|
+
const execute = typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it;
|
|
1081
|
+
const endPoint = execute?.endPoint(rr, this);
|
|
1082
|
+
if (endPoint instanceof Promise) {
|
|
1083
|
+
await endPoint;
|
|
1084
|
+
}
|
|
1085
|
+
} catch (e) {
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
if (!rr.resIsDone()) {
|
|
1090
|
+
rr.resEnd();
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
const rr = new RequestResponse(req, res, { sessionManager: this.sessionManager, option: this.option });
|
|
1094
|
+
rr.resSetHeader("Server" /* Server */, "simple-boot-http-server");
|
|
1095
|
+
const cookie = rr.reqCookieGet(this.option.sessionOption.key);
|
|
1096
|
+
if (!cookie) {
|
|
1097
|
+
const session = await this.sessionManager.session();
|
|
1098
|
+
rr.resSetHeader("Set-Cookie" /* SetCookie */, `${this.option.sessionOption.key}=${session.uuid}; Path=/; HttpOnly`);
|
|
1099
|
+
}
|
|
1100
|
+
const otherStorage = /* @__PURE__ */ new Map();
|
|
1101
|
+
otherStorage.set(RequestResponse, rr);
|
|
1102
|
+
otherStorage.set(import_http.IncomingMessage, req);
|
|
1103
|
+
otherStorage.set(import_http.ServerResponse, res);
|
|
1104
|
+
try {
|
|
1105
|
+
transactionManager?.try();
|
|
1106
|
+
if (this.option.requestEndPoints) {
|
|
1107
|
+
for (const it of this.option.requestEndPoints) {
|
|
1108
|
+
try {
|
|
1109
|
+
const execute = typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it;
|
|
1110
|
+
execute?.endPoint(rr, this);
|
|
1111
|
+
} catch (e) {
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
const filter = {
|
|
1116
|
+
carrier: /* @__PURE__ */ new Map(),
|
|
1117
|
+
filters: []
|
|
1118
|
+
};
|
|
1119
|
+
for (let i = 0; this.option.filters && i < this.option.filters.length; i++) {
|
|
1120
|
+
const it = this.option.filters[i];
|
|
1121
|
+
const execute = typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it;
|
|
1122
|
+
let sw = true;
|
|
1123
|
+
if (execute?.proceedBefore) {
|
|
1124
|
+
sw = await execute.proceedBefore({ rr, app: this, carrier: filter.carrier });
|
|
1125
|
+
filter.filters.push({ filter: execute, sw });
|
|
1126
|
+
}
|
|
1127
|
+
if (!sw) {
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
if (!rr.resIsDone()) {
|
|
1132
|
+
const routerModule = await super.routing(rr.reqIntent);
|
|
1133
|
+
otherStorage.set(import_RouterModule.RouterModule, routerModule);
|
|
1134
|
+
const moduleInstance = routerModule?.getModuleInstance?.();
|
|
1135
|
+
let methods = [];
|
|
1136
|
+
if (routerModule && moduleInstance) {
|
|
1137
|
+
if (routerModule.propertyKeys) {
|
|
1138
|
+
const map = routerModule.propertyKeys?.map((it) => {
|
|
1139
|
+
return { propertyKey: it, config: getUrlMapping(moduleInstance, it) };
|
|
1140
|
+
});
|
|
1141
|
+
methods.push(...map ?? []);
|
|
1142
|
+
} else {
|
|
1143
|
+
methods.push(...getUrlMappings(moduleInstance).filter((it) => !(0, import_Router.getRoute)(moduleInstance, it.propertyKey)) ?? []);
|
|
1144
|
+
}
|
|
1145
|
+
if (rr.reqMethod()?.toUpperCase() === "OPTIONS" /* OPTIONS */.toUpperCase()) {
|
|
1146
|
+
rr.resSetHeader("Allow" /* Allow */, methods.map((it) => it.config.method).join(", "));
|
|
1147
|
+
rr.resStatusCode(200 /* Ok */);
|
|
1148
|
+
}
|
|
1149
|
+
methods = methods.filter((it) => it && it.propertyKey && it.config && rr.reqMethod()?.toUpperCase() === it.config.method.toUpperCase());
|
|
1150
|
+
methods.sort((a, b) => {
|
|
1151
|
+
return (b.config?.req?.contentType?.length ?? 0) + (b.config?.req?.accept?.length ?? 0) - ((a.config?.req?.contentType?.length ?? 0) + (a.config?.req?.accept?.length ?? 0));
|
|
1152
|
+
});
|
|
1153
|
+
methods = methods.filter((it) => it.config?.req?.contentType ? !!it.config?.req?.contentType?.find((sit) => rr.reqHasContentTypeHeader(sit)) : true).filter((it) => it.config?.req?.accept ? !!it.config?.req?.accept?.find((sit) => rr.reqHasAcceptHeader(sit)) : true);
|
|
1154
|
+
if (methods[0]) {
|
|
1155
|
+
const it = methods[0];
|
|
1156
|
+
const paramTypes = import_ReflectUtils2.ReflectUtils.getParameterTypes(moduleInstance, it.propertyKey);
|
|
1157
|
+
const injects = (0, import_Inject.getInject)(moduleInstance, it.propertyKey);
|
|
1158
|
+
const validIndexs = (0, import_Validation.getValidIndex)(moduleInstance, it.propertyKey);
|
|
1159
|
+
if (injects) {
|
|
1160
|
+
const isJson = injects.find((it2) => it2.config?.situationType === "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY" /* REQ_JSON_BODY */);
|
|
1161
|
+
const isFormUrl = injects.find((it2) => it2.config?.situationType === "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY" /* REQ_FORM_URL_BODY */);
|
|
1162
|
+
const isTransactionManager = injects.find((it2) => it2.config?.situationType === InjectSituationType.TransactionManager);
|
|
1163
|
+
const siturationContainers = new import_Inject.SituationTypeContainers();
|
|
1164
|
+
if (isJson) {
|
|
1165
|
+
let data2 = await rr.reqBodyJsonData();
|
|
1166
|
+
if (isJson.type) {
|
|
1167
|
+
data2 = Object.assign(new isJson.type(), data2);
|
|
1168
|
+
}
|
|
1169
|
+
if (validIndexs.includes(isJson.index)) {
|
|
1170
|
+
const inValid = (0, import_Validation.execValidationInValid)(data2);
|
|
1171
|
+
if ((inValid?.length ?? 0) > 0) {
|
|
1172
|
+
throw new import_ValidException.ValidException(inValid);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
siturationContainers.push(new import_Inject.SituationTypeContainer({
|
|
1176
|
+
situationType: "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY" /* REQ_JSON_BODY */,
|
|
1177
|
+
data: data2
|
|
1178
|
+
}));
|
|
1179
|
+
}
|
|
1180
|
+
if (isFormUrl) {
|
|
1181
|
+
let data2 = await rr.reqBodyFormUrlData();
|
|
1182
|
+
if (isFormUrl.type) {
|
|
1183
|
+
data2 = Object.assign(new isFormUrl.type(), data2);
|
|
1184
|
+
}
|
|
1185
|
+
if (validIndexs.includes(isFormUrl.index)) {
|
|
1186
|
+
const inValid = (0, import_Validation.execValidationInValid)(data2);
|
|
1187
|
+
if ((inValid?.length ?? 0) > 0) {
|
|
1188
|
+
throw new import_ValidException.ValidException(inValid);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
siturationContainers.push(new import_Inject.SituationTypeContainer({ situationType: "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY" /* REQ_FORM_URL_BODY */, data: data2 }));
|
|
1192
|
+
}
|
|
1193
|
+
if (isTransactionManager && isTransactionManager.type && transactionManager && transactionManager.hasTransaction(isTransactionManager.type)) {
|
|
1194
|
+
let data2 = await transactionManager.getTransaction(isTransactionManager.type);
|
|
1195
|
+
if (data2) {
|
|
1196
|
+
data2 = await data2.try(isTransactionManager.config.argument);
|
|
1197
|
+
siturationContainers.push(new import_Inject.SituationTypeContainer({ situationType: InjectSituationType.TransactionManager, data: data2, index: isTransactionManager.index }));
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
if (siturationContainers.length) {
|
|
1201
|
+
otherStorage.set(import_Inject.SituationTypeContainers, siturationContainers);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
for (const paramType of paramTypes) {
|
|
1205
|
+
if (paramType === ReqFormUrlBody) {
|
|
1206
|
+
otherStorage.set(ReqFormUrlBody, await rr.reqBodyReqFormUrlBody());
|
|
1207
|
+
} else if (paramType === ReqJsonBody) {
|
|
1208
|
+
otherStorage.set(ReqJsonBody, await rr.reqBodyReqJsonBody());
|
|
1209
|
+
} else if (paramType === import_url2.URLSearchParams) {
|
|
1210
|
+
otherStorage.set(import_url2.URLSearchParams, rr.reqUrlSearchParams);
|
|
1211
|
+
} else if (paramType === ReqMultipartFormBody) {
|
|
1212
|
+
otherStorage.set(ReqMultipartFormBody, rr.reqBodyMultipartFormData());
|
|
1213
|
+
} else if (paramType === ReqHeader) {
|
|
1214
|
+
otherStorage.set(ReqHeader, rr.reqHeaderObj);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
let data = await this.simstanceManager.executeBindParameterSimPromise({
|
|
1218
|
+
target: moduleInstance,
|
|
1219
|
+
targetKey: it.propertyKey
|
|
1220
|
+
}, otherStorage);
|
|
1221
|
+
if (it.config?.resolver) {
|
|
1222
|
+
const execute = typeof it.config.resolver === "function" ? this.simstanceManager.getOrNewSim({ target: it.config.resolver }) : it.config.resolver;
|
|
1223
|
+
data = await execute?.resolve?.(data, rr);
|
|
1224
|
+
}
|
|
1225
|
+
const status = it.config?.res?.status ?? 200 /* Ok */;
|
|
1226
|
+
const headers = it.config?.res?.header ?? {};
|
|
1227
|
+
if (it.config?.res?.contentType) {
|
|
1228
|
+
headers["Content-Type" /* ContentType */] = it.config?.res?.contentType;
|
|
1229
|
+
}
|
|
1230
|
+
if ((it.config?.res?.contentType?.toLowerCase().indexOf("application/json" /* ApplicationJson */.toLowerCase()) ?? -1) > -1) {
|
|
1231
|
+
data = JSON.stringify(data);
|
|
1232
|
+
} else if (data && typeof data === "object") {
|
|
1233
|
+
data = JSON.stringify(data);
|
|
1234
|
+
}
|
|
1235
|
+
rr.resSetHeaders(headers);
|
|
1236
|
+
rr.resSetStatusCode(status);
|
|
1237
|
+
rr.resWrite(data);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
if (this.option.noSuchRouteEndPointMappingThrow && methods.length <= 0 && rr.reqMethod()?.toUpperCase() !== "OPTIONS" /* OPTIONS */) {
|
|
1241
|
+
throw this.option.noSuchRouteEndPointMappingThrow(rr);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
for (const it of filter.filters.reverse()) {
|
|
1245
|
+
if (it.filter?.proceedAfter && !await it.filter.proceedAfter({ rr, app: this, before: it.sw, carrier: filter.carrier })) {
|
|
1246
|
+
break;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
} catch (e) {
|
|
1250
|
+
transactionManager?.catch(e);
|
|
1251
|
+
rr.resStatusCode(e instanceof HttpError ? e.status : 500 /* InternalServerError */);
|
|
1252
|
+
const execute = typeof this.option.globalAdvice === "function" ? this.simstanceManager.getOrNewSim(this.option.globalAdvice) : this.option.globalAdvice;
|
|
1253
|
+
if (!execute) {
|
|
1254
|
+
rr.resEnd();
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
if (e && typeof e === "object") {
|
|
1258
|
+
otherStorage.set(e.constructor, e);
|
|
1259
|
+
otherStorage.set(import_Inject.SituationTypeContainer, new import_Inject.SituationTypeContainer({
|
|
1260
|
+
situationType: import_ExceptionDecorator.ExceptionHandlerSituationType.ERROR_OBJECT,
|
|
1261
|
+
data: e
|
|
1262
|
+
}));
|
|
1263
|
+
}
|
|
1264
|
+
const target = (0, import_ExceptionDecorator.targetExceptionHandler)(execute, e);
|
|
1265
|
+
if (target) {
|
|
1266
|
+
await this.simstanceManager.executeBindParameterSimPromise({
|
|
1267
|
+
target: execute,
|
|
1268
|
+
targetKey: target.propertyKey
|
|
1269
|
+
}, otherStorage);
|
|
1270
|
+
}
|
|
1271
|
+
} finally {
|
|
1272
|
+
transactionManager?.finally();
|
|
1273
|
+
}
|
|
1274
|
+
if (!rr.resIsDone()) {
|
|
1275
|
+
rr.resEnd();
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
this.server.listen(this.option.listen.port, this.option.listen.hostname, this.option.listen.backlog, () => {
|
|
1279
|
+
this.option.listen.listeningListener?.(this, this.server);
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
|
|
1284
|
+
// src/endpoints/CrossDomainHeaderEndPoint.ts
|
|
1285
|
+
var CrossDomainHeaderEndPoint = class {
|
|
1286
|
+
constructor(config) {
|
|
1287
|
+
this.config = config;
|
|
1288
|
+
}
|
|
1289
|
+
/*
|
|
1290
|
+
rr.resSetHeader("Access-Control-Allow-Origin", "*")
|
|
1291
|
+
rr.resSetHeader("Access-Control-Allow-Methods", "DELETE, POST, GET, OPTIONS")
|
|
1292
|
+
rr.resSetHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With")
|
|
1293
|
+
*/
|
|
1294
|
+
async endPoint(rr, app) {
|
|
1295
|
+
if (this.config?.accessControlAllowOrigin) {
|
|
1296
|
+
rr.resSetHeader("Access-Control-Allow-Origin" /* AccessControlAllowOrigin */, Array.isArray(this.config.accessControlAllowOrigin) ? this.config.accessControlAllowOrigin.join(", ") : this.config.accessControlAllowOrigin);
|
|
1297
|
+
}
|
|
1298
|
+
if (this.config?.accessControlAllowMethods) {
|
|
1299
|
+
rr.resSetHeader("Access-Control-Allow-Methods" /* AccessControlAllowMethods */, Array.isArray(this.config.accessControlAllowMethods) ? this.config.accessControlAllowMethods.join(", ") : this.config.accessControlAllowMethods);
|
|
1300
|
+
}
|
|
1301
|
+
if (this.config?.accessControlAllowHeaders) {
|
|
1302
|
+
rr.resSetHeader("Access-Control-Allow-Headers" /* AccessControlAllowHeaders */, Array.isArray(this.config.accessControlAllowHeaders) ? this.config.accessControlAllowHeaders.join(", ") : this.config.accessControlAllowHeaders);
|
|
1303
|
+
}
|
|
1304
|
+
if (this.config?.accessControlExposeHeaders) {
|
|
1305
|
+
rr.resSetHeader("Access-Control-Expose-Headers" /* AccessControlExposeHeaders */, Array.isArray(this.config.accessControlExposeHeaders) ? this.config.accessControlExposeHeaders.join(", ") : this.config.accessControlExposeHeaders);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
async onInit(app) {
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
|
|
1312
|
+
// src/endpoints/HeaderEndPoint.ts
|
|
1313
|
+
var HeaderEndPoint = class {
|
|
1314
|
+
constructor(headers) {
|
|
1315
|
+
this.headers = headers;
|
|
1316
|
+
}
|
|
1317
|
+
async endPoint(rr, app) {
|
|
1318
|
+
if (this.headers) {
|
|
1319
|
+
rr.resSetHeaders(this.headers);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
async onInit(app) {
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
|
|
1326
|
+
// src/errors/BadRequestError.ts
|
|
1327
|
+
var BadRequestError = class extends HttpError {
|
|
1328
|
+
constructor({ status = 400 /* BadRequest */, message = "Bad Request" } = {}) {
|
|
1329
|
+
super({ status, message });
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
// src/errors/ForbiddenError.ts
|
|
1334
|
+
var ForbiddenError = class extends HttpError {
|
|
1335
|
+
constructor({ status = 403 /* Forbidden */, message = "Forbidden" } = {}) {
|
|
1336
|
+
super({ status, message });
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
// src/errors/InternalServerError.ts
|
|
1341
|
+
var InternalServerError = class extends HttpError {
|
|
1342
|
+
constructor({ status = 500 /* InternalServerError */, message = "Internal Server Error" } = {}) {
|
|
1343
|
+
super({ status, message });
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1347
|
+
// src/errors/NotFoundError.ts
|
|
1348
|
+
var NotFoundError = class extends HttpError {
|
|
1349
|
+
constructor({ status = 404 /* NotFound */, message = "Not Found" } = {}) {
|
|
1350
|
+
super({ status, message });
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
// src/errors/UnauthorizedError.ts
|
|
1355
|
+
var UnauthorizedError = class extends HttpError {
|
|
1356
|
+
constructor({ status = 401 /* Unauthorized */, message = "Unauthorized" } = {}) {
|
|
1357
|
+
super({ status, message });
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
// src/filters/CacheFilter.ts
|
|
1362
|
+
var import_FileUtils2 = require("@dooboostore/core-node/file/FileUtils");
|
|
1363
|
+
var import_ConvertUtils3 = require("@dooboostore/core-node/convert/ConvertUtils");
|
|
1364
|
+
var import_RandomUtils2 = require("@dooboostore/core/random/RandomUtils");
|
|
1365
|
+
var CacheFilter = class _CacheFilter {
|
|
1366
|
+
constructor(config) {
|
|
1367
|
+
this.config = config;
|
|
1368
|
+
this.storage = /* @__PURE__ */ new Map();
|
|
1369
|
+
if (config.config.cacheDir && config.config.startUpClean) {
|
|
1370
|
+
import_FileUtils2.FileUtils.deleteSync(config.config.cacheDir, { options: { recursive: true } });
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
static {
|
|
1374
|
+
this.CARRIER_KEY_NAME = "_CARRIER_CACHE_FILTER_KEY_NAME";
|
|
1375
|
+
}
|
|
1376
|
+
async onInit(app) {
|
|
1377
|
+
}
|
|
1378
|
+
async proceedBefore({ rr, app, carrier }) {
|
|
1379
|
+
const filter = this.config.filter?.(rr, app);
|
|
1380
|
+
if (!filter) {
|
|
1381
|
+
return true;
|
|
1382
|
+
}
|
|
1383
|
+
if (this.config.config.cacheDir) {
|
|
1384
|
+
import_FileUtils2.FileUtils.mkdirSync(this.config.config.cacheDir, { recursive: true });
|
|
1385
|
+
}
|
|
1386
|
+
if (!this.cacheConfig && this.config.config.cacheDir) {
|
|
1387
|
+
try {
|
|
1388
|
+
this.cacheConfig = JSON.parse(import_ConvertUtils3.ConvertUtils.toString(import_FileUtils2.FileUtils.readSync([this.config.config.cacheDir, "cacheConfig.json"], { option: { encoding: "utf-8" } })));
|
|
1389
|
+
} catch (e) {
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
const date = (/* @__PURE__ */ new Date()).toISOString();
|
|
1393
|
+
this.cacheConfig ??= {
|
|
1394
|
+
createDate: date,
|
|
1395
|
+
updateDate: date,
|
|
1396
|
+
// accessDate: date,
|
|
1397
|
+
caches: {}
|
|
1398
|
+
};
|
|
1399
|
+
this.cacheConfig.createDate ??= date;
|
|
1400
|
+
this.cacheConfig.updateDate ??= date;
|
|
1401
|
+
this.cacheConfig.caches ??= {};
|
|
1402
|
+
const rkey = this.config.key(rr, app);
|
|
1403
|
+
const sessionData = { key: rkey.key, lifeTime: rkey.lifeTime ?? this.config.config.lifeTime, isUpdate: false, responseHeaders: rkey.responseHeaders };
|
|
1404
|
+
const cache = this.cacheConfig.caches[sessionData.key];
|
|
1405
|
+
if (cache) {
|
|
1406
|
+
const existes = this.config.config.cacheDir ? import_FileUtils2.FileUtils.existsSync(cache.path) : this.storage.has(cache.path);
|
|
1407
|
+
const diffTime = Date.now() - cache.createTime;
|
|
1408
|
+
if (!existes || diffTime > cache.lifeTime) {
|
|
1409
|
+
delete this.cacheConfig[sessionData.key];
|
|
1410
|
+
this.deleteChunk(cache.path);
|
|
1411
|
+
sessionData.isUpdate = true;
|
|
1412
|
+
} else {
|
|
1413
|
+
rr.resSetHeaders({
|
|
1414
|
+
...cache.responseHeader,
|
|
1415
|
+
cacheFilter: `true;remainTime=${cache.lifeTime - diffTime}`
|
|
1416
|
+
});
|
|
1417
|
+
try {
|
|
1418
|
+
const chunk = this.getChunk(cache.path);
|
|
1419
|
+
await rr.resEnd(chunk);
|
|
1420
|
+
} catch (e) {
|
|
1421
|
+
console.log("--------e", e);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
} else {
|
|
1425
|
+
sessionData.isUpdate = true;
|
|
1426
|
+
}
|
|
1427
|
+
carrier.set(_CacheFilter.CARRIER_KEY_NAME, sessionData);
|
|
1428
|
+
return sessionData.isUpdate;
|
|
1429
|
+
}
|
|
1430
|
+
deleteChunk(path3) {
|
|
1431
|
+
if (this.config.config.cacheDir && import_FileUtils2.FileUtils.existsSync(path3)) {
|
|
1432
|
+
import_FileUtils2.FileUtils.deleteFileSync(path3);
|
|
1433
|
+
} else if (this.storage.has(path3)) {
|
|
1434
|
+
this.storage.delete(path3);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
getChunk(path3) {
|
|
1438
|
+
return this.config.config.cacheDir ? import_FileUtils2.FileUtils.readSync(path3) : this.storage.get(path3);
|
|
1439
|
+
}
|
|
1440
|
+
async proceedAfter({ rr, app, carrier }) {
|
|
1441
|
+
const sessionData = carrier.get(_CacheFilter.CARRIER_KEY_NAME);
|
|
1442
|
+
if (sessionData && sessionData.isUpdate) {
|
|
1443
|
+
try {
|
|
1444
|
+
if (this.config.config.cacheDir) {
|
|
1445
|
+
import_FileUtils2.FileUtils.mkdirSync([this.config.config.cacheDir, "caches"], { recursive: true });
|
|
1446
|
+
}
|
|
1447
|
+
const resBody = rr.resBodyData();
|
|
1448
|
+
if (!resBody) {
|
|
1449
|
+
return true;
|
|
1450
|
+
}
|
|
1451
|
+
let p = void 0;
|
|
1452
|
+
const destFileUUID = import_RandomUtils2.RandomUtils.uuid4();
|
|
1453
|
+
p = this.writeChunk(destFileUUID, resBody);
|
|
1454
|
+
const updateDateNow = Date.now();
|
|
1455
|
+
const updateDate = new Date(updateDateNow).toISOString();
|
|
1456
|
+
this.cacheConfig.createDate ??= updateDate;
|
|
1457
|
+
this.cacheConfig.updateDate = updateDate;
|
|
1458
|
+
const responseHeaders = {};
|
|
1459
|
+
sessionData.responseHeaders?.map((it) => it.toLowerCase()).forEach((it) => {
|
|
1460
|
+
responseHeaders[it] = rr.resHeader(it);
|
|
1461
|
+
});
|
|
1462
|
+
this.cacheConfig.caches[sessionData.key] = {
|
|
1463
|
+
path: p,
|
|
1464
|
+
createTime: updateDateNow,
|
|
1465
|
+
lifeTime: sessionData.lifeTime,
|
|
1466
|
+
responseHeader: responseHeaders
|
|
1467
|
+
};
|
|
1468
|
+
if (this.config.config.cacheDir) {
|
|
1469
|
+
import_FileUtils2.FileUtils.write(JSON.stringify(this.cacheConfig), { path: [this.config.config.cacheDir, "cacheConfig.json"] });
|
|
1470
|
+
}
|
|
1471
|
+
} catch (e) {
|
|
1472
|
+
console.log("---", e);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
return true;
|
|
1476
|
+
}
|
|
1477
|
+
writeChunk(destFileUUID, resBody) {
|
|
1478
|
+
if (this.config.config.cacheDir) {
|
|
1479
|
+
return import_FileUtils2.FileUtils.write(resBody, { path: [this.config.config.cacheDir, "caches", destFileUUID] });
|
|
1480
|
+
} else {
|
|
1481
|
+
this.storage.set(destFileUUID, resBody);
|
|
1482
|
+
return destFileUUID;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
|
|
1487
|
+
// src/filters/HttpStatusFilter.ts
|
|
1488
|
+
var HttpStatusFilter = class {
|
|
1489
|
+
constructor(httpStatus) {
|
|
1490
|
+
this.httpStatus = httpStatus;
|
|
1491
|
+
}
|
|
1492
|
+
async proceedBefore({ rr, app }) {
|
|
1493
|
+
rr.resStatusCode(this.httpStatus);
|
|
1494
|
+
rr.resEnd();
|
|
1495
|
+
return false;
|
|
1496
|
+
}
|
|
1497
|
+
async proceedAfter({ rr, app }) {
|
|
1498
|
+
return true;
|
|
1499
|
+
}
|
|
1500
|
+
async onInit(app) {
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
|
|
1504
|
+
// src/filters/OpenApi3Filter.ts
|
|
1505
|
+
var DefulatData = {
|
|
1506
|
+
openapi: "3.0.1",
|
|
1507
|
+
info: {
|
|
1508
|
+
title: "SimpleBootHttpServer OpenApi3",
|
|
1509
|
+
description: "SimpleBootHttpServer OpenApi3"
|
|
1510
|
+
}
|
|
1511
|
+
};
|
|
1512
|
+
var OpenApi3Filter = class {
|
|
1513
|
+
constructor(config, openApiConfig) {
|
|
1514
|
+
this.config = config;
|
|
1515
|
+
this.openApiConfig = Object.assign(Object.assign({}, DefulatData), openApiConfig ?? {});
|
|
1516
|
+
}
|
|
1517
|
+
async onInit(app) {
|
|
1518
|
+
}
|
|
1519
|
+
async proceedBefore({ rr, app }) {
|
|
1520
|
+
if (rr.reqUrl === this.config.path) {
|
|
1521
|
+
const map = app.routerManager.routingMap();
|
|
1522
|
+
const data = {
|
|
1523
|
+
paths: {}
|
|
1524
|
+
};
|
|
1525
|
+
Object.entries(map).filter(([k, v]) => typeof v !== "string").forEach(([k, v]) => {
|
|
1526
|
+
const method = data.paths[k] = {};
|
|
1527
|
+
getUrlMappings(v)?.forEach((it) => {
|
|
1528
|
+
method[it.config.method] = {
|
|
1529
|
+
summary: it.propertyKey,
|
|
1530
|
+
description: it.propertyKey
|
|
1531
|
+
// operationId: it.operationId,
|
|
1532
|
+
// parameters: it.parameters,
|
|
1533
|
+
// responses: it.responses,
|
|
1534
|
+
};
|
|
1535
|
+
});
|
|
1536
|
+
});
|
|
1537
|
+
rr.resWriteJson(Object.assign(Object.assign({}, this.openApiConfig), data)).resStatusCode(200 /* Ok */).resEnd();
|
|
1538
|
+
return false;
|
|
1539
|
+
}
|
|
1540
|
+
return true;
|
|
1541
|
+
}
|
|
1542
|
+
async proceedAfter({ rr, app }) {
|
|
1543
|
+
return true;
|
|
1544
|
+
}
|
|
1545
|
+
};
|
|
1546
|
+
|
|
1547
|
+
// src/filters/ResourceFilter.ts
|
|
1548
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
1549
|
+
var import_path = __toESM(require("path"), 1);
|
|
1550
|
+
var import_mime_types = __toESM(require("mime-types"), 1);
|
|
1551
|
+
var ResourceFilter = class {
|
|
1552
|
+
constructor(resourceDistPath, resourceRegex = []) {
|
|
1553
|
+
this.resourceDistPath = resourceDistPath;
|
|
1554
|
+
this.resourceRegex = resourceRegex;
|
|
1555
|
+
}
|
|
1556
|
+
async onInit(app) {
|
|
1557
|
+
}
|
|
1558
|
+
async proceedBefore({ rr, app }) {
|
|
1559
|
+
const url = (rr.reqUrlPathName ?? "").replace(/\.\./g, "");
|
|
1560
|
+
const urlObj = rr.reqUrlObject;
|
|
1561
|
+
let sw = true;
|
|
1562
|
+
const regExps = this.resourceRegex.filter((it) => {
|
|
1563
|
+
if (it instanceof RegExp) {
|
|
1564
|
+
return it.test(url);
|
|
1565
|
+
}
|
|
1566
|
+
if (typeof it === "string") {
|
|
1567
|
+
return RegExp(it).test(url);
|
|
1568
|
+
}
|
|
1569
|
+
if (typeof it === "function") {
|
|
1570
|
+
return it(rr, app);
|
|
1571
|
+
}
|
|
1572
|
+
if (typeof it === "object" && "request" in it) {
|
|
1573
|
+
if (typeof it.request === "function") {
|
|
1574
|
+
return it.request(rr, app);
|
|
1575
|
+
}
|
|
1576
|
+
return RegExp(it.request).test(url);
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
for (const it of regExps) {
|
|
1580
|
+
const resourcePath = import_path.default.join(this.resourceDistPath, typeof it === "object" && "dist" in it ? it.dist : urlObj.pathname);
|
|
1581
|
+
sw = false;
|
|
1582
|
+
if (import_fs.default.existsSync(resourcePath)) {
|
|
1583
|
+
rr.resStatusCode(200 /* Ok */);
|
|
1584
|
+
rr.resSetHeader("Content-Type" /* ContentType */, import_mime_types.default.lookup(resourcePath).toString());
|
|
1585
|
+
await rr.resEnd(import_fs.default.readFileSync(resourcePath));
|
|
1586
|
+
break;
|
|
1587
|
+
} else {
|
|
1588
|
+
rr.resStatusCode(404 /* NotFound */);
|
|
1589
|
+
await rr.resEnd();
|
|
1590
|
+
break;
|
|
1591
|
+
}
|
|
1592
|
+
sw = false;
|
|
1593
|
+
}
|
|
1594
|
+
return sw;
|
|
1595
|
+
}
|
|
1596
|
+
async proceedAfter({ rr, app }) {
|
|
1597
|
+
return true;
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
// src/filters/ThrowFilter.ts
|
|
1602
|
+
var ThrowFilter = class {
|
|
1603
|
+
constructor(error) {
|
|
1604
|
+
this.error = error;
|
|
1605
|
+
}
|
|
1606
|
+
async onInit(app) {
|
|
1607
|
+
}
|
|
1608
|
+
async proceedBefore({ rr, app }) {
|
|
1609
|
+
return true;
|
|
1610
|
+
}
|
|
1611
|
+
async proceedAfter({ rr, app }) {
|
|
1612
|
+
const sw = rr.resIsDone();
|
|
1613
|
+
if (!sw) {
|
|
1614
|
+
throw this.error;
|
|
1615
|
+
}
|
|
1616
|
+
;
|
|
1617
|
+
return false;
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
// src/models/datas/HeaderData.ts
|
|
1622
|
+
var HeaderData = class {
|
|
1623
|
+
constructor(header, data) {
|
|
1624
|
+
this.header = header;
|
|
1625
|
+
this.data = data;
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
|
|
1629
|
+
// src/models/datas/Resource.ts
|
|
1630
|
+
var import_fs2 = __toESM(require("fs"), 1);
|
|
1631
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
1632
|
+
var import_mime_types2 = __toESM(require("mime-types"), 1);
|
|
1633
|
+
var Resource = class {
|
|
1634
|
+
constructor(path3, rootPath = process.cwd()) {
|
|
1635
|
+
this.path = path3;
|
|
1636
|
+
this.rootPath = rootPath;
|
|
1637
|
+
}
|
|
1638
|
+
get absolutePath() {
|
|
1639
|
+
if (this.path instanceof RequestResponse) {
|
|
1640
|
+
return import_path2.default.join(this.rootPath, this.path.reqUrlObj().pathname);
|
|
1641
|
+
} else if (this.path instanceof URL) {
|
|
1642
|
+
return import_path2.default.join(this.rootPath, this.path.pathname);
|
|
1643
|
+
} else {
|
|
1644
|
+
return import_path2.default.join(this.rootPath, this.path);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
get conTentType() {
|
|
1648
|
+
return import_mime_types2.default.lookup(this.absolutePath).toString();
|
|
1649
|
+
}
|
|
1650
|
+
get data() {
|
|
1651
|
+
const promise = new Promise((resolve, reject) => {
|
|
1652
|
+
import_fs2.default.readFile("", (error, fileBuffer) => {
|
|
1653
|
+
if (error) {
|
|
1654
|
+
reject(error);
|
|
1655
|
+
}
|
|
1656
|
+
const fileContent = fileBuffer.toString();
|
|
1657
|
+
resolve(fileContent);
|
|
1658
|
+
});
|
|
1659
|
+
});
|
|
1660
|
+
return promise;
|
|
1661
|
+
}
|
|
1662
|
+
async write(rr) {
|
|
1663
|
+
rr.resStatusCode(200 /* Ok */);
|
|
1664
|
+
rr.resSetHeader("Content-Type" /* ContentType */, this.conTentType);
|
|
1665
|
+
await rr.resEnd(import_fs2.default.readFileSync(this.absolutePath));
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
// src/models/method/patch/PatchJson.ts
|
|
1670
|
+
var import_fast_json_patch = __toESM(require("fast-json-patch"), 1);
|
|
1671
|
+
var PatchJson = class {
|
|
1672
|
+
constructor(patch) {
|
|
1673
|
+
this.patch = patch;
|
|
1674
|
+
}
|
|
1675
|
+
apply(obj) {
|
|
1676
|
+
obj = import_fast_json_patch.default.applyPatch(obj, this.patch).newDocument;
|
|
1677
|
+
return obj;
|
|
1678
|
+
}
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
// src/resolvers/ResourceResolver.ts
|
|
1682
|
+
var import_SimDecorator = require("@dooboostore/simple-boot/decorators/SimDecorator");
|
|
1683
|
+
var ResourceResolver = class {
|
|
1684
|
+
resolve(data, rr) {
|
|
1685
|
+
return new Resource(data ?? rr).write(rr);
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
ResourceResolver = __decorateClass([
|
|
1689
|
+
import_SimDecorator.Sim
|
|
1690
|
+
], ResourceResolver);
|
|
1691
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1692
|
+
0 && (module.exports = {
|
|
1693
|
+
BadRequestError,
|
|
1694
|
+
CONNECT,
|
|
1695
|
+
CacheFilter,
|
|
1696
|
+
CrossDomainHeaderEndPoint,
|
|
1697
|
+
DELETE,
|
|
1698
|
+
ForbiddenError,
|
|
1699
|
+
GET,
|
|
1700
|
+
HEAD,
|
|
1701
|
+
HeaderData,
|
|
1702
|
+
HeaderEndPoint,
|
|
1703
|
+
HttpError,
|
|
1704
|
+
HttpHeaders,
|
|
1705
|
+
HttpMethod,
|
|
1706
|
+
HttpServerOption,
|
|
1707
|
+
HttpStatus,
|
|
1708
|
+
HttpStatusFilter,
|
|
1709
|
+
InjectSituationType,
|
|
1710
|
+
InternalServerError,
|
|
1711
|
+
Mimes,
|
|
1712
|
+
NotFoundError,
|
|
1713
|
+
OPTIONS,
|
|
1714
|
+
OpenApi3Filter,
|
|
1715
|
+
PATCH,
|
|
1716
|
+
POST,
|
|
1717
|
+
PUT,
|
|
1718
|
+
PatchJson,
|
|
1719
|
+
ReqFormUrlBody,
|
|
1720
|
+
ReqHeader,
|
|
1721
|
+
ReqJsonBody,
|
|
1722
|
+
ReqMultipartFormBody,
|
|
1723
|
+
RequestResponse,
|
|
1724
|
+
RequestResponseChain,
|
|
1725
|
+
Resource,
|
|
1726
|
+
ResourceFilter,
|
|
1727
|
+
ResourceResolver,
|
|
1728
|
+
SessionManager,
|
|
1729
|
+
SimpleBootHttpServer,
|
|
1730
|
+
TRACE,
|
|
1731
|
+
ThrowFilter,
|
|
1732
|
+
UnauthorizedError,
|
|
1733
|
+
UrlMapping,
|
|
1734
|
+
UrlMappingSituationType,
|
|
1735
|
+
getCONNECT,
|
|
1736
|
+
getCONNECTS,
|
|
1737
|
+
getDELETE,
|
|
1738
|
+
getDELETES,
|
|
1739
|
+
getGET,
|
|
1740
|
+
getGETS,
|
|
1741
|
+
getHEAD,
|
|
1742
|
+
getHEADS,
|
|
1743
|
+
getOPTIONS,
|
|
1744
|
+
getOPTIONSS,
|
|
1745
|
+
getPATCH,
|
|
1746
|
+
getPATCHS,
|
|
1747
|
+
getPOST,
|
|
1748
|
+
getPOSTS,
|
|
1749
|
+
getPUT,
|
|
1750
|
+
getPUTS,
|
|
1751
|
+
getTRACE,
|
|
1752
|
+
getTRACES,
|
|
1753
|
+
getUrlMapping,
|
|
1754
|
+
getUrlMappings
|
|
1755
|
+
});
|
|
1756
|
+
//# sourceMappingURL=index.js.map
|