@dooboostore/simple-boot-http-server 1.0.17 → 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/dist/cjs/SimpleBootHttpServer.js +930 -2
- package/dist/cjs/SimpleBootHttpServer.js.map +7 -0
- package/dist/cjs/codes/HttpHeaders.js +71 -1
- package/dist/cjs/codes/HttpHeaders.js.map +7 -0
- package/dist/cjs/codes/HttpMethod.js +41 -1
- package/dist/cjs/codes/HttpMethod.js.map +7 -0
- package/dist/cjs/codes/HttpStatus.js +49 -1
- package/dist/cjs/codes/HttpStatus.js.map +7 -0
- package/dist/cjs/codes/Mimes.js +57 -1
- package/dist/cjs/codes/Mimes.js.map +7 -0
- package/dist/cjs/codes/index.js +145 -1
- package/dist/cjs/codes/index.js.map +7 -0
- package/dist/cjs/decorators/MethodMapping.js +265 -2
- package/dist/cjs/decorators/MethodMapping.js.map +7 -0
- package/dist/cjs/decorators/index.js +267 -2
- package/dist/cjs/decorators/index.js.map +7 -0
- package/dist/cjs/endpoints/CrossDomainHeaderEndPoint.js +55 -1
- package/dist/cjs/endpoints/CrossDomainHeaderEndPoint.js.map +7 -0
- package/dist/cjs/endpoints/EndPoint.js +18 -1
- package/dist/cjs/endpoints/EndPoint.js.map +7 -0
- package/dist/cjs/endpoints/HeaderEndPoint.js +41 -1
- package/dist/cjs/endpoints/HeaderEndPoint.js.map +7 -0
- package/dist/cjs/endpoints/index.js +73 -1
- package/dist/cjs/endpoints/index.js.map +7 -0
- package/dist/cjs/errors/BadRequestError.js +45 -1
- package/dist/cjs/errors/BadRequestError.js.map +7 -0
- package/dist/cjs/errors/ForbiddenError.js +45 -1
- package/dist/cjs/errors/ForbiddenError.js.map +7 -0
- package/dist/cjs/errors/HttpError.js +36 -1
- package/dist/cjs/errors/HttpError.js.map +7 -0
- package/dist/cjs/errors/InternalServerError.js +45 -1
- package/dist/cjs/errors/InternalServerError.js.map +7 -0
- package/dist/cjs/errors/NotFoundError.js +45 -1
- package/dist/cjs/errors/NotFoundError.js.map +7 -0
- package/dist/cjs/errors/UnauthorizedError.js +45 -1
- package/dist/cjs/errors/UnauthorizedError.js.map +7 -0
- package/dist/cjs/errors/index.js +83 -1
- package/dist/cjs/errors/index.js.map +7 -0
- package/dist/cjs/filters/CacheFilter.js +153 -1
- package/dist/cjs/filters/CacheFilter.js.map +7 -0
- package/dist/cjs/filters/Filter.js +18 -1
- package/dist/cjs/filters/Filter.js.map +7 -0
- package/dist/cjs/filters/HttpStatusFilter.js +44 -1
- package/dist/cjs/filters/HttpStatusFilter.js.map +7 -0
- package/dist/cjs/filters/OpenApi3Filter.js +83 -2
- package/dist/cjs/filters/OpenApi3Filter.js.map +7 -0
- package/dist/cjs/filters/ResourceFilter.js +91 -2
- package/dist/cjs/filters/ResourceFilter.js.map +7 -0
- package/dist/cjs/filters/ThrowFilter.js +47 -1
- package/dist/cjs/filters/ThrowFilter.js.map +7 -0
- package/dist/cjs/filters/index.js +318 -2
- package/dist/cjs/filters/index.js.map +7 -0
- package/dist/cjs/index.js +1756 -2
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/inject/InjectSituationType.js +33 -1
- package/dist/cjs/inject/InjectSituationType.js.map +7 -0
- package/dist/cjs/inject/index.js +35 -1
- package/dist/cjs/inject/index.js.map +7 -0
- package/dist/cjs/lifecycle/OnInit.js +18 -1
- package/dist/cjs/lifecycle/OnInit.js.map +7 -0
- package/dist/cjs/lifecycle/index.js +18 -1
- package/dist/cjs/lifecycle/index.js.map +7 -0
- package/dist/cjs/models/RequestResponse.js +500 -1
- package/dist/cjs/models/RequestResponse.js.map +7 -0
- package/dist/cjs/models/datas/HeaderData.js +35 -1
- package/dist/cjs/models/datas/HeaderData.js.map +7 -0
- package/dist/cjs/models/datas/MultipartData.js +18 -1
- package/dist/cjs/models/datas/MultipartData.js.map +7 -0
- package/dist/cjs/models/datas/ReqHeader.js +31 -1
- package/dist/cjs/models/datas/ReqHeader.js.map +7 -0
- package/dist/cjs/models/datas/Resource.js +550 -2
- package/dist/cjs/models/datas/Resource.js.map +7 -0
- package/dist/cjs/models/datas/body/ReqFormUrlBody.js +31 -1
- package/dist/cjs/models/datas/body/ReqFormUrlBody.js.map +7 -0
- package/dist/cjs/models/datas/body/ReqJsonBody.js +31 -1
- package/dist/cjs/models/datas/body/ReqJsonBody.js.map +7 -0
- package/dist/cjs/models/datas/body/ReqMultipartFormBody.js +34 -1
- package/dist/cjs/models/datas/body/ReqMultipartFormBody.js.map +7 -0
- package/dist/cjs/models/index.js +593 -2
- package/dist/cjs/models/index.js.map +7 -0
- package/dist/cjs/models/method/patch/PatchJson.js +49 -2
- package/dist/cjs/models/method/patch/PatchJson.js.map +7 -0
- package/dist/cjs/option/HttpServerOption.js +67 -1
- package/dist/cjs/option/HttpServerOption.js.map +7 -0
- package/dist/cjs/option/index.js +69 -1
- package/dist/cjs/option/index.js.map +7 -0
- package/dist/cjs/resolvers/Resolver.js +18 -1
- package/dist/cjs/resolvers/Resolver.js.map +7 -0
- package/dist/cjs/resolvers/{ResourceResorver.d.ts → ResourceResolver.d.ts} +2 -2
- package/dist/cjs/resolvers/{ResourceResorver.d.ts.map → ResourceResolver.d.ts.map} +1 -1
- package/dist/cjs/resolvers/ResourceResolver.js +571 -0
- package/dist/cjs/resolvers/ResourceResolver.js.map +7 -0
- package/dist/cjs/resolvers/index.d.ts +1 -1
- package/dist/cjs/resolvers/index.js +571 -2
- package/dist/cjs/resolvers/index.js.map +7 -0
- package/dist/cjs/session/SessionManager.js +577 -1
- package/dist/cjs/session/SessionManager.js.map +7 -0
- package/dist/cjs/session/index.js +579 -1
- package/dist/cjs/session/index.js.map +7 -0
- package/dist/esm/SimpleBootHttpServer.js +906 -2
- package/dist/esm/SimpleBootHttpServer.js.map +7 -0
- package/dist/esm/codes/HttpHeaders.js +47 -1
- package/dist/esm/codes/HttpHeaders.js.map +7 -0
- package/dist/esm/codes/HttpMethod.js +17 -1
- package/dist/esm/codes/HttpMethod.js.map +7 -0
- package/dist/esm/codes/HttpStatus.js +25 -1
- package/dist/esm/codes/HttpStatus.js.map +7 -0
- package/dist/esm/codes/Mimes.js +33 -1
- package/dist/esm/codes/Mimes.js.map +7 -0
- package/dist/esm/codes/index.js +116 -1
- package/dist/esm/codes/index.js.map +7 -0
- package/dist/esm/decorators/MethodMapping.js +211 -2
- package/dist/esm/decorators/MethodMapping.js.map +7 -0
- package/dist/esm/decorators/index.js +211 -2
- package/dist/esm/decorators/index.js.map +7 -0
- package/dist/esm/endpoints/CrossDomainHeaderEndPoint.js +31 -1
- package/dist/esm/endpoints/CrossDomainHeaderEndPoint.js.map +7 -0
- package/dist/esm/endpoints/EndPoint.js +1 -0
- package/dist/esm/endpoints/EndPoint.js.map +7 -0
- package/dist/esm/endpoints/HeaderEndPoint.js +17 -1
- package/dist/esm/endpoints/HeaderEndPoint.js.map +7 -0
- package/dist/esm/endpoints/index.js +46 -1
- package/dist/esm/endpoints/index.js.map +7 -0
- package/dist/esm/errors/BadRequestError.js +19 -1
- package/dist/esm/errors/BadRequestError.js.map +7 -0
- package/dist/esm/errors/ForbiddenError.js +19 -1
- package/dist/esm/errors/ForbiddenError.js.map +7 -0
- package/dist/esm/errors/HttpError.js +12 -1
- package/dist/esm/errors/HttpError.js.map +7 -0
- package/dist/esm/errors/InternalServerError.js +19 -1
- package/dist/esm/errors/InternalServerError.js.map +7 -0
- package/dist/esm/errors/NotFoundError.js +19 -1
- package/dist/esm/errors/NotFoundError.js.map +7 -0
- package/dist/esm/errors/UnauthorizedError.js +19 -1
- package/dist/esm/errors/UnauthorizedError.js.map +7 -0
- package/dist/esm/errors/index.js +52 -1
- package/dist/esm/errors/index.js.map +7 -0
- package/dist/esm/filters/CacheFilter.js +129 -1
- package/dist/esm/filters/CacheFilter.js.map +7 -0
- package/dist/esm/filters/Filter.js +1 -0
- package/dist/esm/filters/Filter.js.map +7 -0
- package/dist/esm/filters/HttpStatusFilter.js +20 -1
- package/dist/esm/filters/HttpStatusFilter.js.map +7 -0
- package/dist/esm/filters/OpenApi3Filter.js +57 -2
- package/dist/esm/filters/OpenApi3Filter.js.map +7 -0
- package/dist/esm/filters/ResourceFilter.js +57 -2
- package/dist/esm/filters/ResourceFilter.js.map +7 -0
- package/dist/esm/filters/ThrowFilter.js +23 -1
- package/dist/esm/filters/ThrowFilter.js.map +7 -0
- package/dist/esm/filters/index.js +278 -2
- package/dist/esm/filters/index.js.map +7 -0
- package/dist/esm/index.js +1662 -2
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/inject/InjectSituationType.js +9 -1
- package/dist/esm/inject/InjectSituationType.js.map +7 -0
- package/dist/esm/inject/index.js +9 -1
- package/dist/esm/inject/index.js.map +7 -0
- package/dist/esm/lifecycle/OnInit.js +1 -0
- package/dist/esm/lifecycle/OnInit.js.map +7 -0
- package/dist/esm/lifecycle/index.js +1 -0
- package/dist/esm/lifecycle/index.js.map +7 -0
- package/dist/esm/models/RequestResponse.js +475 -1
- package/dist/esm/models/RequestResponse.js.map +7 -0
- package/dist/esm/models/datas/HeaderData.js +11 -1
- package/dist/esm/models/datas/HeaderData.js.map +7 -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.js +7 -1
- package/dist/esm/models/datas/ReqHeader.js.map +7 -0
- package/dist/esm/models/datas/Resource.js +516 -2
- package/dist/esm/models/datas/Resource.js.map +7 -0
- package/dist/esm/models/datas/body/ReqFormUrlBody.js +7 -1
- package/dist/esm/models/datas/body/ReqFormUrlBody.js.map +7 -0
- package/dist/esm/models/datas/body/ReqJsonBody.js +7 -1
- package/dist/esm/models/datas/body/ReqJsonBody.js.map +7 -0
- package/dist/esm/models/datas/body/ReqMultipartFormBody.js +10 -1
- package/dist/esm/models/datas/body/ReqMultipartFormBody.js.map +7 -0
- package/dist/esm/models/index.js +549 -2
- package/dist/esm/models/index.js.map +7 -0
- package/dist/esm/models/method/patch/PatchJson.js +15 -2
- package/dist/esm/models/method/patch/PatchJson.js.map +7 -0
- package/dist/esm/option/HttpServerOption.d.ts +1 -1
- package/dist/esm/option/HttpServerOption.js +43 -1
- package/dist/esm/option/HttpServerOption.js.map +7 -0
- package/dist/esm/option/index.js +43 -1
- package/dist/esm/option/index.js.map +7 -0
- package/dist/esm/resolvers/Resolver.js +1 -0
- package/dist/esm/resolvers/Resolver.js.map +7 -0
- package/dist/esm/resolvers/{ResourceResorver.d.ts → ResourceResolver.d.ts} +2 -2
- package/dist/esm/resolvers/{ResourceResorver.d.ts.map → ResourceResolver.d.ts.map} +1 -1
- package/dist/esm/resolvers/ResourceResolver.js +538 -0
- package/dist/esm/resolvers/ResourceResolver.js.map +7 -0
- package/dist/esm/resolvers/index.d.ts +1 -1
- package/dist/esm/resolvers/index.js +538 -2
- package/dist/esm/resolvers/index.js.map +7 -0
- package/dist/esm/session/SessionManager.js +553 -1
- package/dist/esm/session/SessionManager.js.map +7 -0
- package/dist/esm/session/index.js +553 -1
- package/dist/esm/session/index.js.map +7 -0
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +1662 -2
- 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 -2
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +7 -0
- package/package.json +24 -21
- package/dist/cjs/SimpleBootHttpServer.js.LICENSE.txt +0 -20
- package/dist/cjs/decorators/MethodMapping.js.LICENSE.txt +0 -16
- package/dist/cjs/decorators/index.js.LICENSE.txt +0 -16
- package/dist/cjs/filters/OpenApi3Filter.js.LICENSE.txt +0 -16
- package/dist/cjs/filters/ResourceFilter.js.LICENSE.txt +0 -13
- package/dist/cjs/filters/index.js.LICENSE.txt +0 -30
- package/dist/cjs/index.js.LICENSE.txt +0 -46
- package/dist/cjs/models/datas/Resource.js.LICENSE.txt +0 -13
- package/dist/cjs/models/index.js.LICENSE.txt +0 -25
- package/dist/cjs/models/method/patch/PatchJson.js.LICENSE.txt +0 -11
- package/dist/cjs/resolvers/ResourceResorver.js +0 -2
- package/dist/cjs/resolvers/ResourceResorver.js.LICENSE.txt +0 -13
- package/dist/cjs/resolvers/index.js.LICENSE.txt +0 -13
- package/dist/esm/SimpleBootHttpServer.js.LICENSE.txt +0 -20
- package/dist/esm/decorators/MethodMapping.js.LICENSE.txt +0 -16
- package/dist/esm/decorators/index.js.LICENSE.txt +0 -16
- package/dist/esm/filters/OpenApi3Filter.js.LICENSE.txt +0 -16
- package/dist/esm/filters/ResourceFilter.js.LICENSE.txt +0 -13
- package/dist/esm/filters/index.js.LICENSE.txt +0 -30
- package/dist/esm/index.js.LICENSE.txt +0 -46
- package/dist/esm/models/datas/Resource.js.LICENSE.txt +0 -13
- package/dist/esm/models/index.js.LICENSE.txt +0 -25
- package/dist/esm/models/method/patch/PatchJson.js.LICENSE.txt +0 -11
- package/dist/esm/resolvers/ResourceResorver.js +0 -2
- package/dist/esm/resolvers/ResourceResorver.js.LICENSE.txt +0 -13
- package/dist/esm/resolvers/index.js.LICENSE.txt +0 -13
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.LICENSE.txt +0 -54
- package/dist/umd-bundle/SimpleBootHttpServer.d.ts +0 -14
- package/dist/umd-bundle/SimpleBootHttpServer.d.ts.map +0 -1
- package/dist/umd-bundle/codes/HttpHeaders.d.ts +0 -42
- package/dist/umd-bundle/codes/HttpHeaders.d.ts.map +0 -1
- package/dist/umd-bundle/codes/HttpMethod.d.ts +0 -12
- package/dist/umd-bundle/codes/HttpMethod.d.ts.map +0 -1
- package/dist/umd-bundle/codes/HttpStatus.d.ts +0 -45
- package/dist/umd-bundle/codes/HttpStatus.d.ts.map +0 -1
- package/dist/umd-bundle/codes/Mimes.d.ts +0 -28
- package/dist/umd-bundle/codes/Mimes.d.ts.map +0 -1
- package/dist/umd-bundle/codes/index.d.ts +0 -5
- package/dist/umd-bundle/codes/index.d.ts.map +0 -1
- package/dist/umd-bundle/decorators/MethodMapping.d.ts +0 -74
- package/dist/umd-bundle/decorators/MethodMapping.d.ts.map +0 -1
- package/dist/umd-bundle/decorators/index.d.ts +0 -2
- package/dist/umd-bundle/decorators/index.d.ts.map +0 -1
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.LICENSE.txt +0 -54
- package/dist/umd-bundle/endpoints/CrossDomainHeaderEndPoint.d.ts +0 -16
- package/dist/umd-bundle/endpoints/CrossDomainHeaderEndPoint.d.ts.map +0 -1
- package/dist/umd-bundle/endpoints/EndPoint.d.ts +0 -7
- package/dist/umd-bundle/endpoints/EndPoint.d.ts.map +0 -1
- package/dist/umd-bundle/endpoints/HeaderEndPoint.d.ts +0 -12
- package/dist/umd-bundle/endpoints/HeaderEndPoint.d.ts.map +0 -1
- package/dist/umd-bundle/endpoints/index.d.ts +0 -4
- package/dist/umd-bundle/endpoints/index.d.ts.map +0 -1
- package/dist/umd-bundle/errors/BadRequestError.d.ts +0 -8
- package/dist/umd-bundle/errors/BadRequestError.d.ts.map +0 -1
- package/dist/umd-bundle/errors/ForbiddenError.d.ts +0 -8
- package/dist/umd-bundle/errors/ForbiddenError.d.ts.map +0 -1
- package/dist/umd-bundle/errors/HttpError.d.ts +0 -12
- package/dist/umd-bundle/errors/HttpError.d.ts.map +0 -1
- package/dist/umd-bundle/errors/InternalServerError.d.ts +0 -8
- package/dist/umd-bundle/errors/InternalServerError.d.ts.map +0 -1
- package/dist/umd-bundle/errors/NotFoundError.d.ts +0 -8
- package/dist/umd-bundle/errors/NotFoundError.d.ts.map +0 -1
- package/dist/umd-bundle/errors/UnauthorizedError.d.ts +0 -8
- package/dist/umd-bundle/errors/UnauthorizedError.d.ts.map +0 -1
- package/dist/umd-bundle/errors/index.d.ts +0 -7
- package/dist/umd-bundle/errors/index.d.ts.map +0 -1
- package/dist/umd-bundle/filters/CacheFilter.d.ts +0 -45
- package/dist/umd-bundle/filters/CacheFilter.d.ts.map +0 -1
- package/dist/umd-bundle/filters/Filter.d.ts +0 -17
- package/dist/umd-bundle/filters/Filter.d.ts.map +0 -1
- package/dist/umd-bundle/filters/HttpStatusFilter.d.ts +0 -20
- package/dist/umd-bundle/filters/HttpStatusFilter.d.ts.map +0 -1
- package/dist/umd-bundle/filters/OpenApi3Filter.d.ts +0 -142
- package/dist/umd-bundle/filters/OpenApi3Filter.d.ts.map +0 -1
- package/dist/umd-bundle/filters/ResourceFilter.d.ts +0 -24
- package/dist/umd-bundle/filters/ResourceFilter.d.ts.map +0 -1
- package/dist/umd-bundle/filters/ThrowFilter.d.ts +0 -19
- package/dist/umd-bundle/filters/ThrowFilter.d.ts.map +0 -1
- package/dist/umd-bundle/filters/index.d.ts +0 -7
- package/dist/umd-bundle/filters/index.d.ts.map +0 -1
- package/dist/umd-bundle/index.d.ts +0 -13
- package/dist/umd-bundle/index.d.ts.map +0 -1
- package/dist/umd-bundle/inject/InjectSituationType.d.ts +0 -4
- package/dist/umd-bundle/inject/InjectSituationType.d.ts.map +0 -1
- package/dist/umd-bundle/inject/index.d.ts +0 -2
- package/dist/umd-bundle/inject/index.d.ts.map +0 -1
- package/dist/umd-bundle/lifecycle/OnInit.d.ts +0 -5
- package/dist/umd-bundle/lifecycle/OnInit.d.ts.map +0 -1
- package/dist/umd-bundle/lifecycle/index.d.ts +0 -2
- package/dist/umd-bundle/lifecycle/index.d.ts.map +0 -1
- package/dist/umd-bundle/models/RequestResponse.d.ts +0 -100
- package/dist/umd-bundle/models/RequestResponse.d.ts.map +0 -1
- package/dist/umd-bundle/models/datas/HeaderData.d.ts +0 -10
- package/dist/umd-bundle/models/datas/HeaderData.d.ts.map +0 -1
- package/dist/umd-bundle/models/datas/MultipartData.d.ts +0 -12
- package/dist/umd-bundle/models/datas/MultipartData.d.ts.map +0 -1
- package/dist/umd-bundle/models/datas/ReqHeader.d.ts +0 -68
- package/dist/umd-bundle/models/datas/ReqHeader.d.ts.map +0 -1
- package/dist/umd-bundle/models/datas/Resource.d.ts +0 -11
- package/dist/umd-bundle/models/datas/Resource.d.ts.map +0 -1
- package/dist/umd-bundle/models/datas/body/ReqFormUrlBody.d.ts +0 -4
- package/dist/umd-bundle/models/datas/body/ReqFormUrlBody.d.ts.map +0 -1
- package/dist/umd-bundle/models/datas/body/ReqJsonBody.d.ts +0 -4
- package/dist/umd-bundle/models/datas/body/ReqJsonBody.d.ts.map +0 -1
- package/dist/umd-bundle/models/datas/body/ReqMultipartFormBody.d.ts +0 -6
- package/dist/umd-bundle/models/datas/body/ReqMultipartFormBody.d.ts.map +0 -1
- package/dist/umd-bundle/models/index.d.ts +0 -10
- package/dist/umd-bundle/models/index.d.ts.map +0 -1
- package/dist/umd-bundle/models/method/patch/PatchJson.d.ts +0 -8
- package/dist/umd-bundle/models/method/patch/PatchJson.d.ts.map +0 -1
- package/dist/umd-bundle/option/HttpServerOption.d.ts +0 -83
- package/dist/umd-bundle/option/HttpServerOption.d.ts.map +0 -1
- package/dist/umd-bundle/option/index.d.ts +0 -2
- package/dist/umd-bundle/option/index.d.ts.map +0 -1
- package/dist/umd-bundle/resolvers/Resolver.d.ts +0 -5
- package/dist/umd-bundle/resolvers/Resolver.d.ts.map +0 -1
- package/dist/umd-bundle/resolvers/ResourceResorver.d.ts +0 -6
- package/dist/umd-bundle/resolvers/ResourceResorver.d.ts.map +0 -1
- package/dist/umd-bundle/resolvers/index.d.ts +0 -3
- package/dist/umd-bundle/resolvers/index.d.ts.map +0 -1
- package/dist/umd-bundle/session/SessionManager.d.ts +0 -57
- package/dist/umd-bundle/session/SessionManager.d.ts.map +0 -1
- package/dist/umd-bundle/session/index.d.ts +0 -2
- package/dist/umd-bundle/session/index.d.ts.map +0 -1
|
@@ -1 +1,129 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";var t={426:(e,t,i)=>{i.d(t,{T:()=>s});var r,o={d:(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},n={};o.d(n,{T:()=>r}),function(e){e.toString=function(e,t){return null==e?"":"string"==typeof e?e:e.toString(t?.encoding??"utf-8",t?.start,t?.end)},e.toBuffer=(e,t)=>"base64"===t?.encoding?(e=e.split(";base64,").pop()||"",Buffer.from(e,"base64")):Buffer.from(e)}(r||(r={}));const s=n.T},889:(e,t,i)=>{i.d(t,{n:()=>l});var r={9284:(e,t,i)=>{var r;i.d(t,{U:()=>r}),function(e){e.isArrowFunction=e=>"function"==typeof e&&void 0===e.prototype&&!e.toString().startsWith("class"),e.isPlainObject=e=>null!==e&&"object"==typeof e&&e.constructor===Object,e.isFrozen=e=>Object.isFrozen(e),e.isSealed=e=>Object.isSealed(e),e.isFrozenOrSealed=t=>e.isFrozen(t)||e.isSealed(t),e.isFrozenAndSealed=t=>e.isFrozen(t)&&e.isSealed(t),e.isNotFrozen=e=>!Object.isFrozen(e),e.isNotSealed=e=>!Object.isSealed(e),e.isNotFrozenOrSealed=t=>!e.isFrozen(t)&&!e.isSealed(t),e.isNotFrozenAndSealed=t=>!e.isFrozen(t)||!e.isSealed(t),e.isNullOrUndefined=e=>null==e||void 0===e,e.isConstructor=e=>"function"==typeof e&&void 0!==e.prototype&&e.prototype.constructor===e,e.isFunction=t=>"function"==typeof t&&!e.isConstructor(t),e.isNullish=t=>e.isNotNullish(t),e.isNotNullish=t=>Array.isArray(t)||e.isString(t)?t.length>0:t instanceof Set||t instanceof Map?t.size>0:"object"==typeof t&&null!==t?Object.keys(t).length>0:null!=t,e.isNotNullUndefined=e=>null!=e,e.isNull=e=>null===e,e.isUndefined=e=>void 0===e,e.isArray=t=>!e.isNullOrUndefined(t)&&"[object Array]"===Object.prototype.toString.call(t).trim(),e.isStringNumber=e=>"number"==typeof e?!isNaN(e):"string"==typeof e&&""!==e.trim()&&!isNaN(Number(e)),e.isNumber=t=>!e.isNullOrUndefined(t)&&"[object Number]"===Object.prototype.toString.call(t).trim(),e.isIterator=e=>null!=e&&"function"==typeof e[Symbol.iterator],e.isString=t=>!e.isNullOrUndefined(t)&&"[object String]"===Object.prototype.toString.call(t).trim(),e.isObject=t=>!e.isNullOrUndefined(t)&&"[object Object]"===Object.prototype.toString.call(t).trim(),e.isMap=t=>!e.isNullOrUndefined(t)&&"[object Map]"===Object.prototype.toString.call(t).trim(),e.isEmpty=t=>!!e.isNullOrUndefined(t)||(e.isArray(t)?0===t.length:e.isString(t)?0===t.trim().length:e.isMap(t)?0===t.size:!!e.isObject(t)&&0===Object.keys(t).length),e.isSet=e=>e instanceof Set,e.isNullishFiltered=e=>Array.isArray(e)?e.every(e=>null!=e):null!=e,e.isFalsyFiltered=e=>Array.isArray(e)?e.every(e=>e):!!e,e.includeValue=(e,t)=>Object.values(e).includes(t),e.includeKey=(e,t)=>Object.keys(e).includes(t),e.lastConsonantLetter=e=>(e.charCodeAt(e.length-1)-44032)%28>0,e.inRange=(e,t,i)=>t<=e&&e<=i,e.isBase64=e=>{let t=e;const i=e.split(";base64,");if(i.length>1)t=i[1];else if(e.startsWith("data:")){const i=e.indexOf(",");i>-1&&(t=e.substring(i+1))}return""===t||t.length,/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}}(r||(r={}))}},o={};function n(e){var t=o[e];if(void 0!==t)return t.exports;var i=o[e]={exports:{}};return r[e](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};n.d(s,{n:()=>a});var a,c=n(9284);!function(e){e.uniqueInts=(t,i,r)=>{const o=[];if(r>i-t)throw new Error("Count is greater than the range of unique integers");for(;o.length<r;){const r=e.int(t,i);o.includes(r)||o.push(r)}return o},e.chance=e=>{if(e<0||e>1)throw new Error("Percentage must be between 0 and 1");return Math.random()<e},e.int=(t,i)=>Math.floor(e.float(t,i)),e.float=(e,t)=>c.U.isNullOrUndefined(e)?Math.random():!c.U.isNullOrUndefined(e)&&c.U.isNullOrUndefined(t)?Math.random()*(e||0):Math.random()*((t||0)-(e||0))+(e||0),e.uuid=(e="xxxx-xxxx-xxxx-xxxx")=>e.replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),e.uuid4=()=>{let e,t="";for(e=0;e<32;e+=1)switch(e){case 8:case 20:t+="-",t+=(16*Math.random()|0).toString(16);break;case 12:t+="-",t+="4";break;case 16:t+="-",t+=(4*Math.random()|8).toString(16);break;default:t+=(16*Math.random()|0).toString(16)}return t},e.hex=()=>{const e="0123456789ABCDEF".split("");let t="";for(let i=0;i<6;i++)t+=e[Math.floor(16*Math.random())];return t},e.rgb=()=>{const e="0123456789ABCDEF".split("");let t="#";for(let i=0;i<6;i++)t+=e[Math.floor(16*Math.random())];return t},e.rgba=()=>{const e="0123456789ABCDEF".split("");let t="#";for(let i=0;i<8;i++)t+=e[Math.floor(16*Math.random())];return t},e.alphabet=e=>{const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");let i="";for(let r=0;r<e;r++)i+=t[Math.floor(Math.random()*t.length)];return i}}(a||(a={}));const l=s.n},3055:(t,i,r)=>{r.d(i,{i:()=>y});const o=e(import.meta.url)("node:module"),n=(0,o.createRequire)("file:///Users/hyunhakim/workspace/dooboostore/source/dooboostore-develop/dooboostore-develop.github.io/source/packages/@dooboostore/core-node/dist/esm/file/FileUtils.js")("node:os"),s=(0,o.createRequire)("file:///Users/hyunhakim/workspace/dooboostore/source/dooboostore-develop/dooboostore-develop.github.io/source/packages/@dooboostore/core-node/dist/esm/file/FileUtils.js")("node:fs"),a=(0,o.createRequire)("file:///Users/hyunhakim/workspace/dooboostore/source/dooboostore-develop/dooboostore-develop.github.io/source/packages/@dooboostore/core-node/dist/esm/file/FileUtils.js")("node:path");var c={9284:(e,t,i)=>{var r;i.d(t,{U:()=>r}),function(e){e.isArrowFunction=e=>"function"==typeof e&&void 0===e.prototype&&!e.toString().startsWith("class"),e.isPlainObject=e=>null!==e&&"object"==typeof e&&e.constructor===Object,e.isFrozen=e=>Object.isFrozen(e),e.isSealed=e=>Object.isSealed(e),e.isFrozenOrSealed=t=>e.isFrozen(t)||e.isSealed(t),e.isFrozenAndSealed=t=>e.isFrozen(t)&&e.isSealed(t),e.isNotFrozen=e=>!Object.isFrozen(e),e.isNotSealed=e=>!Object.isSealed(e),e.isNotFrozenOrSealed=t=>!e.isFrozen(t)&&!e.isSealed(t),e.isNotFrozenAndSealed=t=>!e.isFrozen(t)||!e.isSealed(t),e.isNullOrUndefined=e=>null==e||void 0===e,e.isConstructor=e=>"function"==typeof e&&void 0!==e.prototype&&e.prototype.constructor===e,e.isFunction=t=>"function"==typeof t&&!e.isConstructor(t),e.isNullish=t=>e.isNotNullish(t),e.isNotNullish=t=>Array.isArray(t)||e.isString(t)?t.length>0:t instanceof Set||t instanceof Map?t.size>0:"object"==typeof t&&null!==t?Object.keys(t).length>0:null!=t,e.isNotNullUndefined=e=>null!=e,e.isNull=e=>null===e,e.isUndefined=e=>void 0===e,e.isArray=t=>!e.isNullOrUndefined(t)&&"[object Array]"===Object.prototype.toString.call(t).trim(),e.isStringNumber=e=>"number"==typeof e?!isNaN(e):"string"==typeof e&&""!==e.trim()&&!isNaN(Number(e)),e.isNumber=t=>!e.isNullOrUndefined(t)&&"[object Number]"===Object.prototype.toString.call(t).trim(),e.isIterator=e=>null!=e&&"function"==typeof e[Symbol.iterator],e.isString=t=>!e.isNullOrUndefined(t)&&"[object String]"===Object.prototype.toString.call(t).trim(),e.isObject=t=>!e.isNullOrUndefined(t)&&"[object Object]"===Object.prototype.toString.call(t).trim(),e.isMap=t=>!e.isNullOrUndefined(t)&&"[object Map]"===Object.prototype.toString.call(t).trim(),e.isEmpty=t=>!!e.isNullOrUndefined(t)||(e.isArray(t)?0===t.length:e.isString(t)?0===t.trim().length:e.isMap(t)?0===t.size:!!e.isObject(t)&&0===Object.keys(t).length),e.isSet=e=>e instanceof Set,e.isNullishFiltered=e=>Array.isArray(e)?e.every(e=>null!=e):null!=e,e.isFalsyFiltered=e=>Array.isArray(e)?e.every(e=>e):!!e,e.includeValue=(e,t)=>Object.values(e).includes(t),e.includeKey=(e,t)=>Object.keys(e).includes(t),e.lastConsonantLetter=e=>(e.charCodeAt(e.length-1)-44032)%28>0,e.inRange=(e,t,i)=>t<=e&&e<=i,e.isBase64=e=>{let t=e;const i=e.split(";base64,");if(i.length>1)t=i[1];else if(e.startsWith("data:")){const i=e.indexOf(",");i>-1&&(t=e.substring(i+1))}return""===t||t.length,/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}}(r||(r={}))}},l={};function d(e){var t=l[e];if(void 0!==t)return t.exports;var i=l[e]={exports:{}};return c[e](i,i.exports,d),i.exports}d.d=(e,t)=>{for(var i in t)d.o(t,i)&&!d.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var h={};d.d(h,{n:()=>u});var u,p,f=d(9284);(p=u||(u={})).uniqueInts=(e,t,i)=>{const r=[];if(i>t-e)throw new Error("Count is greater than the range of unique integers");for(;r.length<i;){const i=p.int(e,t);r.includes(i)||r.push(i)}return r},p.chance=e=>{if(e<0||e>1)throw new Error("Percentage must be between 0 and 1");return Math.random()<e},p.int=(e,t)=>Math.floor(p.float(e,t)),p.float=(e,t)=>f.U.isNullOrUndefined(e)?Math.random():!f.U.isNullOrUndefined(e)&&f.U.isNullOrUndefined(t)?Math.random()*(e||0):Math.random()*((t||0)-(e||0))+(e||0),p.uuid=(e="xxxx-xxxx-xxxx-xxxx")=>e.replace(/[xy]/g,function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),p.uuid4=()=>{let e,t="";for(e=0;e<32;e+=1)switch(e){case 8:case 20:t+="-",t+=(16*Math.random()|0).toString(16);break;case 12:t+="-",t+="4";break;case 16:t+="-",t+=(4*Math.random()|8).toString(16);break;default:t+=(16*Math.random()|0).toString(16)}return t},p.hex=()=>{const e="0123456789ABCDEF".split("");let t="";for(let i=0;i<6;i++)t+=e[Math.floor(16*Math.random())];return t},p.rgb=()=>{const e="0123456789ABCDEF".split("");let t="#";for(let i=0;i<6;i++)t+=e[Math.floor(16*Math.random())];return t},p.rgba=()=>{const e="0123456789ABCDEF".split("");let t="#";for(let i=0;i<8;i++)t+=e[Math.floor(16*Math.random())];return t},p.alphabet=e=>{const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");let i="";for(let r=0;r<e;r++)i+=t[Math.floor(Math.random()*t.length)];return i};const g=h.n;var y;!function(e){class t{constructor(e){this._data=e,this.updateStats()}get originalName(){return this._data.originalName}get directory(){return this._data.path.substring(0,this._data.path.lastIndexOf("/"))}get fileName(){return this._data.path.substring(this._data.path.lastIndexOf("/")+1)}get path(){return this._data.path}get extension(){const e=this._data.path.substring(this._data.path.lastIndexOf(".")+1);return e.length>0?e:void 0}async updateStats(){const e=await s.promises.stat(this._data.path);this.size=e.size}async delete(){await s.promises.unlink(this._data.path),this._data.path="",this.size=void 0}async copy(e){await s.promises.copyFile(this._data.path,e),this._data.path=e,this.size=(await s.promises.stat(e)).size}async move(e){const t=e.substring(0,e.lastIndexOf("/"));await s.promises.mkdir(t,{recursive:!0}),await s.promises.rename(this._data.path,e),this._data.path=e,this.size=(await s.promises.stat(e)).size}async rename(e){const t=`${this.directory}/${e}`;await s.promises.rename(this._data.path,t),this.size=(await s.promises.stat(t)).size,this._data.path=t}}e.File=t,e.writeFile=async(e,i)=>(i.path??(i.path=`${n.tmpdir()}/${g.uuid4()}_${Date.now()}`),await s.promises.mkdir(i.path.substring(0,i.path.lastIndexOf("/")),{recursive:!0}),await s.promises.writeFile(i.path,e),new t({path:i.path,originalName:i.originalName})),e.path=e=>Array.isArray(e)?a.join(...e):e,e.existsSync=(t,i)=>{const r=e.path(t);return s.existsSync(r)?(i?.existes?.(r),!0):(i?.noExistes?.(r),!1)},e.mkdirSync=(t,i)=>{e.existsSync(t,{noExistes:e=>{s.mkdirSync(e,i)}})},e.mkdir=async(t,i)=>new Promise((r,o)=>{e.existsSync(t,{noExistes:e=>{s.mkdirSync(e,i),r(e)},existes:e=>{r(e)}})}),e.readSync=(t,i)=>{const r=e.path(t);return i?.option?s.readFileSync(r,i.option):s.readFileSync(r)},e.read=async(t,i)=>{const r=e.path(t);return s.readFile(r,i.option)},e.write=(t,i)=>{const r=e.path(i.path);return i.options?s.writeFileSync(r,t,i.options):s.writeFileSync(r,t),r},e.writeAppend=(t,i)=>{const r=e.path(i.path);return i.options?s.appendFileSync(r,t,i.options):s.appendFileSync(r,t),r},e.deleteSync=(t,i)=>{const r=e.path(t);e.existsSync(r)&&(i?.options?s.rmSync(r,i?.options):s.rmSync(r))},e.deleteDirSync=(t,i)=>{const r=e.path(t);e.existsSync(r)&&(i?.options?s.rmdirSync(r,i?.options):s.rmdirSync(r))},e.deleteFileSync=t=>{const i=e.path(t);e.existsSync(i)&&s.unlinkSync(i)},e.copySync=(t,i,r)=>{const o=e.path(t),n=e.path(i);s.cpSync(o,n,r)}}(y||(y={}))}},i={};function r(e){var o=i[e];if(void 0!==o)return o.exports;var n=i[e]={exports:{}};return t[e](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o={};r.d(o,{d:()=>c});var n=r(3055),s=r(426),a=r(889);class c{constructor(e){this.config=e,this.storage=new Map,e.config.cacheDir&&e.config.startUpClean&&n.i.deleteSync(e.config.cacheDir,{options:{recursive:!0}})}async onInit(e){}async proceedBefore({rr:e,app:t,carrier:i}){var r,o,a;const l=this.config.filter?.(e,t);if(!l)return!0;if(this.config.config.cacheDir&&n.i.mkdirSync(this.config.config.cacheDir,{recursive:!0}),!this.cacheConfig&&this.config.config.cacheDir)try{this.cacheConfig=JSON.parse(s.T.toString(n.i.readSync([this.config.config.cacheDir,"cacheConfig.json"],{option:{encoding:"utf-8"}})))}catch(e){}const d=(new Date).toISOString();this.cacheConfig??(this.cacheConfig={createDate:d,updateDate:d,caches:{}}),(r=this.cacheConfig).createDate??(r.createDate=d),(o=this.cacheConfig).updateDate??(o.updateDate=d),(a=this.cacheConfig).caches??(a.caches={});const h=this.config.key(e,t),u={key:h.key,lifeTime:h.lifeTime??this.config.config.lifeTime,isUpdate:!1,responseHeaders:h.responseHeaders},p=this.cacheConfig.caches[u.key];if(p){const t=this.config.config.cacheDir?n.i.existsSync(p.path):this.storage.has(p.path),i=Date.now()-p.createTime;if(!t||i>p.lifeTime)delete this.cacheConfig[u.key],this.deleteChunk(p.path),u.isUpdate=!0;else{e.resSetHeaders({...p.responseHeader,cacheFilter:"true;remainTime="+(p.lifeTime-i)});try{const t=this.getChunk(p.path);await e.resEnd(t)}catch(e){console.log("--------e",e)}}}else u.isUpdate=!0;return i.set(c.CARRIER_KEY_NAME,u),u.isUpdate}deleteChunk(e){this.config.config.cacheDir&&n.i.existsSync(e)?n.i.deleteFileSync(e):this.storage.has(e)&&this.storage.delete(e)}getChunk(e){return this.config.config.cacheDir?n.i.readSync(e):this.storage.get(e)}async proceedAfter({rr:e,app:t,carrier:i}){var r;const o=i.get(c.CARRIER_KEY_NAME);if(o&&o.isUpdate)try{this.config.config.cacheDir&&n.i.mkdirSync([this.config.config.cacheDir,"caches"],{recursive:!0});const t=e.resBodyData();if(!t)return!0;let i;const s=a.n.uuid4();i=this.writeChunk(s,t);const c=Date.now(),l=new Date(c).toISOString();(r=this.cacheConfig).createDate??(r.createDate=l),this.cacheConfig.updateDate=l;const d={};o.responseHeaders?.map(e=>e.toLowerCase()).forEach(t=>{d[t]=e.resHeader(t)}),this.cacheConfig.caches[o.key]={path:i,createTime:c,lifeTime:o.lifeTime,responseHeader:d},this.config.config.cacheDir&&n.i.write(JSON.stringify(this.cacheConfig),{path:[this.config.config.cacheDir,"cacheConfig.json"]})}catch(e){console.log("---",e)}return!0}writeChunk(e,t){return this.config.config.cacheDir?n.i.write(t,{path:[this.config.config.cacheDir,"caches",e]}):(this.storage.set(e,t),e)}}c.CARRIER_KEY_NAME="_CARRIER_CACHE_FILTER_KEY_NAME";const l=o.d;export{l as CacheFilter};
|
|
1
|
+
// src/filters/CacheFilter.ts
|
|
2
|
+
import { FileUtils } from "@dooboostore/core-node/file/FileUtils";
|
|
3
|
+
import { ConvertUtils } from "@dooboostore/core-node/convert/ConvertUtils";
|
|
4
|
+
import { RandomUtils } from "@dooboostore/core/random/RandomUtils";
|
|
5
|
+
var CacheFilter = class _CacheFilter {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
this.storage = /* @__PURE__ */ new Map();
|
|
9
|
+
if (config.config.cacheDir && config.config.startUpClean) {
|
|
10
|
+
FileUtils.deleteSync(config.config.cacheDir, { options: { recursive: true } });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
static {
|
|
14
|
+
this.CARRIER_KEY_NAME = "_CARRIER_CACHE_FILTER_KEY_NAME";
|
|
15
|
+
}
|
|
16
|
+
async onInit(app) {
|
|
17
|
+
}
|
|
18
|
+
async proceedBefore({ rr, app, carrier }) {
|
|
19
|
+
const filter = this.config.filter?.(rr, app);
|
|
20
|
+
if (!filter) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (this.config.config.cacheDir) {
|
|
24
|
+
FileUtils.mkdirSync(this.config.config.cacheDir, { recursive: true });
|
|
25
|
+
}
|
|
26
|
+
if (!this.cacheConfig && this.config.config.cacheDir) {
|
|
27
|
+
try {
|
|
28
|
+
this.cacheConfig = JSON.parse(ConvertUtils.toString(FileUtils.readSync([this.config.config.cacheDir, "cacheConfig.json"], { option: { encoding: "utf-8" } })));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const date = (/* @__PURE__ */ new Date()).toISOString();
|
|
33
|
+
this.cacheConfig ??= {
|
|
34
|
+
createDate: date,
|
|
35
|
+
updateDate: date,
|
|
36
|
+
// accessDate: date,
|
|
37
|
+
caches: {}
|
|
38
|
+
};
|
|
39
|
+
this.cacheConfig.createDate ??= date;
|
|
40
|
+
this.cacheConfig.updateDate ??= date;
|
|
41
|
+
this.cacheConfig.caches ??= {};
|
|
42
|
+
const rkey = this.config.key(rr, app);
|
|
43
|
+
const sessionData = { key: rkey.key, lifeTime: rkey.lifeTime ?? this.config.config.lifeTime, isUpdate: false, responseHeaders: rkey.responseHeaders };
|
|
44
|
+
const cache = this.cacheConfig.caches[sessionData.key];
|
|
45
|
+
if (cache) {
|
|
46
|
+
const existes = this.config.config.cacheDir ? FileUtils.existsSync(cache.path) : this.storage.has(cache.path);
|
|
47
|
+
const diffTime = Date.now() - cache.createTime;
|
|
48
|
+
if (!existes || diffTime > cache.lifeTime) {
|
|
49
|
+
delete this.cacheConfig[sessionData.key];
|
|
50
|
+
this.deleteChunk(cache.path);
|
|
51
|
+
sessionData.isUpdate = true;
|
|
52
|
+
} else {
|
|
53
|
+
rr.resSetHeaders({
|
|
54
|
+
...cache.responseHeader,
|
|
55
|
+
cacheFilter: `true;remainTime=${cache.lifeTime - diffTime}`
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
const chunk = this.getChunk(cache.path);
|
|
59
|
+
await rr.resEnd(chunk);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
console.log("--------e", e);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
sessionData.isUpdate = true;
|
|
66
|
+
}
|
|
67
|
+
carrier.set(_CacheFilter.CARRIER_KEY_NAME, sessionData);
|
|
68
|
+
return sessionData.isUpdate;
|
|
69
|
+
}
|
|
70
|
+
deleteChunk(path) {
|
|
71
|
+
if (this.config.config.cacheDir && FileUtils.existsSync(path)) {
|
|
72
|
+
FileUtils.deleteFileSync(path);
|
|
73
|
+
} else if (this.storage.has(path)) {
|
|
74
|
+
this.storage.delete(path);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
getChunk(path) {
|
|
78
|
+
return this.config.config.cacheDir ? FileUtils.readSync(path) : this.storage.get(path);
|
|
79
|
+
}
|
|
80
|
+
async proceedAfter({ rr, app, carrier }) {
|
|
81
|
+
const sessionData = carrier.get(_CacheFilter.CARRIER_KEY_NAME);
|
|
82
|
+
if (sessionData && sessionData.isUpdate) {
|
|
83
|
+
try {
|
|
84
|
+
if (this.config.config.cacheDir) {
|
|
85
|
+
FileUtils.mkdirSync([this.config.config.cacheDir, "caches"], { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
const resBody = rr.resBodyData();
|
|
88
|
+
if (!resBody) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
let p = void 0;
|
|
92
|
+
const destFileUUID = RandomUtils.uuid4();
|
|
93
|
+
p = this.writeChunk(destFileUUID, resBody);
|
|
94
|
+
const updateDateNow = Date.now();
|
|
95
|
+
const updateDate = new Date(updateDateNow).toISOString();
|
|
96
|
+
this.cacheConfig.createDate ??= updateDate;
|
|
97
|
+
this.cacheConfig.updateDate = updateDate;
|
|
98
|
+
const responseHeaders = {};
|
|
99
|
+
sessionData.responseHeaders?.map((it) => it.toLowerCase()).forEach((it) => {
|
|
100
|
+
responseHeaders[it] = rr.resHeader(it);
|
|
101
|
+
});
|
|
102
|
+
this.cacheConfig.caches[sessionData.key] = {
|
|
103
|
+
path: p,
|
|
104
|
+
createTime: updateDateNow,
|
|
105
|
+
lifeTime: sessionData.lifeTime,
|
|
106
|
+
responseHeader: responseHeaders
|
|
107
|
+
};
|
|
108
|
+
if (this.config.config.cacheDir) {
|
|
109
|
+
FileUtils.write(JSON.stringify(this.cacheConfig), { path: [this.config.config.cacheDir, "cacheConfig.json"] });
|
|
110
|
+
}
|
|
111
|
+
} catch (e) {
|
|
112
|
+
console.log("---", e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
writeChunk(destFileUUID, resBody) {
|
|
118
|
+
if (this.config.config.cacheDir) {
|
|
119
|
+
return FileUtils.write(resBody, { path: [this.config.config.cacheDir, "caches", destFileUUID] });
|
|
120
|
+
} else {
|
|
121
|
+
this.storage.set(destFileUUID, resBody);
|
|
122
|
+
return destFileUUID;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
export {
|
|
127
|
+
CacheFilter
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=CacheFilter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/filters/CacheFilter.ts"],
|
|
4
|
+
"sourcesContent": ["import { Filter } from '../filters/Filter';\nimport { HttpStatus } from '../codes/HttpStatus';\nimport { RequestResponse } from '../models/RequestResponse';\nimport { SimpleBootHttpServer } from '../SimpleBootHttpServer';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { FileUtils } from '@dooboostore/core-node/file/FileUtils';\nimport { ConvertUtils } from '@dooboostore/core-node/convert/ConvertUtils';\nimport { RandomUtils } from '@dooboostore/core/random/RandomUtils';\n\nexport type CacheFilterSessionType = { key: string, lifeTime: number, isUpdate: boolean, responseHeaders?: string[] };\n\ntype CacheConfigCacheItemType = { path: string, createTime: number, lifeTime: number, responseHeader: { [key: string]: string | number | string[] } };\n\ntype KeyAndConfig = { key: string, lifeTime?: number, responseHeaders?: string[] } ;\n\nexport class CacheFilter implements Filter {\n public static readonly CARRIER_KEY_NAME = '_CARRIER_CACHE_FILTER_KEY_NAME';\n private storage = new Map<string, string | Buffer>();\n private cacheConfig: {\n createDate: string;\n updateDate: string;\n caches: { [key: string]: CacheConfigCacheItemType }\n }\n\n constructor(private config: {\n config: {\n cacheDir?: string;\n lifeTime: number;\n startUpClean?: boolean;\n },\n filter?: (rr: RequestResponse, app: SimpleBootHttpServer) => boolean;\n key: (rr: RequestResponse, app: SimpleBootHttpServer) => KeyAndConfig;\n }) {\n\n if (config.config.cacheDir && config.config.startUpClean) {\n FileUtils.deleteSync(config.config.cacheDir, {options: {recursive: true}});\n }\n }\n\n async onInit(app: SimpleBootHttpServer) {\n }\n\n async proceedBefore({rr, app, carrier}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n // this.key = undefined;\n // this.lifeTime = undefined;\n // this.isUpdate = false;\n const filter = this.config.filter?.(rr,app);\n if (!filter) {\n return true;\n }\n if (this.config.config.cacheDir) {\n FileUtils.mkdirSync(this.config.config.cacheDir, {recursive: true});\n }\n if (!this.cacheConfig && this.config.config.cacheDir) {\n try {\n this.cacheConfig = JSON.parse(ConvertUtils.toString(FileUtils.readSync([this.config.config.cacheDir, 'cacheConfig.json'], { option: {encoding: 'utf-8'}})));\n } catch (e) {\n }\n }\n const date = new Date().toISOString();\n this.cacheConfig ??= {\n createDate: date,\n updateDate: date,\n // accessDate: date,\n caches: {}\n };\n this.cacheConfig.createDate ??= date;\n this.cacheConfig.updateDate ??= date;\n // this.cacheConfig.accessDate ??= date;\n this.cacheConfig.caches ??= {};\n\n\n const rkey = this.config.key(rr, app);\n // console.log('--path filter', rr.reqMethod(), rr.reqUrlPathName, filter, rkey)\n const sessionData: CacheFilterSessionType = {key: rkey.key, lifeTime: rkey.lifeTime ?? this.config.config.lifeTime, isUpdate: false, responseHeaders: rkey.responseHeaders};\n\n\n const cache = this.cacheConfig.caches[sessionData.key];\n if (cache) {\n const existes = this.config.config.cacheDir ? FileUtils.existsSync(cache.path) : this.storage.has(cache.path);\n const diffTime = Date.now() - cache.createTime;\n if (!existes || diffTime > cache.lifeTime) {\n delete this.cacheConfig[sessionData.key];\n this.deleteChunk(cache.path);\n sessionData.isUpdate = true;\n } else {\n rr.resSetHeaders({\n ...cache.responseHeader,\n cacheFilter: `true;remainTime=${cache.lifeTime - diffTime}`\n });\n // console.log('chunk--->', cache.path);\n try {\n const chunk = this.getChunk(cache.path);\n // console.log('chunk--->', chunk);\n await rr.resEnd(chunk);\n } catch (e) {\n console.log('--------e', e)\n }\n }\n } else {\n sessionData.isUpdate = true;\n }\n carrier.set(CacheFilter.CARRIER_KEY_NAME, sessionData);\n return sessionData.isUpdate;\n }\n\n private deleteChunk(path: string) {\n if (this.config.config.cacheDir && FileUtils.existsSync(path)) {\n FileUtils.deleteFileSync(path);\n } else if (this.storage.has(path)) {\n this.storage.delete(path);\n }\n }\n\n private getChunk(path: string) {\n return this.config.config.cacheDir ? FileUtils.readSync(path) : this.storage.get(path);\n }\n\n async proceedAfter({rr, app, carrier}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n // const data = await rr.resBodyStringData()\n const sessionData = carrier.get(CacheFilter.CARRIER_KEY_NAME) as CacheFilterSessionType ;\n if (sessionData && sessionData.isUpdate) {\n try {\n if (this.config.config.cacheDir) {\n FileUtils.mkdirSync([this.config.config.cacheDir, 'caches'], {recursive: true});\n }\n const resBody = rr.resBodyData();\n if (!resBody) {\n return true;\n }\n let p: string | undefined = undefined;\n const destFileUUID = RandomUtils.uuid4();\n p = this.writeChunk(destFileUUID, resBody);\n const updateDateNow = Date.now();\n const updateDate = new Date(updateDateNow).toISOString();\n this.cacheConfig.createDate ??= updateDate;\n this.cacheConfig.updateDate = updateDate;\n const responseHeaders: {[key: string]: string | number | string[]} = {}\n sessionData.responseHeaders?.map(it=>it.toLowerCase()).forEach(it => {\n responseHeaders[it] = rr.resHeader(it);\n })\n this.cacheConfig.caches[sessionData.key] = {\n path: p,\n createTime: updateDateNow,\n lifeTime: sessionData.lifeTime,\n responseHeader: responseHeaders\n };\n\n if (this.config.config.cacheDir) {\n FileUtils.write(JSON.stringify(this.cacheConfig), {path: [this.config.config.cacheDir, 'cacheConfig.json']});\n }\n } catch (e) {\n console.log('---', e)\n }\n }\n\n return true;\n }\n\n private writeChunk(destFileUUID: string, resBody: string | Buffer ) {\n if (this.config.config.cacheDir) {\n return FileUtils.write(resBody, {path: [this.config.config.cacheDir, 'caches', destFileUUID]});\n } else {\n this.storage.set(destFileUUID, resBody);\n return destFileUUID;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAMA,SAAU,iBAAiB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAQrB,IAAM,cAAN,MAAM,aAA8B;AAAA,EASzC,YAAoB,QAQjB;AARiB;AAPpB,SAAQ,UAAU,oBAAI,IAA6B;AAiBjD,QAAI,OAAO,OAAO,YAAY,OAAO,OAAO,cAAc;AACxD,gBAAU,WAAW,OAAO,OAAO,UAAU,EAAC,SAAS,EAAC,WAAW,KAAI,EAAC,CAAC;AAAA,IAC3E;AAAA,EACF;AAAA,EArBA;AAAA,SAAuB,mBAAmB;AAAA;AAAA,EAuB1C,MAAM,OAAO,KAA2B;AAAA,EACxC;AAAA,EAEA,MAAM,cAAc,EAAC,IAAI,KAAK,QAAO,GAAgF;AAInH,UAAM,SAAS,KAAK,OAAO,SAAS,IAAG,GAAG;AAC1C,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,IACT;AACA,QAAI,KAAK,OAAO,OAAO,UAAU;AAC/B,gBAAU,UAAU,KAAK,OAAO,OAAO,UAAU,EAAC,WAAW,KAAI,CAAC;AAAA,IACpE;AACA,QAAI,CAAC,KAAK,eAAe,KAAK,OAAO,OAAO,UAAU;AACpD,UAAI;AACF,aAAK,cAAc,KAAK,MAAM,aAAa,SAAS,UAAU,SAAS,CAAC,KAAK,OAAO,OAAO,UAAU,kBAAkB,GAAG,EAAE,QAAQ,EAAC,UAAU,QAAO,EAAC,CAAC,CAAC,CAAC;AAAA,MAC5J,SAAS,GAAG;AAAA,MACZ;AAAA,IACF;AACA,UAAM,QAAO,oBAAI,KAAK,GAAE,YAAY;AACpC,SAAK,gBAAgB;AAAA,MACnB,YAAY;AAAA,MACZ,YAAY;AAAA;AAAA,MAEZ,QAAQ,CAAC;AAAA,IACX;AACA,SAAK,YAAY,eAAe;AAChC,SAAK,YAAY,eAAe;AAEhC,SAAK,YAAY,WAAW,CAAC;AAG7B,UAAM,OAAO,KAAK,OAAO,IAAI,IAAI,GAAG;AAEpC,UAAM,cAAsC,EAAC,KAAK,KAAK,KAAK,UAAU,KAAK,YAAY,KAAK,OAAO,OAAO,UAAU,UAAU,OAAO,iBAAiB,KAAK,gBAAe;AAG1K,UAAM,QAAQ,KAAK,YAAY,OAAO,YAAY,GAAG;AACrD,QAAI,OAAO;AACT,YAAM,UAAU,KAAK,OAAO,OAAO,WAAW,UAAU,WAAW,MAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI;AAC5G,YAAM,WAAW,KAAK,IAAI,IAAI,MAAM;AACpC,UAAI,CAAC,WAAW,WAAW,MAAM,UAAU;AACzC,eAAO,KAAK,YAAY,YAAY,GAAG;AACvC,aAAK,YAAY,MAAM,IAAI;AAC3B,oBAAY,WAAW;AAAA,MACzB,OAAO;AACL,WAAG,cAAc;AAAA,UACf,GAAG,MAAM;AAAA,UACT,aAAa,mBAAmB,MAAM,WAAW,QAAQ;AAAA,QAC3D,CAAC;AAED,YAAI;AACF,gBAAM,QAAQ,KAAK,SAAS,MAAM,IAAI;AAExC,gBAAM,GAAG,OAAO,KAAK;AAAA,QACrB,SAAS,GAAG;AACV,kBAAQ,IAAI,aAAa,CAAC;AAAA,QAC5B;AAAA,MACF;AAAA,IACF,OAAO;AACL,kBAAY,WAAW;AAAA,IACzB;AACA,YAAQ,IAAI,aAAY,kBAAkB,WAAW;AACrD,WAAO,YAAY;AAAA,EACrB;AAAA,EAEQ,YAAY,MAAc;AAChC,QAAI,KAAK,OAAO,OAAO,YAAY,UAAU,WAAW,IAAI,GAAG;AAC7D,gBAAU,eAAe,IAAI;AAAA,IAC/B,WAAW,KAAK,QAAQ,IAAI,IAAI,GAAG;AACjC,WAAK,QAAQ,OAAO,IAAI;AAAA,IAC1B;AAAA,EACF;AAAA,EAEQ,SAAS,MAAc;AAC7B,WAAO,KAAK,OAAO,OAAO,WAAW,UAAU,SAAS,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI;AAAA,EACvF;AAAA,EAEA,MAAM,aAAa,EAAC,IAAI,KAAK,QAAO,GAAgF;AAElH,UAAM,cAAc,QAAQ,IAAI,aAAY,gBAAgB;AAC5D,QAAI,eAAe,YAAY,UAAU;AACvC,UAAI;AACF,YAAI,KAAK,OAAO,OAAO,UAAU;AAC/B,oBAAU,UAAU,CAAC,KAAK,OAAO,OAAO,UAAU,QAAQ,GAAG,EAAC,WAAW,KAAI,CAAC;AAAA,QAChF;AACA,cAAM,UAAU,GAAG,YAAY;AAC/B,YAAI,CAAC,SAAS;AACZ,iBAAO;AAAA,QACT;AACA,YAAK,IAAwB;AAC7B,cAAM,eAAe,YAAY,MAAM;AACvC,YAAI,KAAK,WAAW,cAAc,OAAO;AACzC,cAAM,gBAAgB,KAAK,IAAI;AAC/B,cAAM,aAAa,IAAI,KAAK,aAAa,EAAE,YAAY;AACvD,aAAK,YAAY,eAAe;AAChC,aAAK,YAAY,aAAa;AAC9B,cAAM,kBAA+D,CAAC;AACtE,oBAAY,iBAAiB,IAAI,QAAI,GAAG,YAAY,CAAC,EAAE,QAAQ,QAAM;AACnE,0BAAgB,EAAE,IAAI,GAAG,UAAU,EAAE;AAAA,QACvC,CAAC;AACD,aAAK,YAAY,OAAO,YAAY,GAAG,IAAI;AAAA,UACzC,MAAM;AAAA,UACN,YAAY;AAAA,UACZ,UAAU,YAAY;AAAA,UACtB,gBAAgB;AAAA,QAClB;AAEA,YAAI,KAAK,OAAO,OAAO,UAAU;AAC/B,oBAAU,MAAM,KAAK,UAAU,KAAK,WAAW,GAAG,EAAC,MAAM,CAAC,KAAK,OAAO,OAAO,UAAU,kBAAkB,EAAC,CAAC;AAAA,QAC7G;AAAA,MACF,SAAS,GAAG;AACV,gBAAQ,IAAI,OAAO,CAAC;AAAA,MACtB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,WAAW,cAAsB,SAA2B;AAClE,QAAI,KAAK,OAAO,OAAO,UAAU;AAC/B,aAAO,UAAU,MAAM,SAAS,EAAC,MAAM,CAAC,KAAK,OAAO,OAAO,UAAU,UAAU,YAAY,EAAC,CAAC;AAAA,IAC/F,OAAO;AACL,WAAK,QAAQ,IAAI,cAAc,OAAO;AACtC,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=Filter.js.map
|
|
@@ -1 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
// src/filters/HttpStatusFilter.ts
|
|
2
|
+
var HttpStatusFilter = class {
|
|
3
|
+
constructor(httpStatus) {
|
|
4
|
+
this.httpStatus = httpStatus;
|
|
5
|
+
}
|
|
6
|
+
async proceedBefore({ rr, app }) {
|
|
7
|
+
rr.resStatusCode(this.httpStatus);
|
|
8
|
+
rr.resEnd();
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
async proceedAfter({ rr, app }) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
async onInit(app) {
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
HttpStatusFilter
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=HttpStatusFilter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/filters/HttpStatusFilter.ts"],
|
|
4
|
+
"sourcesContent": ["import {Filter} from '../filters/Filter';\nimport {HttpStatus} from '../codes/HttpStatus';\nimport {RequestResponse} from '../models/RequestResponse';\nimport {SimpleBootHttpServer} from '../SimpleBootHttpServer';\n\nexport class HttpStatusFilter implements Filter {\n\n constructor(private httpStatus: HttpStatus | number) {\n }\n\n async proceedBefore({rr, app}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n // res.writeHead(this.httpStatus);\n rr.resStatusCode(this.httpStatus);\n rr.resEnd();\n return false;\n }\n\n async proceedAfter({rr, app}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n return true;\n }\n\n async onInit(app: SimpleBootHttpServer){\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAKO,IAAM,mBAAN,MAAyC;AAAA,EAE5C,YAAoB,YAAiC;AAAjC;AAAA,EACpB;AAAA,EAEA,MAAM,cAAc,EAAC,IAAI,IAAG,GAAgF;AAExG,OAAG,cAAc,KAAK,UAAU;AAChC,OAAG,OAAO;AACV,WAAO;AAAA,EACX;AAAA,EAEA,MAAM,aAAa,EAAC,IAAI,IAAG,GAAgF;AACvG,WAAO;AAAA,EACX;AAAA,EAEA,MAAM,OAAO,KAA0B;AAAA,EACvC;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
var t={229:(t,e,r)=>{var n;r.d(e,{t:()=>n}),function(t){t[t.Ok=200]="Ok",t[t.MovedPermanently=301]="MovedPermanently",t[t.Found=302]="Found",t[t.SeeOther=303]="SeeOther",t[t.NotModified=304]="NotModified",t[t.TemporaryRedirect=307]="TemporaryRedirect",t[t.PermanentRedirect=308]="PermanentRedirect",t[t.BadRequest=400]="BadRequest",t[t.Unauthorized=401]="Unauthorized",t[t.Forbidden=403]="Forbidden",t[t.NotFound=404]="NotFound",t[t.InternalServerError=500]="InternalServerError",t[t.NotImplemented=501]="NotImplemented",t[t.BadGateway=502]="BadGateway",t[t.ServiceUnavailable=503]="ServiceUnavailable",t[t.GatewayTimeout=504]="GatewayTimeout",t[t.HttpVersionNotSupported=505]="HttpVersionNotSupported"}(n||(n={}))},5053:(t,e,r)=>{r.d(e,{d:()=>f});var n={9771:()=>{var t;!function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof global?global:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",a="function"==typeof Object.create,u={__proto__:[]}instanceof Array,f=!a&&!u,c={create:a?function(){return U(Object.create(null))}:u?function(){return U({__proto__:null})}:function(){return U({})},has:f?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:f?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},s=Object.getPrototypeOf(Function),d="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:function(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}();return function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,I(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,n)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,a)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!I(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(I(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();function n(t,e){return t}function i(t,e){return e}function a(t,e){return[t,e]}}(),y="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:function(){function t(){this._map=new d}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[o]=function(){return this.keys()},t}(),p="function"==typeof WeakMap?WeakMap:function(){var t=c.create(),e=n();return function(){function t(){this._key=n()}return t.prototype.has=function(t){var e=i(t,!1);return void 0!==e&&c.has(e,this._key)},t.prototype.get=function(t){var e=i(t,!1);return void 0!==e?c.get(e,this._key):void 0},t.prototype.set=function(t,e){return i(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=i(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=n()},t}();function n(){var e;do{e="@@WeakMap@@"+a()}while(c.has(t,e));return t[e]=!0,e}function i(t,n){if(!r.call(t,e)){if(!n)return;Object.defineProperty(t,e,{value:c.create()})}return t[e]}function o(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function a(){var t=function(){if("function"==typeof Uint8Array){var t=new Uint8Array(16);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,16),t}return o(new Array(16),16)}();t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var e="",r=0;r<16;++r){var n=t[r];4!==r&&6!==r&&8!==r||(e+="-"),n<16&&(e+="0"),e+=n.toString(16).toLowerCase()}return e}}(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,l=function(){var t;return!k(h)&&P(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),k(t)&&(t=function(){var t,r,n,i;k(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=function(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,i=t.getOwnMetadataKeys,o=t.deleteMetadata,a=new p;return{isProviderFor:function(t,e){var r=a.get(t);return!(k(r)||!r.has(e))||!!i(t,e).length&&(k(r)&&(r=new y,a.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:o}}(e.Reflect));var o=new p,a={registerProvider:function(e){if(!Object.isExtensible(a))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case k(r):r=e;break;case r===e:break;case k(n):n=e;break;case n===e:break;default:void 0===i&&(i=new y),i.add(e)}},getProvider:f,setProvider:function(t,e,r){if(!c(r))throw new Error("Metadata provider not registered.");var n=f(t,e);if(n!==r){if(!k(n))return!1;var i=o.get(t);k(i)&&(i=new d,o.set(t,i)),i.set(e,r)}return!0}};return a;function u(e,o){if(!k(r)){if(r.isProviderFor(e,o))return r;if(!k(n)){if(n.isProviderFor(e,o))return r;if(!k(i))for(var a=F(i);;){var u=C(a);if(!u)return;var f=D(u);if(f.isProviderFor(e,o))return N(a),f}}}if(!k(t)&&t.isProviderFor(e,o))return t}function f(t,e){var r,n=o.get(t);return k(n)||(r=n.get(e)),k(r)?(k(r=u(t,e))||(k(n)&&(n=new d,o.set(t,n)),n.set(e,r)),r):r}function c(t){if(k(t))throw new TypeError;return r===t||n===t||!k(i)&&i.has(t)}}()),!k(h)&&P(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}(),v=function(t){var e=new p,r={isProviderFor:function(t,r){var n=e.get(t);return!k(n)&&n.has(r)},OrdinaryDefineOwnMetadata:function(t,e,r,i){n(r,i,!0).set(t,e)},OrdinaryHasOwnMetadata:function(t,e,r){var i=n(e,r,!1);return!k(i)&&R(i.has(t))},OrdinaryGetOwnMetadata:function(t,e,r){var i=n(e,r,!1);if(!k(i))return i.get(t)},OrdinaryOwnMetadataKeys:function(t,e){var r=[],i=n(t,e,!1);if(k(i))return r;for(var o=F(i.keys()),a=0;;){var u=C(o);if(!u)return r.length=a,r;var f=D(u);try{r[a]=f}catch(t){try{N(o)}finally{throw t}}a++}},OrdinaryDeleteMetadata:function(t,r,i){var o=n(r,i,!1);if(k(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var a=e.get(r);k(a)||(a.delete(i),0===a.size&&e.delete(a))}return!0}};return l.registerProvider(r),r;function n(n,i,o){var a=e.get(n),u=!1;if(k(a)){if(!o)return;a=new d,e.set(n,a),u=!0}var f=a.get(i);if(k(f)){if(!o)return;if(f=new d,a.set(i,f),!t.setProvider(n,i,r))throw a.delete(i),u&&e.delete(n),new Error("Wrong provider for target.")}return f}}(l);function w(t,e,r){if(_(t,e,r))return!0;var n=z(e);return!T(n)&&w(t,n,r)}function _(t,e,r){var n=H(e,r,!1);return!k(n)&&R(n.OrdinaryHasOwnMetadata(t,e,r))}function g(t,e,r){if(_(t,e,r))return O(t,e,r);var n=z(e);return T(n)?void 0:g(t,n,r)}function O(t,e,r){var n=H(e,r,!1);if(!k(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function b(t,e,r,n){H(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function M(t,e){var r=E(t,e),n=z(t);if(null===n)return r;var i=M(n,e);if(i.length<=0)return r;if(r.length<=0)return i;for(var o=new y,a=[],u=0,f=r;u<f.length;u++){var c=f[u];o.has(c)||(o.add(c),a.push(c))}for(var s=0,d=i;s<d.length;s++)c=d[s],o.has(c)||(o.add(c),a.push(c));return a}function E(t,e){var r=H(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function m(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function k(t){return void 0===t}function T(t){return null===t}function P(t){return"object"==typeof t?null!==t:"function"==typeof t}function R(t){return!!t}function j(t){var e=function(t){switch(m(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var e="string",r=K(t,i);if(void 0!==r){var n=r.call(t,e);if(P(n))throw new TypeError;return n}return function(t){var e,r,n=t.toString;if(S(n)&&!P(r=n.call(t)))return r;if(S(e=t.valueOf)&&!P(r=e.call(t)))return r;throw new TypeError}(t)}(t);return"symbol"==typeof e?e:function(t){return""+t}(e)}function x(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function S(t){return"function"==typeof t}function A(t){return"function"==typeof t}function I(t,e){return t===e||t!=t&&e!=e}function K(t,e){var r=t[e];if(null!=r){if(!S(r))throw new TypeError;return r}}function F(t){var e=K(t,o);if(!S(e))throw new TypeError;var r=e.call(t);if(!P(r))throw new TypeError;return r}function D(t){return t.value}function C(t){var e=t.next();return!e.done&&e}function N(t){var e=t.return;e&&e.call(t)}function z(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===s)return e;if(e!==s)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var i=n.constructor;return"function"!=typeof i||i===t?e:i}function H(t,e,r){var n=l.getProvider(t,e);if(!k(n))return n;if(r){if(l.setProvider(t,e,v))return v;throw new Error("Illegal state.")}}function U(t){return t.__=void 0,delete t.__,t}t("decorate",function(t,e,r,n){if(k(r)){if(!x(t))throw new TypeError;if(!A(e))throw new TypeError;return function(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!k(n)&&!T(n)){if(!A(n))throw new TypeError;e=n}}return e}(t,e)}if(!x(t))throw new TypeError;if(!P(e))throw new TypeError;if(!P(n)&&!k(n)&&!T(n))throw new TypeError;return T(n)&&(n=void 0),function(t,e,r,n){for(var i=t.length-1;i>=0;--i){var o=(0,t[i])(e,r,n);if(!k(o)&&!T(o)){if(!P(o))throw new TypeError;n=o}}return n}(t,e,r=j(r),n)}),t("metadata",function(t,e){return function(r,n){if(!P(r))throw new TypeError;if(!k(n)&&!function(t){switch(m(t)){case 3:case 4:return!0;default:return!1}}(n))throw new TypeError;b(t,e,r,n)}}),t("defineMetadata",function(t,e,r,n){if(!P(r))throw new TypeError;return k(n)||(n=j(n)),b(t,e,r,n)}),t("hasMetadata",function(t,e,r){if(!P(e))throw new TypeError;return k(r)||(r=j(r)),w(t,e,r)}),t("hasOwnMetadata",function(t,e,r){if(!P(e))throw new TypeError;return k(r)||(r=j(r)),_(t,e,r)}),t("getMetadata",function(t,e,r){if(!P(e))throw new TypeError;return k(r)||(r=j(r)),g(t,e,r)}),t("getOwnMetadata",function(t,e,r){if(!P(e))throw new TypeError;return k(r)||(r=j(r)),O(t,e,r)}),t("getMetadataKeys",function(t,e){if(!P(t))throw new TypeError;return k(e)||(e=j(e)),M(t,e)}),t("getOwnMetadataKeys",function(t,e){if(!P(t))throw new TypeError;return k(e)||(e=j(e)),E(t,e)}),t("deleteMetadata",function(t,e,r){if(!P(e))throw new TypeError;if(k(r)||(r=j(r)),!P(e))throw new TypeError;k(r)||(r=j(r));var n=H(e,r,!1);return!k(n)&&n.OrdinaryDeleteMetadata(t,e,r)})}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))}},i={};function o(t){var e=i[t];if(void 0!==e)return e.exports;var r=i[t]={exports:{}};return n[t](r,r.exports,o),r.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var a,u={};o.d(u,{d:()=>a}),o(9771),function(t){t.getParameterTypes=(t,e)=>e?Reflect.getMetadata("design:paramtypes",t,e)||[]:Reflect.getMetadata("design:paramtypes",t)||[],t.getReturnType=(t,e)=>Reflect.getMetadata("design:returntype",t,e),t.getType=(t,e)=>e?Reflect.getMetadata("design:type",t,e):Reflect.getMetadata("design:type",t),t.getMetadata=(t,e,r)=>r?Reflect.getMetadata(t,e,r):Reflect.getMetadata(t,e),t.getMetadataKeys=t=>Reflect.getMetadataKeys(t),t.getOwnMetadata=(t,e,r)=>r?Reflect.getOwnMetadata(t,e,r):Reflect.getOwnMetadata(t,e),t.getMetadatas=e=>t.getMetadataKeys(e).map(r=>t.getMetadata(r,e)),t.metadata=(t,e)=>Reflect.metadata(t,e),t.defineMetadata=(t,e,r,n)=>{n&&Reflect.defineMetadata?Reflect.defineMetadata(t,e,r,n):Reflect.defineMetadata&&Reflect.defineMetadata(t,e,r)}}(a||(a={}));const f=u.d},5118:(t,e,r)=>{var n;!function(t){t.GET="GET",t.POST="POST",t.PUT="PUT",t.DELETE="DELETE",t.PATCH="PATCH",t.HEAD="HEAD",t.OPTIONS="OPTIONS",t.TRACE="TRACE",t.CONNECT="CONNECT"}(n||(n={}))},9108:(t,e,r)=>{r.d(e,{Fz:()=>a}),r(9771);var n,i=r(5053);r(5118),function(t){t.REQ_JSON_BODY="SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY",t.REQ_FORM_URL_BODY="SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY"}(n||(n={}));const o=Symbol("MappingMetadataKey"),a=t=>(null!=t&&"object"==typeof t&&(t=t.constructor),i.d.getMetadata(o,t))},9771:()=>{var t;!function(t){!function(){var e="object"==typeof globalThis?globalThis:"object"==typeof global?global:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=n(t);function n(t,e){return function(r,n){Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0!==e.Reflect&&(r=n(e.Reflect,r)),function(t,e){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",a="function"==typeof Object.create,u={__proto__:[]}instanceof Array,f=!a&&!u,c={create:a?function(){return G(Object.create(null))}:u?function(){return G({__proto__:null})}:function(){return G({})},has:f?function(t,e){return r.call(t,e)}:function(t,e){return e in t},get:f?function(t,e){return r.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},s=Object.getPrototypeOf(Function),d="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:function(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}();return function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,K(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,n)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,a)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!K(this._cacheKey,t)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(K(this._keys[r],t)){this._cacheIndex=r;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();function n(t,e){return t}function i(t,e){return e}function a(t,e){return[t,e]}}(),y="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:function(){function t(){this._map=new d}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[o]=function(){return this.keys()},t}(),p="function"==typeof WeakMap?WeakMap:function(){var t=c.create(),e=n();return function(){function t(){this._key=n()}return t.prototype.has=function(t){var e=i(t,!1);return void 0!==e&&c.has(e,this._key)},t.prototype.get=function(t){var e=i(t,!1);return void 0!==e?c.get(e,this._key):void 0},t.prototype.set=function(t,e){return i(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=i(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=n()},t}();function n(){var e;do{e="@@WeakMap@@"+a()}while(c.has(t,e));return t[e]=!0,e}function i(t,n){if(!r.call(t,e)){if(!n)return;Object.defineProperty(t,e,{value:c.create()})}return t[e]}function o(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function a(){var t=function(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):o(e,t),e}return o(new Array(t),t)}(16);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var e="",r=0;r<16;++r){var n=t[r];4!==r&&6!==r&&8!==r||(e+="-"),n<16&&(e+="0"),e+=n.toString(16).toLowerCase()}return e}}(),h=n?Symbol.for("@reflect-metadata:registry"):void 0,l=function(){var t;return!k(h)&&P(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[h]),k(t)&&(t=function(){var t,r,n,i;k(h)||void 0===e.Reflect||h in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=function(t){var e=t.defineMetadata,r=t.hasOwnMetadata,n=t.getOwnMetadata,i=t.getOwnMetadataKeys,o=t.deleteMetadata,a=new p;return{isProviderFor:function(t,e){var r=a.get(t);return!(k(r)||!r.has(e))||!!i(t,e).length&&(k(r)&&(r=new y,a.set(t,r)),r.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:o}}(e.Reflect));var o=new p,a={registerProvider:u,getProvider:c,setProvider:l};return a;function u(e){if(!Object.isExtensible(a))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case k(r):r=e;break;case r===e:break;case k(n):n=e;break;case n===e:break;default:void 0===i&&(i=new y),i.add(e)}}function f(e,o){if(!k(r)){if(r.isProviderFor(e,o))return r;if(!k(n)){if(n.isProviderFor(e,o))return r;if(!k(i))for(var a=D(i);;){var u=N(a);if(!u)return;var f=C(u);if(f.isProviderFor(e,o))return z(a),f}}}if(!k(t)&&t.isProviderFor(e,o))return t}function c(t,e){var r,n=o.get(t);return k(n)||(r=n.get(e)),k(r)?(k(r=f(t,e))||(k(n)&&(n=new d,o.set(t,n)),n.set(e,r)),r):r}function s(t){if(k(t))throw new TypeError;return r===t||n===t||!k(i)&&i.has(t)}function l(t,e,r){if(!s(r))throw new Error("Metadata provider not registered.");var n=c(t,e);if(n!==r){if(!k(n))return!1;var i=o.get(t);k(i)&&(i=new d,o.set(t,i)),i.set(e,r)}return!0}}()),!k(h)&&P(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,h,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}(),v=function(t){var e=new p,r={isProviderFor:function(t,r){var n=e.get(t);return!k(n)&&n.has(r)},OrdinaryDefineOwnMetadata:function(t,e,r,i){n(r,i,!0).set(t,e)},OrdinaryHasOwnMetadata:function(t,e,r){var i=n(e,r,!1);return!k(i)&&j(i.has(t))},OrdinaryGetOwnMetadata:function(t,e,r){var i=n(e,r,!1);if(!k(i))return i.get(t)},OrdinaryOwnMetadataKeys:function(t,e){var r=[],i=n(t,e,!1);if(k(i))return r;for(var o=D(i.keys()),a=0;;){var u=N(o);if(!u)return r.length=a,r;var f=C(u);try{r[a]=f}catch(t){try{z(o)}finally{throw t}}a++}},OrdinaryDeleteMetadata:function(t,r,i){var o=n(r,i,!1);if(k(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var a=e.get(r);k(a)||(a.delete(i),0===a.size&&e.delete(a))}return!0}};return l.registerProvider(r),r;function n(n,i,o){var a=e.get(n),u=!1;if(k(a)){if(!o)return;a=new d,e.set(n,a),u=!0}var f=a.get(i);if(k(f)){if(!o)return;if(f=new d,a.set(i,f),!t.setProvider(n,i,r))throw a.delete(i),u&&e.delete(n),new Error("Wrong provider for target.")}return f}}(l);function w(t,e,r){if(_(t,e,r))return!0;var n=H(e);return!T(n)&&w(t,n,r)}function _(t,e,r){var n=U(e,r,!1);return!k(n)&&j(n.OrdinaryHasOwnMetadata(t,e,r))}function g(t,e,r){if(_(t,e,r))return O(t,e,r);var n=H(e);return T(n)?void 0:g(t,n,r)}function O(t,e,r){var n=U(e,r,!1);if(!k(n))return n.OrdinaryGetOwnMetadata(t,e,r)}function b(t,e,r,n){U(r,n,!0).OrdinaryDefineOwnMetadata(t,e,r,n)}function M(t,e){var r=E(t,e),n=H(t);if(null===n)return r;var i=M(n,e);if(i.length<=0)return r;if(r.length<=0)return i;for(var o=new y,a=[],u=0,f=r;u<f.length;u++){var c=f[u];o.has(c)||(o.add(c),a.push(c))}for(var s=0,d=i;s<d.length;s++)c=d[s],o.has(c)||(o.add(c),a.push(c));return a}function E(t,e){var r=U(t,e,!1);return r?r.OrdinaryOwnMetadataKeys(t,e):[]}function m(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function k(t){return void 0===t}function T(t){return null===t}function P(t){return"object"==typeof t?null!==t:"function"==typeof t}function R(t,e){switch(m(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r=3===e?"string":5===e?"number":"default",n=F(t,i);if(void 0!==n){var o=n.call(t,r);if(P(o))throw new TypeError;return o}return function(t,e){if("string"===e){var r=t.toString;if(A(r)&&!P(i=r.call(t)))return i;if(A(n=t.valueOf)&&!P(i=n.call(t)))return i}else{var n;if(A(n=t.valueOf)&&!P(i=n.call(t)))return i;var i,o=t.toString;if(A(o)&&!P(i=o.call(t)))return i}throw new TypeError}(t,"default"===r?"number":r)}function j(t){return!!t}function x(t){var e=R(t,3);return"symbol"==typeof e?e:function(t){return""+t}(e)}function S(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function A(t){return"function"==typeof t}function I(t){return"function"==typeof t}function K(t,e){return t===e||t!=t&&e!=e}function F(t,e){var r=t[e];if(null!=r){if(!A(r))throw new TypeError;return r}}function D(t){var e=F(t,o);if(!A(e))throw new TypeError;var r=e.call(t);if(!P(r))throw new TypeError;return r}function C(t){return t.value}function N(t){var e=t.next();return!e.done&&e}function z(t){var e=t.return;e&&e.call(t)}function H(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===s)return e;if(e!==s)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var i=n.constructor;return"function"!=typeof i||i===t?e:i}function U(t,e,r){var n=l.getProvider(t,e);if(!k(n))return n;if(r){if(l.setProvider(t,e,v))return v;throw new Error("Illegal state.")}}function G(t){return t.__=void 0,delete t.__,t}t("decorate",function(t,e,r,n){if(k(r)){if(!S(t))throw new TypeError;if(!I(e))throw new TypeError;return function(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!k(n)&&!T(n)){if(!I(n))throw new TypeError;e=n}}return e}(t,e)}if(!S(t))throw new TypeError;if(!P(e))throw new TypeError;if(!P(n)&&!k(n)&&!T(n))throw new TypeError;return T(n)&&(n=void 0),function(t,e,r,n){for(var i=t.length-1;i>=0;--i){var o=(0,t[i])(e,r,n);if(!k(o)&&!T(o)){if(!P(o))throw new TypeError;n=o}}return n}(t,e,r=x(r),n)}),t("metadata",function(t,e){return function(r,n){if(!P(r))throw new TypeError;if(!k(n)&&!function(t){switch(m(t)){case 3:case 4:return!0;default:return!1}}(n))throw new TypeError;b(t,e,r,n)}}),t("defineMetadata",function(t,e,r,n){if(!P(r))throw new TypeError;return k(n)||(n=x(n)),b(t,e,r,n)}),t("hasMetadata",function(t,e,r){if(!P(e))throw new TypeError;return k(r)||(r=x(r)),w(t,e,r)}),t("hasOwnMetadata",function(t,e,r){if(!P(e))throw new TypeError;return k(r)||(r=x(r)),_(t,e,r)}),t("getMetadata",function(t,e,r){if(!P(e))throw new TypeError;return k(r)||(r=x(r)),g(t,e,r)}),t("getOwnMetadata",function(t,e,r){if(!P(e))throw new TypeError;return k(r)||(r=x(r)),O(t,e,r)}),t("getMetadataKeys",function(t,e){if(!P(t))throw new TypeError;return k(e)||(e=x(e)),M(t,e)}),t("getOwnMetadataKeys",function(t,e){if(!P(t))throw new TypeError;return k(e)||(e=x(e)),E(t,e)}),t("deleteMetadata",function(t,e,r){if(!P(e))throw new TypeError;if(k(r)||(r=x(r)),!P(e))throw new TypeError;k(r)||(r=x(r));var n=U(e,r,!1);return!k(n)&&n.OrdinaryDeleteMetadata(t,e,r)})}(r,e),void 0===e.Reflect&&(e.Reflect=t)}()}(t||(t={}))}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};r.d(n,{A:()=>u});var i=r(229),o=r(9108);const a={openapi:"3.0.1",info:{title:"SimpleBootHttpServer OpenApi3",description:"SimpleBootHttpServer OpenApi3"}};class u{constructor(t,e){this.config=t,this.openApiConfig=Object.assign(Object.assign({},a),e??{})}async onInit(t){}async proceedBefore({rr:t,app:e}){if(t.reqUrl===this.config.path){const r=e.routerManager.routingMap(),n={paths:{}};return Object.entries(r).filter(([t,e])=>"string"!=typeof e).forEach(([t,e])=>{const r=n.paths[t]={};(0,o.Fz)(e)?.forEach(t=>{r[t.config.method]={summary:t.propertyKey,description:t.propertyKey}})}),t.resWriteJson(Object.assign(Object.assign({},this.openApiConfig),n)).resStatusCode(i.t.Ok).resEnd(),!1}return!0}async proceedAfter({rr:t,app:e}){return!0}}const f=n.A;export{f as OpenApi3Filter};
|
|
1
|
+
// src/decorators/MethodMapping.ts
|
|
2
|
+
import "reflect-metadata";
|
|
3
|
+
import { ReflectUtils } from "@dooboostore/core/reflect/ReflectUtils";
|
|
4
|
+
var MappingMetadataKey = Symbol("MappingMetadataKey");
|
|
5
|
+
var getUrlMappings = (target) => {
|
|
6
|
+
if (target !== null && void 0 !== target && typeof target === "object") {
|
|
7
|
+
target = target.constructor;
|
|
8
|
+
}
|
|
9
|
+
return ReflectUtils.getMetadata(MappingMetadataKey, target);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/filters/OpenApi3Filter.ts
|
|
13
|
+
var DefulatData = {
|
|
14
|
+
openapi: "3.0.1",
|
|
15
|
+
info: {
|
|
16
|
+
title: "SimpleBootHttpServer OpenApi3",
|
|
17
|
+
description: "SimpleBootHttpServer OpenApi3"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var OpenApi3Filter = class {
|
|
21
|
+
constructor(config, openApiConfig) {
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.openApiConfig = Object.assign(Object.assign({}, DefulatData), openApiConfig ?? {});
|
|
24
|
+
}
|
|
25
|
+
async onInit(app) {
|
|
26
|
+
}
|
|
27
|
+
async proceedBefore({ rr, app }) {
|
|
28
|
+
if (rr.reqUrl === this.config.path) {
|
|
29
|
+
const map = app.routerManager.routingMap();
|
|
30
|
+
const data = {
|
|
31
|
+
paths: {}
|
|
32
|
+
};
|
|
33
|
+
Object.entries(map).filter(([k, v]) => typeof v !== "string").forEach(([k, v]) => {
|
|
34
|
+
const method = data.paths[k] = {};
|
|
35
|
+
getUrlMappings(v)?.forEach((it) => {
|
|
36
|
+
method[it.config.method] = {
|
|
37
|
+
summary: it.propertyKey,
|
|
38
|
+
description: it.propertyKey
|
|
39
|
+
// operationId: it.operationId,
|
|
40
|
+
// parameters: it.parameters,
|
|
41
|
+
// responses: it.responses,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
rr.resWriteJson(Object.assign(Object.assign({}, this.openApiConfig), data)).resStatusCode(200 /* Ok */).resEnd();
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
async proceedAfter({ rr, app }) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
OpenApi3Filter
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=OpenApi3Filter.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/decorators/MethodMapping.ts", "../../../src/filters/OpenApi3Filter.ts"],
|
|
4
|
+
"sourcesContent": ["import 'reflect-metadata';\nimport { ConstructorType } from '@dooboostore/core/types';\nimport { ReflectMethod } from '@dooboostore/simple-boot/types/Types';\nimport { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { Resolver } from '../resolvers/Resolver';\nimport { Mimes } from '../codes/Mimes';\nimport { HttpMethod } from '../codes/HttpMethod';\n\nexport enum UrlMappingSituationType {\n REQ_JSON_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY',\n REQ_FORM_URL_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY'\n}\nexport type MappingConfig = {\n method: HttpMethod | string,\n description?: {\n name?: string;\n detail?: string;\n };\n\n req?: {\n contentType?: (Mimes|string)[];\n accept?: (Mimes|string)[];\n };\n\n res?: {\n status?: number;\n header?: {[key: string]: string};\n contentType?: Mimes | string;\n }\n resolver?: Resolver|ConstructorType<Resolver>;\n}\nexport type SaveMappingConfig = {propertyKey: string | symbol; config: MappingConfig}\nconst MappingMetadataKey = Symbol('MappingMetadataKey');\n// const GETSMappingMetadataKey = Symbol('GET_METHODS');\n// const GETMappingMetadataKey = Symbol('GET_METHOD');\n\nconst process = (config: MappingConfig, target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const saveMappingConfigs = (ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? []) as SaveMappingConfig[];\n saveMappingConfigs.push({propertyKey, config});\n ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);\n ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey);\n}\nexport function UrlMapping(config: MappingConfig): ReflectMethod;\nexport function UrlMapping(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function UrlMapping(configOrtarget?: MappingConfig | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.GET}, configOrtarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n process(configOrtarget, target, propertyKey, descriptor);\n }\n }\n}\nexport const getUrlMapping = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);\n}\n\nexport const getUrlMappings = (target: any): SaveMappingConfig[] => {\n if (target !== null && undefined !== target && typeof target === 'object') {\n target = target.constructor;\n }\n return ReflectUtils.getMetadata(MappingMetadataKey, target);\n}\nexport function GET(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function GET(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function GET(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.GET}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.GET;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getGET = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getGETS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function POST(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function POST(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function POST(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.POST}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.POST;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPOST = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPOSTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.POST);\n}\nexport function DELETE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function DELETE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function DELETE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.DELETE}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.DELETE;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getDELETE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getDELETES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.DELETE);\n}\nexport function PUT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PUT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PUT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.PUT}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PUT;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPUT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPUTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PUT);\n}\nexport function PATCH(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PATCH(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PATCH(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.PATCH}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PATCH;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPATCH = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPATCHS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function OPTIONS(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function OPTIONS(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function OPTIONS(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.OPTIONS}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.OPTIONS;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getOPTIONS = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getOPTIONSS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.OPTIONS);\n}\nexport function HEAD(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function HEAD(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function HEAD(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.HEAD}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.HEAD;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getHEAD = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getHEADS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function TRACE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function TRACE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function TRACE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.TRACE}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.TRACE;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getTRACE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getTRACES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.TRACE);\n}\nexport function CONNECT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function CONNECT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function CONNECT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.CONNECT}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.CONNECT;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getCONNECT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getCONNECTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.CONNECT);\n}\n", "import {Filter} from './Filter';\nimport {HttpStatus} from '../codes/HttpStatus';\nimport {SimpleBootHttpServer} from '../SimpleBootHttpServer';\nimport {RequestResponse} from '../models/RequestResponse';\nimport {getUrlMappings} from '../decorators/MethodMapping';\n\ntype MethodType = {\n summary?: string;\n description?: string;\n operationId?: string;\n parameters?: {\n name: string;\n in: string;\n required: boolean;\n schema: {\n type: string;\n format?: string;\n items?: {\n type: string;\n format?: string;\n }\n }\n }[];\n responses: {\n [code: string]: {\n description: string;\n content?: {\n [type: string]: {\n schema: {\n type: string;\n format?: string;\n items?: {\n type: string;\n format?: string;\n }\n }\n }\n }\n }\n }\n};\ntype PathType = {\n [method: string]: MethodType\n};\ntype PathsType = {\n [path: string]: PathType\n};\nexport type OpenApiType = {\n openapi: string;\n info?: {\n title?: string;\n description?: string;\n contact?: {\n name?: string;\n email?: string;\n }\n }\n servers?: { url: string }[],\n paths?: PathsType\n components?: {\n schemas?: {\n [key: string]: {\n type: string;\n required?: string[];\n properties?: {\n [key: string]: {\n type: string;\n format?: string;\n items?: {\n type: string;\n format?: string;\n }\n }\n }\n }\n }\n securitySchemes?: {\n [key: string]: {\n type: string;\n description?: string;\n in?: string;\n name?: string;\n scheme?: string;\n bearerFormat?: string;\n flows?: {\n [key: string]: {\n authorizationUrl?: string;\n tokenUrl?: string;\n refreshUrl?: string;\n scopes?: {\n [key: string]: {\n description?: string;\n }\n }\n }\n }\n }\n }\n }\n}\nexport type OpenApi3FilterConfig = {\n info?: {\n title?: string;\n description?: string;\n contact?: {\n name?: string;\n email?: string;\n }\n }\n servers?: { url: string }[],\n}\nconst DefulatData: OpenApiType = {\n openapi: '3.0.1',\n info: {\n title: 'SimpleBootHttpServer OpenApi3',\n description: 'SimpleBootHttpServer OpenApi3',\n }\n}\n\nexport class OpenApi3Filter implements Filter {\n private openApiConfig: any;\n\n constructor(public config: { path: string, excludePath?: { method: string, path: string }[] }, openApiConfig?: OpenApi3FilterConfig) {\n this.openApiConfig = Object.assign(Object.assign({}, DefulatData), openApiConfig ?? {})\n }\n async onInit(app: SimpleBootHttpServer){\n }\n async proceedBefore({rr, app}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n if (rr.reqUrl === this.config.path) {\n const map = app.routerManager.routingMap();\n // let routers = app.simstanceManager.getSimAtomics().filter((it: SimAtomic) => it.getConfig(RouterMetadataKey));\n const data = {\n paths: {} as PathsType\n } as OpenApiType;\n\n Object.entries(map).filter(([k, v]) => typeof v !== 'string').forEach(([k, v]) => {\n const method = data.paths![k] = {} as PathType;\n getUrlMappings(v)?.forEach(it => {\n method[it.config.method] = {\n summary: it.propertyKey,\n description: it.propertyKey\n // operationId: it.operationId,\n // parameters: it.parameters,\n // responses: it.responses,\n } as MethodType\n });\n })\n\n rr.resWriteJson(Object.assign(Object.assign({}, this.openApiConfig), data)).resStatusCode(HttpStatus.Ok).resEnd();\n return false;\n }\n return true;\n }\n\n async proceedAfter({rr, app}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n return true;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO;AAGP,SAAS,oBAAoB;AA6B7B,IAAM,qBAAqB,OAAO,oBAAoB;AAyB/C,IAAM,iBAAiB,CAAC,WAAqC;AAChE,MAAI,WAAW,QAAQ,WAAc,UAAU,OAAO,WAAW,UAAU;AACvE,aAAS,OAAO;AAAA,EACpB;AACA,SAAO,aAAa,YAAY,oBAAoB,MAAM;AAC9D;;;ACiDA,IAAM,cAA2B;AAAA,EAC7B,SAAS;AAAA,EACT,MAAM;AAAA,IACF,OAAO;AAAA,IACP,aAAa;AAAA,EACjB;AACJ;AAEO,IAAM,iBAAN,MAAuC;AAAA,EAG1C,YAAmB,QAA4E,eAAsC;AAAlH;AACf,SAAK,gBAAgB,OAAO,OAAO,OAAO,OAAO,CAAC,GAAG,WAAW,GAAG,iBAAiB,CAAC,CAAC;AAAA,EAC1F;AAAA,EACA,MAAM,OAAO,KAA0B;AAAA,EACvC;AAAA,EACA,MAAM,cAAc,EAAC,IAAI,IAAG,GAAgF;AACxG,QAAI,GAAG,WAAW,KAAK,OAAO,MAAM;AAChC,YAAM,MAAM,IAAI,cAAc,WAAW;AAEzC,YAAM,OAAO;AAAA,QACT,OAAO,CAAC;AAAA,MACZ;AAEA,aAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM;AAC9E,cAAM,SAAS,KAAK,MAAO,CAAC,IAAI,CAAC;AACjC,uBAAe,CAAC,GAAG,QAAQ,QAAM;AAC7B,iBAAO,GAAG,OAAO,MAAM,IAAI;AAAA,YACvB,SAAS,GAAG;AAAA,YACZ,aAAa,GAAG;AAAA;AAAA;AAAA;AAAA,UAIpB;AAAA,QACJ,CAAC;AAAA,MACL,CAAC;AAED,SAAG,aAAa,OAAO,OAAO,OAAO,OAAO,CAAC,GAAG,KAAK,aAAa,GAAG,IAAI,CAAC,EAAE,0BAA2B,EAAE,OAAO;AAChH,aAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX;AAAA,EAEA,MAAM,aAAa,EAAC,IAAI,IAAG,GAAgF;AACvG,WAAO;AAAA,EACX;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|