@dooboostore/simple-boot-http-server 1.0.24 → 1.0.26

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.
Files changed (190) hide show
  1. package/README.md +113 -0
  2. package/dist/cjs/SimpleBootHttpServer.js +16 -4
  3. package/dist/cjs/SimpleBootHttpServer.js.map +2 -2
  4. package/dist/cjs/bundle-entry.js +34 -24
  5. package/dist/cjs/bundle-entry.js.map +2 -2
  6. package/dist/cjs/decorators/MethodMapping.js +33 -3
  7. package/dist/cjs/decorators/MethodMapping.js.map +2 -2
  8. package/dist/cjs/errors/BadRequestError.js +2 -1
  9. package/dist/cjs/errors/BadRequestError.js.map +2 -2
  10. package/dist/cjs/errors/ForbiddenError.js +2 -1
  11. package/dist/cjs/errors/ForbiddenError.js.map +2 -2
  12. package/dist/cjs/errors/InternalServerError.js +2 -1
  13. package/dist/cjs/errors/InternalServerError.js.map +2 -2
  14. package/dist/cjs/errors/NotFoundError.js +2 -1
  15. package/dist/cjs/errors/NotFoundError.js.map +2 -2
  16. package/dist/cjs/errors/UnauthorizedError.js +2 -1
  17. package/dist/cjs/errors/UnauthorizedError.js.map +2 -2
  18. package/dist/cjs/filters/IntentSchemeFilter.js +1 -2
  19. package/dist/cjs/filters/IntentSchemeFilter.js.map +2 -2
  20. package/dist/cjs/filters/ResourceFilter.js +3 -2
  21. package/dist/cjs/filters/ResourceFilter.js.map +2 -2
  22. package/dist/cjs/filters/index.js +3 -1
  23. package/dist/cjs/filters/index.js.map +2 -2
  24. package/dist/cjs/index.js +2 -0
  25. package/dist/cjs/index.js.map +2 -2
  26. package/dist/cjs/inject/InjectSituationType.js +1 -1
  27. package/dist/cjs/inject/InjectSituationType.js.map +2 -2
  28. package/dist/cjs/models/RequestResponse.js +19 -2
  29. package/dist/cjs/models/RequestResponse.js.map +2 -2
  30. package/dist/cjs/models/datas/body/index.js +28 -0
  31. package/dist/cjs/models/datas/body/index.js.map +7 -0
  32. package/dist/cjs/models/datas/index.js +32 -0
  33. package/dist/cjs/models/datas/index.js.map +7 -0
  34. package/dist/cjs/models/datas/{body → path}/ReqPathData.js.map +1 -1
  35. package/dist/cjs/models/datas/{search → path}/ReqSearchParamsObj.js.map +1 -1
  36. package/dist/cjs/models/datas/path/index.js +24 -0
  37. package/dist/cjs/models/datas/path/index.js.map +7 -0
  38. package/dist/cjs/models/index.js +4 -16
  39. package/dist/cjs/models/index.js.map +2 -2
  40. package/dist/cjs/models/method/index.js +22 -0
  41. package/dist/cjs/models/method/index.js.map +7 -0
  42. package/dist/cjs/models/method/patch/index.js +22 -0
  43. package/dist/cjs/models/method/patch/index.js.map +7 -0
  44. package/dist/cjs/option/HttpServerOption.js.map +2 -2
  45. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js +98 -95
  46. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js.map +3 -3
  47. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js +1 -1
  48. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js.map +2 -2
  49. package/dist/cjs/proxy/TopicProtocolApiServiceProxy.js +244 -266
  50. package/dist/cjs/proxy/TopicProtocolApiServiceProxy.js.map +3 -3
  51. package/dist/cjs/websocket/WebSocketClient.js +2 -1
  52. package/dist/cjs/websocket/WebSocketClient.js.map +2 -2
  53. package/dist/esm/SimpleBootHttpServer.js +16 -4
  54. package/dist/esm/SimpleBootHttpServer.js.map +2 -2
  55. package/dist/esm/bundle-entry.js +14 -12
  56. package/dist/esm/bundle-entry.js.map +2 -2
  57. package/dist/esm/decorators/MethodMapping.js +22 -2
  58. package/dist/esm/decorators/MethodMapping.js.map +2 -2
  59. package/dist/esm/errors/BadRequestError.js +2 -1
  60. package/dist/esm/errors/BadRequestError.js.map +2 -2
  61. package/dist/esm/errors/ForbiddenError.js +2 -1
  62. package/dist/esm/errors/ForbiddenError.js.map +2 -2
  63. package/dist/esm/errors/InternalServerError.js +2 -1
  64. package/dist/esm/errors/InternalServerError.js.map +2 -2
  65. package/dist/esm/errors/NotFoundError.js +2 -1
  66. package/dist/esm/errors/NotFoundError.js.map +2 -2
  67. package/dist/esm/errors/UnauthorizedError.js +2 -1
  68. package/dist/esm/errors/UnauthorizedError.js.map +2 -2
  69. package/dist/esm/filters/IntentSchemeFilter.js +2 -3
  70. package/dist/esm/filters/IntentSchemeFilter.js.map +2 -2
  71. package/dist/esm/filters/ResourceFilter.js +3 -2
  72. package/dist/esm/filters/ResourceFilter.js.map +2 -2
  73. package/dist/esm/filters/index.js +1 -0
  74. package/dist/esm/filters/index.js.map +2 -2
  75. package/dist/esm/index.js +1 -0
  76. package/dist/esm/index.js.map +2 -2
  77. package/dist/esm/inject/InjectSituationType.js +1 -1
  78. package/dist/esm/inject/InjectSituationType.js.map +2 -2
  79. package/dist/esm/models/RequestResponse.js +19 -2
  80. package/dist/esm/models/RequestResponse.js.map +2 -2
  81. package/dist/esm/models/datas/body/index.js +5 -0
  82. package/dist/esm/models/datas/body/index.js.map +7 -0
  83. package/dist/esm/models/datas/index.js +7 -0
  84. package/dist/esm/models/datas/index.js.map +7 -0
  85. package/dist/esm/models/datas/{body → path}/ReqPathData.js.map +1 -1
  86. package/dist/esm/models/datas/{search → path}/ReqSearchParamsObj.js.map +1 -1
  87. package/dist/esm/models/datas/path/index.js +3 -0
  88. package/dist/esm/models/datas/path/index.js.map +7 -0
  89. package/dist/esm/models/index.js +2 -8
  90. package/dist/esm/models/index.js.map +2 -2
  91. package/dist/esm/models/method/index.js +2 -0
  92. package/dist/esm/models/method/index.js.map +7 -0
  93. package/dist/esm/models/method/patch/index.js +2 -0
  94. package/dist/esm/models/method/patch/index.js.map +7 -0
  95. package/dist/esm/option/HttpServerOption.js.map +2 -2
  96. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js +98 -95
  97. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js.map +3 -3
  98. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js +2 -2
  99. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js.map +2 -2
  100. package/dist/esm/proxy/TopicProtocolApiServiceProxy.js +244 -266
  101. package/dist/esm/proxy/TopicProtocolApiServiceProxy.js.map +3 -3
  102. package/dist/esm/websocket/WebSocketClient.js +3 -2
  103. package/dist/esm/websocket/WebSocketClient.js.map +2 -2
  104. package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +19374 -4956
  105. package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +4 -4
  106. package/dist/types/SimpleBootHttpServer.d.ts +1 -1
  107. package/dist/types/SimpleBootHttpServer.d.ts.map +1 -1
  108. package/dist/types/bundle-entry.d.ts +7 -12
  109. package/dist/types/bundle-entry.d.ts.map +1 -1
  110. package/dist/types/decorators/MethodMapping.d.ts +10 -0
  111. package/dist/types/decorators/MethodMapping.d.ts.map +1 -1
  112. package/dist/types/errors/BadRequestError.d.ts +2 -2
  113. package/dist/types/errors/BadRequestError.d.ts.map +1 -1
  114. package/dist/types/errors/ForbiddenError.d.ts +2 -2
  115. package/dist/types/errors/ForbiddenError.d.ts.map +1 -1
  116. package/dist/types/errors/InternalServerError.d.ts +2 -2
  117. package/dist/types/errors/InternalServerError.d.ts.map +1 -1
  118. package/dist/types/errors/NotFoundError.d.ts +2 -2
  119. package/dist/types/errors/NotFoundError.d.ts.map +1 -1
  120. package/dist/types/errors/UnauthorizedError.d.ts +2 -2
  121. package/dist/types/errors/UnauthorizedError.d.ts.map +1 -1
  122. package/dist/types/filters/ResourceFilter.d.ts.map +1 -1
  123. package/dist/types/filters/index.d.ts +1 -0
  124. package/dist/types/filters/index.d.ts.map +1 -1
  125. package/dist/types/index.d.ts +1 -0
  126. package/dist/types/index.d.ts.map +1 -1
  127. package/dist/types/inject/InjectSituationType.d.ts.map +1 -1
  128. package/dist/types/models/RequestResponse.d.ts +3 -1
  129. package/dist/types/models/RequestResponse.d.ts.map +1 -1
  130. package/dist/types/models/datas/body/index.d.ts +5 -0
  131. package/dist/types/models/datas/body/index.d.ts.map +1 -0
  132. package/dist/types/models/datas/index.d.ts +7 -0
  133. package/dist/types/models/datas/index.d.ts.map +1 -0
  134. package/dist/types/models/datas/{body → path}/ReqPathData.d.ts.map +1 -1
  135. package/dist/types/models/datas/path/ReqSearchParamsObj.d.ts.map +1 -0
  136. package/dist/types/models/datas/path/index.d.ts +3 -0
  137. package/dist/types/models/datas/path/index.d.ts.map +1 -0
  138. package/dist/types/models/index.d.ts +2 -8
  139. package/dist/types/models/index.d.ts.map +1 -1
  140. package/dist/types/models/method/index.d.ts +2 -0
  141. package/dist/types/models/method/index.d.ts.map +1 -0
  142. package/dist/types/models/method/patch/index.d.ts +2 -0
  143. package/dist/types/models/method/patch/index.d.ts.map +1 -0
  144. package/dist/types/option/HttpServerOption.d.ts +6 -2
  145. package/dist/types/option/HttpServerOption.d.ts.map +1 -1
  146. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts +6 -8
  147. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts.map +1 -1
  148. package/dist/types/proxy/TopicProtocolApiServiceProxy.d.ts +5 -15
  149. package/dist/types/proxy/TopicProtocolApiServiceProxy.d.ts.map +1 -1
  150. package/dist/types/websocket/WebSocketClient.d.ts.map +1 -1
  151. package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +19340 -4928
  152. package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +4 -4
  153. package/dist/umd-bundle/websocket-client.umd.js +378 -1468
  154. package/dist/umd-bundle/websocket-client.umd.js.map +4 -4
  155. package/package.json +8 -8
  156. package/src/SimpleBootHttpServer.ts +20 -6
  157. package/src/bundle-entry.ts +12 -12
  158. package/src/decorators/MethodMapping.ts +13 -1
  159. package/src/errors/BadRequestError.ts +7 -3
  160. package/src/errors/ForbiddenError.ts +7 -3
  161. package/src/errors/InternalServerError.ts +7 -3
  162. package/src/errors/NotFoundError.ts +7 -3
  163. package/src/errors/UnauthorizedError.ts +7 -3
  164. package/src/filters/IntentSchemeFilter.ts +2 -2
  165. package/src/filters/ResourceFilter.ts +5 -2
  166. package/src/filters/index.ts +1 -0
  167. package/src/index.ts +1 -0
  168. package/src/inject/InjectSituationType.ts +1 -1
  169. package/src/models/RequestResponse.ts +28 -2
  170. package/src/models/datas/body/index.ts +4 -0
  171. package/src/models/datas/index.ts +6 -0
  172. package/src/models/datas/path/index.ts +2 -0
  173. package/src/models/index.ts +2 -8
  174. package/src/models/method/index.ts +1 -0
  175. package/src/models/method/patch/index.ts +1 -0
  176. package/src/option/HttpServerOption.ts +4 -2
  177. package/src/proxy/SymbolIntentApiServiceProxy.ts +103 -97
  178. package/src/proxy/SymbolIntentApiServiceProxyBase.ts +2 -2
  179. package/src/proxy/TopicProtocolApiServiceProxy.ts +260 -275
  180. package/src/websocket/WebSocketClient.ts +3 -2
  181. package/README.MD +0 -62
  182. package/dist/types/models/datas/search/ReqSearchParamsObj.d.ts.map +0 -1
  183. /package/dist/cjs/models/datas/{body → path}/ReqPathData.js +0 -0
  184. /package/dist/cjs/models/datas/{search → path}/ReqSearchParamsObj.js +0 -0
  185. /package/dist/esm/models/datas/{body → path}/ReqPathData.js +0 -0
  186. /package/dist/esm/models/datas/{search → path}/ReqSearchParamsObj.js +0 -0
  187. /package/dist/types/models/datas/{body → path}/ReqPathData.d.ts +0 -0
  188. /package/dist/types/models/datas/{search → path}/ReqSearchParamsObj.d.ts +0 -0
  189. /package/src/models/datas/{body → path}/ReqPathData.ts +0 -0
  190. /package/src/models/datas/{search → path}/ReqSearchParamsObj.ts +0 -0
@@ -7,7 +7,7 @@ var UrlMappingSituationType = /* @__PURE__ */ ((UrlMappingSituationType2) => {
7
7
  UrlMappingSituationType2["REQ_FORM_URL_BODY"] = "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY";
8
8
  return UrlMappingSituationType2;
9
9
  })(UrlMappingSituationType || {});
10
- const MappingMetadataKey = Symbol("MappingMetadataKey");
10
+ const MappingMetadataKey = Symbol.for("simple-boot-http-server:mapping-metadata");
11
11
  const process = (config, target, propertyKey, descriptor) => {
12
12
  const saveMappingConfigs = ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? [];
13
13
  saveMappingConfigs.push({ propertyKey, config });
@@ -176,6 +176,16 @@ const getCONNECT = (target, propertyKey) => {
176
176
  const getCONNECTS = (target) => {
177
177
  return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.CONNECT);
178
178
  };
179
+ const urlMapping = UrlMapping;
180
+ const getMethod = GET;
181
+ const postMethod = POST;
182
+ const patchMethod = PATCH;
183
+ const putMethod = PUT;
184
+ const deleteMethod = DELETE;
185
+ const optionsMethod = OPTIONS;
186
+ const headMethod = HEAD;
187
+ const traceMethod = TRACE;
188
+ const connectMethod = CONNECT;
179
189
  export {
180
190
  CONNECT,
181
191
  DELETE,
@@ -188,6 +198,8 @@ export {
188
198
  TRACE,
189
199
  UrlMapping,
190
200
  UrlMappingSituationType,
201
+ connectMethod,
202
+ deleteMethod,
191
203
  getCONNECT,
192
204
  getCONNECTS,
193
205
  getDELETE,
@@ -196,6 +208,7 @@ export {
196
208
  getGETS,
197
209
  getHEAD,
198
210
  getHEADS,
211
+ getMethod,
199
212
  getOPTIONS,
200
213
  getOPTIONSS,
201
214
  getPATCH,
@@ -207,6 +220,13 @@ export {
207
220
  getTRACE,
208
221
  getTRACES,
209
222
  getUrlMapping,
210
- getUrlMappings
223
+ getUrlMappings,
224
+ headMethod,
225
+ optionsMethod,
226
+ patchMethod,
227
+ postMethod,
228
+ putMethod,
229
+ traceMethod,
230
+ urlMapping
211
231
  };
212
232
  //# sourceMappingURL=MethodMapping.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/decorators/MethodMapping.ts"],
4
- "sourcesContent": ["import { ConstructorType } from '@dooboostore/core';\nimport { ReflectMethod } from '@dooboostore/simple-boot';\nimport { ReflectUtils } from '@dooboostore/core';\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_PATH_DATA = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_PATH_DATA',\n // REQ_URL_SEARCH_PARAMS = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS',\n REQ_URL_SEARCH_PARAMS_OBJ = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS_OBJ',\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"],
5
- "mappings": "AAEA,SAAS,oBAAoB;AAG7B,SAAS,kBAAkB;AAEpB,IAAK,0BAAL,kBAAKA,6BAAL;AACH,EAAAA,yBAAA,mBAAgB;AAChB,EAAAA,yBAAA,mBAAgB;AAEhB,EAAAA,yBAAA,+BAA4B;AAC5B,EAAAA,yBAAA,uBAAoB;AALZ,SAAAA;AAAA,GAAA;AA2BZ,MAAM,qBAAqB,OAAO,oBAAoB;AAItD,MAAM,UAAU,CAAC,QAAuB,QAAa,aAA8B,eAAmC;AAClH,QAAM,qBAAsB,aAAa,YAAY,oBAAoB,OAAO,WAAW,KAAK,CAAC;AACjG,qBAAmB,KAAK,EAAC,aAAa,OAAM,CAAC;AAC7C,eAAa,eAAe,oBAAoB,oBAAoB,OAAO,WAAW;AACtF,eAAa,eAAe,oBAAoB,QAAQ,QAAQ,WAAW;AAC/E;AAGO,SAAS,WAAW,gBAAsC,aAA+B,YAAuD;AACnJ,MAAI,eAAe,YAAY;AAC3B,YAAQ,EAAC,QAAQ,WAAW,IAAG,GAAG,gBAAgB,aAAa,UAAU;AAAA,EAC7E,OAAO;AACH,WAAO,CAAC,QAAaC,cAA8BC,gBAAmC;AAClF,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IAC3D;AAAA,EACJ;AACJ;AACO,MAAM,gBAAgB,CAAC,QAAa,gBAA4D;AACnG,SAAO,aAAa,YAAY,oBAAoB,QAAQ,WAAW;AAC3E;A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AAW,MAAK,GAAG,gBAAgB,aAAa,UAAU;AAAA,EAC/E,OAAO;AACH,WAAO,CAAC,QAAaD,cAA8BC,gBAAmC;AAClF,qBAAe,SAAS,WAAW;AACnC,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IAC3D;AAAA,EACJ;AACJ;AAEO,MAAM,WAAW,CAAC,QAAa,gBAA4D;AAC9F,SAAO,cAAc,QAAQ,WAAW;AAC5C;AACO,MAAM,YAAY,CAAC,WAAqC;AAC3D,SAAO,eAAe,MAAM,GAAG,OAAO,QAAM,GAAG,QAAQ,OAAO,YAAY,MAAM,WAAW,KAAK;AACpG;AAGO,SAAS,QAAQ,gBAAsD,aAA+B,YAAuD;AAChK,MAAI,eAAe,YAAY;AAC3B,YAAQ,EAAC,QAAQ,WAAW,QAAO,GAAG,gBAAgB,aAAa,UAAU;AAAA,EACjF,OAAO;AACH,WAAO,CAAC,QAAaD,cAA8BC,gBAAmC;AAClF,qBAAe,SAAS,WAAW;AACnC,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IAC3D;AAAA,EACJ;AACJ;AAEO,MAAM,aAAa,CAAC,QAAa,gBAA4D;AAChG,SAAO,cAAc,QAAQ,WAAW;AAC5C;AACO,MAAM,cAAc,CAAC,WAAqC;AAC7D,SAAO,eAAe,MAAM,GAAG,OAAO,QAAM,GAAG,QAAQ,OAAO,YAAY,MAAM,WAAW,OAAO;AACtG;",
4
+ "sourcesContent": ["import { ConstructorType } from '@dooboostore/core';\nimport { ReflectMethod } from '@dooboostore/simple-boot';\nimport { ReflectUtils } from '@dooboostore/core';\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_PATH_DATA = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_PATH_DATA',\n // REQ_URL_SEARCH_PARAMS = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS',\n REQ_URL_SEARCH_PARAMS_OBJ = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS_OBJ',\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.for('simple-boot-http-server:mapping-metadata');\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\n// Aliases for lowercase\nexport const urlMapping = UrlMapping;\nexport const getMethod = GET;\nexport const postMethod = POST;\nexport const patchMethod = PATCH;\nexport const putMethod = PUT;\nexport const deleteMethod = DELETE;\nexport const optionsMethod = OPTIONS;\nexport const headMethod = HEAD;\nexport const traceMethod = TRACE;\nexport const connectMethod = CONNECT;\n"],
5
+ "mappings": "AAEA,SAAS,oBAAoB;AAG7B,SAAS,kBAAkB;AAEpB,IAAK,0BAAL,kBAAKA,6BAAL;AACH,EAAAA,yBAAA,mBAAgB;AAChB,EAAAA,yBAAA,mBAAgB;AAEhB,EAAAA,yBAAA,+BAA4B;AAC5B,EAAAA,yBAAA,uBAAoB;AALZ,SAAAA;AAAA,GAAA;AA2BZ,MAAM,qBAAqB,OAAO,IAAI,0CAA0C;AAIhF,MAAM,UAAU,CAAC,QAAuB,QAAa,aAA8B,eAAmC;AAClH,QAAM,qBAAsB,aAAa,YAAY,oBAAoB,OAAO,WAAW,KAAK,CAAC;AACjG,qBAAmB,KAAK,EAAC,aAAa,OAAM,CAAC;AAC7C,eAAa,eAAe,oBAAoB,oBAAoB,OAAO,WAAW;AACtF,eAAa,eAAe,oBAAoB,QAAQ,QAAQ,WAAW;AAC/E;AAGO,SAAS,WAAW,gBAAsC,aAA+B,YAAuD;AACnJ,MAAI,eAAe,YAAY;AAC3B,YAAQ,EAAC,QAAQ,WAAW,IAAG,GAAG,gBAAgB,aAAa,UAAU;AAAA,EAC7E,OAAO;AACH,WAAO,CAAC,QAAaC,cAA8BC,gBAAmC;AAClF,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IAC3D;AAAA,EACJ;AACJ;AACO,MAAM,gBAAgB,CAAC,QAAa,gBAA4D;AACnG,SAAO,aAAa,YAAY,oBAAoB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,YAAQ,EAAC,QAAQ,WAAW,MAAK,GAAG,gBAAgB,aAAa,UAAU;AAAA,EAC/E,OAAO;AACH,WAAO,CAAC,QAAaD,cAA8BC,gBAAmC;AAClF,qBAAe,SAAS,WAAW;AACnC,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IAC3D;AAAA,EACJ;AACJ;AAEO,MAAM,WAAW,CAAC,QAAa,gBAA4D;AAC9F,SAAO,cAAc,QAAQ,WAAW;AAC5C;AACO,MAAM,YAAY,CAAC,WAAqC;AAC3D,SAAO,eAAe,MAAM,GAAG,OAAO,QAAM,GAAG,QAAQ,OAAO,YAAY,MAAM,WAAW,KAAK;AACpG;AAGO,SAAS,QAAQ,gBAAsD,aAA+B,YAAuD;AAChK,MAAI,eAAe,YAAY;AAC3B,YAAQ,EAAC,QAAQ,WAAW,QAAO,GAAG,gBAAgB,aAAa,UAAU;AAAA,EACjF,OAAO;AACH,WAAO,CAAC,QAAaD,cAA8BC,gBAAmC;AAClF,qBAAe,SAAS,WAAW;AACnC,cAAQ,gBAAgB,QAAQD,cAAaC,WAAU;AAAA,IAC3D;AAAA,EACJ;AACJ;AAEO,MAAM,aAAa,CAAC,QAAa,gBAA4D;AAChG,SAAO,cAAc,QAAQ,WAAW;AAC5C;AACO,MAAM,cAAc,CAAC,WAAqC;AAC7D,SAAO,eAAe,MAAM,GAAG,OAAO,QAAM,GAAG,QAAQ,OAAO,YAAY,MAAM,WAAW,OAAO;AACtG;AAGO,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,gBAAgB;",
6
6
  "names": ["UrlMappingSituationType", "propertyKey", "descriptor"]
7
7
  }
@@ -1,7 +1,8 @@
1
1
  import { HttpError } from "./HttpError.js";
2
2
  import { HttpStatus } from "../codes/HttpStatus.js";
3
3
  class BadRequestError extends HttpError {
4
- constructor({ status = HttpStatus.BadRequest, message = "Bad Request" } = {}) {
4
+ constructor(input = {}) {
5
+ const { status = HttpStatus.BadRequest, message = "Bad Request" } = typeof input === "string" ? { message: input } : input;
5
6
  super({ status, message });
6
7
  }
7
8
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/errors/BadRequestError.ts"],
4
- "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class BadRequestError extends HttpError {\n constructor({status = HttpStatus.BadRequest, message = 'Bad Request'}: {status?: number, message?: string} = {}) {\n super({status, message});\n }\n}\n"],
5
- "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,wBAAwB,UAAU;AAAA,EAC3C,YAAY,EAAC,SAAS,WAAW,YAAY,UAAU,cAAa,IAAyC,CAAC,GAAG;AAC7G,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EAC3B;AACJ;",
4
+ "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class BadRequestError extends HttpError {\n constructor(\n input: { status?: number; message?: string } | string = {},\n ) {\n const {status = HttpStatus.BadRequest, message = 'Bad Request'} =\n typeof input === 'string' ? {message: input} : input;\n super({status, message});\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,wBAAwB,UAAU;AAAA,EAC7C,YACE,QAAwD,CAAC,GACzD;AACA,UAAM,EAAC,SAAS,WAAW,YAAY,UAAU,cAAa,IAC5D,OAAO,UAAU,WAAW,EAAC,SAAS,MAAK,IAAI;AACjD,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EACzB;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
1
  import { HttpError } from "./HttpError.js";
2
2
  import { HttpStatus } from "../codes/HttpStatus.js";
3
3
  class ForbiddenError extends HttpError {
4
- constructor({ status = HttpStatus.Forbidden, message = "Forbidden" } = {}) {
4
+ constructor(input = {}) {
5
+ const { status = HttpStatus.Forbidden, message = "Forbidden" } = typeof input === "string" ? { message: input } : input;
5
6
  super({ status, message });
6
7
  }
7
8
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/errors/ForbiddenError.ts"],
4
- "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class ForbiddenError extends HttpError {\n constructor({status = HttpStatus.Forbidden, message = 'Forbidden'}: {status?: number, message?: string} = {}) {\n super({status, message});\n }\n}\n"],
5
- "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,uBAAuB,UAAU;AAAA,EAC1C,YAAY,EAAC,SAAS,WAAW,WAAW,UAAU,YAAW,IAAyC,CAAC,GAAG;AAC1G,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EAC3B;AACJ;",
4
+ "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class ForbiddenError extends HttpError {\n constructor(\n input: { status?: number; message?: string } | string = {},\n ) {\n const {status = HttpStatus.Forbidden, message = 'Forbidden'} =\n typeof input === 'string' ? {message: input} : input;\n super({status, message});\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,uBAAuB,UAAU;AAAA,EAC5C,YACE,QAAwD,CAAC,GACzD;AACA,UAAM,EAAC,SAAS,WAAW,WAAW,UAAU,YAAW,IACzD,OAAO,UAAU,WAAW,EAAC,SAAS,MAAK,IAAI;AACjD,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EACzB;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
1
  import { HttpError } from "./HttpError.js";
2
2
  import { HttpStatus } from "../codes/HttpStatus.js";
3
3
  class InternalServerError extends HttpError {
4
- constructor({ status = HttpStatus.InternalServerError, message = "Internal Server Error" } = {}) {
4
+ constructor(input = {}) {
5
+ const { status = HttpStatus.InternalServerError, message = "Internal Server Error" } = typeof input === "string" ? { message: input } : input;
5
6
  super({ status, message });
6
7
  }
7
8
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/errors/InternalServerError.ts"],
4
- "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class InternalServerError extends HttpError {\n constructor({status = HttpStatus.InternalServerError, message = 'Internal Server Error'}: {status?: number, message?: string} = {}) {\n super({status, message});\n }\n}\n"],
5
- "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,4BAA4B,UAAU;AAAA,EAC/C,YAAY,EAAC,SAAS,WAAW,qBAAqB,UAAU,wBAAuB,IAAyC,CAAC,GAAG;AAChI,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EAC3B;AACJ;",
4
+ "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class InternalServerError extends HttpError {\n constructor(\n input: { status?: number; message?: string } | string = {},\n ) {\n const {status = HttpStatus.InternalServerError, message = 'Internal Server Error'} =\n typeof input === 'string' ? {message: input} : input;\n super({status, message});\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,4BAA4B,UAAU;AAAA,EACjD,YACE,QAAwD,CAAC,GACzD;AACA,UAAM,EAAC,SAAS,WAAW,qBAAqB,UAAU,wBAAuB,IAC/E,OAAO,UAAU,WAAW,EAAC,SAAS,MAAK,IAAI;AACjD,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EACzB;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
1
  import { HttpError } from "./HttpError.js";
2
2
  import { HttpStatus } from "../codes/HttpStatus.js";
3
3
  class NotFoundError extends HttpError {
4
- constructor({ status = HttpStatus.NotFound, message = "Not Found" } = {}) {
4
+ constructor(input = {}) {
5
+ const { status = HttpStatus.NotFound, message = "Not Found" } = typeof input === "string" ? { message: input } : input;
5
6
  super({ status, message });
6
7
  }
7
8
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/errors/NotFoundError.ts"],
4
- "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class NotFoundError extends HttpError {\n constructor({status = HttpStatus.NotFound, message = 'Not Found'}: {status?: number, message?: string} = {}) {\n super({status, message});\n }\n}\n"],
5
- "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,sBAAsB,UAAU;AAAA,EACzC,YAAY,EAAC,SAAS,WAAW,UAAU,UAAU,YAAW,IAAyC,CAAC,GAAG;AACzG,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EAC3B;AACJ;",
4
+ "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class NotFoundError extends HttpError {\n constructor(\n input: { status?: number; message?: string } | string = {},\n ) {\n const {status = HttpStatus.NotFound, message = 'Not Found'} =\n typeof input === 'string' ? {message: input} : input;\n super({status, message});\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,sBAAsB,UAAU;AAAA,EAC3C,YACE,QAAwD,CAAC,GACzD;AACA,UAAM,EAAC,SAAS,WAAW,UAAU,UAAU,YAAW,IACxD,OAAO,UAAU,WAAW,EAAC,SAAS,MAAK,IAAI;AACjD,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EACzB;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
1
  import { HttpError } from "./HttpError.js";
2
2
  import { HttpStatus } from "../codes/HttpStatus.js";
3
3
  class UnauthorizedError extends HttpError {
4
- constructor({ status = HttpStatus.Unauthorized, message = "Unauthorized" } = {}) {
4
+ constructor(input = {}) {
5
+ const { status = HttpStatus.Unauthorized, message = "Unauthorized" } = typeof input === "string" ? { message: input } : input;
5
6
  super({ status, message });
6
7
  }
7
8
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/errors/UnauthorizedError.ts"],
4
- "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class UnauthorizedError extends HttpError {\n constructor({status = HttpStatus.Unauthorized, message = 'Unauthorized'}: {status?: number, message?: string} = {}) {\n super({status, message});\n }\n}\n"],
5
- "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,0BAA0B,UAAU;AAAA,EAC7C,YAAY,EAAC,SAAS,WAAW,cAAc,UAAU,eAAc,IAAyC,CAAC,GAAG;AAChH,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EAC3B;AACJ;",
4
+ "sourcesContent": ["import {HttpError} from './HttpError';\nimport {HttpStatus} from '../codes/HttpStatus';\n\nexport class UnauthorizedError extends HttpError {\n constructor(\n input: { status?: number; message?: string } | string = {},\n ) {\n const {status = HttpStatus.Unauthorized, message = 'Unauthorized'} =\n typeof input === 'string' ? {message: input} : input;\n super({status, message});\n }\n}\n"],
5
+ "mappings": "AAAA,SAAQ,iBAAgB;AACxB,SAAQ,kBAAiB;AAElB,MAAM,0BAA0B,UAAU;AAAA,EAC/C,YACE,QAAwD,CAAC,GACzD;AACA,UAAM,EAAC,SAAS,WAAW,cAAc,UAAU,eAAc,IAC/D,OAAO,UAAU,WAAW,EAAC,SAAS,MAAK,IAAI;AACjD,UAAM,EAAC,QAAQ,QAAO,CAAC;AAAA,EACzB;AACF;",
6
6
  "names": []
7
7
  }
@@ -9,9 +9,8 @@ var __metadata = function(k, v) {
9
9
  };
10
10
  var _a;
11
11
  import { HttpHeaders } from "../codes/HttpHeaders.js";
12
- import { Intent } from "@dooboostore/simple-boot";
12
+ import { Intent, sim } from "@dooboostore/simple-boot";
13
13
  import { IntentManager } from "@dooboostore/simple-boot";
14
- import { Sim } from "@dooboostore/simple-boot";
15
14
  import { HttpStatus } from "../codes/HttpStatus.js";
16
15
  import { Mimes } from "../codes/Mimes.js";
17
16
  import { NotFoundError } from "../errors/NotFoundError.js";
@@ -66,7 +65,7 @@ let IntentSchemeFilter = class IntentSchemeFilter2 {
66
65
  }
67
66
  };
68
67
  IntentSchemeFilter = __decorate([
69
- Sim,
68
+ sim,
70
69
  __metadata("design:paramtypes", [typeof (_a = typeof IntentManager !== "undefined" && IntentManager) === "function" ? _a : Object])
71
70
  ], IntentSchemeFilter);
72
71
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/filters/IntentSchemeFilter.ts"],
4
- "sourcesContent": ["import { Filter } from './Filter';\nimport { HttpHeaders } from '../codes/HttpHeaders';\nimport { Intent } from '@dooboostore/simple-boot';\nimport { IntentManager } from '@dooboostore/simple-boot';\nimport { Sim } from '@dooboostore/simple-boot';\nimport { HttpStatus } from '../codes/HttpStatus';\nimport { RequestResponse } from '../models/RequestResponse';\nimport { SimpleBootHttpServer } from '../SimpleBootHttpServer';\nimport { Mimes } from '../codes/Mimes';\nimport { NotFoundError } from '../errors/NotFoundError';\n\n@Sim\nexport class IntentSchemeFilter implements Filter {\n constructor(private intentManager: IntentManager) {}\n\n async onInit(app: SimpleBootHttpServer) {}\n\n async proceedBefore({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n // const rr = rrr;\n const url = rr.reqUrl;\n const contentLength = Number(rr.reqHeader(HttpHeaders.ContentLength.toLowerCase() ?? '0'));\n const acceptType = rr.reqHeader(HttpHeaders.Accept);\n const contentType = rr.reqHeader(HttpHeaders.ContentType);\n const intentScheme = rr.reqHeader(HttpHeaders.XSimpleBootSsrIntentScheme);\n if (acceptType === Mimes.ApplicationJsonPostSimpleBootSsrIntentScheme && intentScheme) {\n let intent = new Intent(`${intentScheme}:/${url}`);\n // console.log('---------1--intent request', intentScheme, url, contentLength, contentType );\n // const responseHeader = {} as any;\n // responseHeader[HttpHeaders.ContentType] = Mimes.ApplicationJson;\n if (contentLength > 0) {\n if (contentType.includes(Mimes.ApplicationJson)) {\n intent.data = [await rr.reqBodyJsonData(), rr];\n } else if (contentType.includes(Mimes.MultipartFormData)) {\n intent.data = [await rr.reqBodyMultipartFormDataObject(), rr];\n }\n // console.log('---------2--intent request',intent);\n const { return: rdatas, target } = await this.intentManager.publishMeta(intent);\n if (target.length <= 0) {\n throw new NotFoundError({ message: 'Not found intent target' });\n }\n const rdata = rdatas[0];\n const wdata = rdata instanceof Promise ? await rdata : rdata;\n rr.resStatusCode(HttpStatus.Ok);\n rr.resSetHeader(HttpHeaders.ContentType, [Mimes.ApplicationJson]);\n await rr.resEnd(wdata ? JSON.stringify(wdata) : undefined);\n } else {\n intent.data = rr.reqUrlSearchParamTuples.length > 0 ? [rr.reqUrlSearchParamsObj, rr] : [rr];\n const { return: rdatas, target } = await this.intentManager.publishMeta(intent);\n if (target.length <= 0) {\n throw new NotFoundError({ message: 'Not found intent target' });\n }\n const rdata = rdatas[0];\n const wdata = rdata instanceof Promise ? await rdata : rdata;\n // const wdata =undefined;\n rr.resStatusCode(HttpStatus.Ok);\n rr.resSetHeader(HttpHeaders.ContentType, [Mimes.ApplicationJson]);\n await rr.resEnd(wdata ? JSON.stringify(wdata) : undefined);\n }\n // console.log('---------3--intent request', rr.req.readable, rr.req.readableLength);\n return false;\n } else {\n return true;\n }\n }\n\n async proceedAfter({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n return true;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;AACA,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,W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AI,CAAC,GAAG,uBAAuB,EAAE,IAAI,CAAC,EAAE;AAC1F,cAAM,EAAE,QAAQ,QAAQ,OAAM,IAAK,MAAM,KAAK,cAAc,YAAY,MAAM;AAC9E,YAAI,OAAO,UAAU,GAAG;AACtB,gBAAM,IAAI,cAAc,EAAE,SAAS,0BAAyB,CAAE;QAChE;AACA,cAAM,QAAQ,OAAO,CAAC;AACtB,cAAM,QAAQ,iBAAiB,UAAU,MAAM,QAAQ;AAEvD,WAAG,cAAc,WAAW,EAAE;AAC9B,WAAG,aAAa,YAAY,aAAa,CAAC,MAAM,eAAe,CAAC;AAChE,cAAM,GAAG,OAAO,QAAQ,KAAK,UAAU,KAAK,IAAI,MAAS;MAC3D;AAEA,aAAO;IACT,OAAO;AACL,aAAO;IACT;EACF;EAEA,MAAM,aAAa,EAAE,IAAI,IAAG,GAAiF;AAC3G,WAAO;EACT;;AAvDW,qBAAkB,WAAA;EAD9B;uDAEoC,kBAAa,eAAb,mBAAa,aAAA,KAAA,MAAA,CAAA;GADrC,kBAAkB;",
4
+ "sourcesContent": ["import { Filter } from './Filter';\nimport { HttpHeaders } from '../codes/HttpHeaders';\nimport {Intent, sim} from '@dooboostore/simple-boot';\nimport { IntentManager } from '@dooboostore/simple-boot';\nimport { Sim } from '@dooboostore/simple-boot';\nimport { HttpStatus } from '../codes/HttpStatus';\nimport { RequestResponse } from '../models/RequestResponse';\nimport { SimpleBootHttpServer } from '../SimpleBootHttpServer';\nimport { Mimes } from '../codes/Mimes';\nimport { NotFoundError } from '../errors/NotFoundError';\n\n@sim\nexport class IntentSchemeFilter implements Filter {\n constructor(private intentManager: IntentManager) {}\n\n async onInit(app: SimpleBootHttpServer) {}\n\n async proceedBefore({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n // const rr = rrr;\n const url = rr.reqUrl;\n const contentLength = Number(rr.reqHeader(HttpHeaders.ContentLength.toLowerCase() ?? '0'));\n const acceptType = rr.reqHeader(HttpHeaders.Accept);\n const contentType = rr.reqHeader(HttpHeaders.ContentType);\n const intentScheme = rr.reqHeader(HttpHeaders.XSimpleBootSsrIntentScheme);\n if (acceptType === Mimes.ApplicationJsonPostSimpleBootSsrIntentScheme && intentScheme) {\n let intent = new Intent(`${intentScheme}:/${url}`);\n // console.log('---------1--intent request', intentScheme, url, contentLength, contentType );\n // const responseHeader = {} as any;\n // responseHeader[HttpHeaders.ContentType] = Mimes.ApplicationJson;\n if (contentLength > 0) {\n if (contentType.includes(Mimes.ApplicationJson)) {\n intent.data = [await rr.reqBodyJsonData(), rr];\n } else if (contentType.includes(Mimes.MultipartFormData)) {\n intent.data = [await rr.reqBodyMultipartFormDataObject(), rr];\n }\n // console.log('---------2--intent request',intent);\n const { return: rdatas, target } = await this.intentManager.publishMeta(intent);\n if (target.length <= 0) {\n throw new NotFoundError({ message: 'Not found intent target' });\n }\n const rdata = rdatas[0];\n const wdata = rdata instanceof Promise ? await rdata : rdata;\n rr.resStatusCode(HttpStatus.Ok);\n rr.resSetHeader(HttpHeaders.ContentType, [Mimes.ApplicationJson]);\n await rr.resEnd(wdata ? JSON.stringify(wdata) : undefined);\n } else {\n intent.data = rr.reqUrlSearchParamTuples.length > 0 ? [rr.reqUrlSearchParamsObj, rr] : [rr];\n const { return: rdatas, target } = await this.intentManager.publishMeta(intent);\n if (target.length <= 0) {\n throw new NotFoundError({ message: 'Not found intent target' });\n }\n const rdata = rdatas[0];\n const wdata = rdata instanceof Promise ? await rdata : rdata;\n // const wdata =undefined;\n rr.resStatusCode(HttpStatus.Ok);\n rr.resSetHeader(HttpHeaders.ContentType, [Mimes.ApplicationJson]);\n await rr.resEnd(wdata ? JSON.stringify(wdata) : undefined);\n }\n // console.log('---------3--intent request', rr.req.readable, rr.req.readableLength);\n return false;\n } else {\n return true;\n }\n }\n\n async proceedAfter({ rr, app }: { rr: RequestResponse; app: SimpleBootHttpServer; carrier: Map<string, any> }) {\n return true;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;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,IAAI,MAAS;MAC3D,OAAO;AACL,eAAO,OAAO,GAAG,wBAAwB,SAAS,IAAI,CAAC,GAAG,uBAAuB,EAAE,IAAI,CAAC,EAAE;AAC1F,cAAM,EAAE,QAAQ,QAAQ,OAAM,IAAK,MAAM,KAAK,cAAc,YAAY,MAAM;AAC9E,YAAI,OAAO,UAAU,GAAG;AACtB,gBAAM,IAAI,cAAc,EAAE,SAAS,0BAAyB,CAAE;QAChE;AACA,cAAM,QAAQ,OAAO,CAAC;AACtB,cAAM,QAAQ,iBAAiB,UAAU,MAAM,QAAQ;AAEvD,WAAG,cAAc,WAAW,EAAE;AAC9B,WAAG,aAAa,YAAY,aAAa,CAAC,MAAM,eAAe,CAAC;AAChE,cAAM,GAAG,OAAO,QAAQ,KAAK,UAAU,KAAK,IAAI,MAAS;MAC3D;AAEA,aAAO;IACT,OAAO;AACL,aAAO;IACT;EACF;EAEA,MAAM,aAAa,EAAE,IAAI,IAAG,GAAiF;AAC3G,WAAO;EACT;;AAvDW,qBAAkB,WAAA;EAD9B;uDAEoC,kBAAa,eAAb,mBAAa,aAAA,KAAA,MAAA,CAAA;GADrC,kBAAkB;",
6
6
  "names": ["IntentSchemeFilter"]
7
7
  }
@@ -32,7 +32,8 @@ class ResourceFilter {
32
32
  return it.test(url);
33
33
  }
34
34
  if (typeof it === "string") {
35
- return RegExp(it).test(url);
35
+ console.log("url!!!!!!!", url);
36
+ return it === url;
36
37
  }
37
38
  if (typeof it === "function") {
38
39
  return it(rr, app);
@@ -43,7 +44,7 @@ class ResourceFilter {
43
44
  } else if (it.request instanceof RegExp) {
44
45
  return it.request.test(url);
45
46
  } else {
46
- return RegExp(it.request).test(url);
47
+ return it.request === url;
47
48
  }
48
49
  }
49
50
  }) ?? [];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/filters/ResourceFilter.ts"],
4
- "sourcesContent": ["import { Filter } from '../filters/Filter';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport mime from 'mime-types';\nimport { HttpHeaders } from '../codes/HttpHeaders';\nimport { HttpStatus } from '../codes/HttpStatus';\nimport { SimpleBootHttpServer } from '../SimpleBootHttpServer';\nimport { RequestResponse } from '../models/RequestResponse';\nimport { Blob } from 'node:buffer';\n\nexport type RequestFilterType = string | RegExp | ((rr: RequestResponse, app: SimpleBootHttpServer) => boolean) | ((rr: RequestResponse, app: SimpleBootHttpServer) => Promise<boolean>);\n\ntype PathDist = RequestFilterType|{request: RequestFilterType, dist: string | ((rr: RequestResponse, app: SimpleBootHttpServer) => string)};\n\ntype DataDist = {request: RequestFilterType, response: (rr: RequestResponse, app: SimpleBootHttpServer) => (string | Promise<Blob | ArrayBuffer | Response>)};\nexport const isPathDist = (item: any): item is PathDist => {\n return typeof item === 'object' && ('request' in item) && ('dist' in item);\n};\nexport const isDataDist = (item: any): item is DataDist => {\n return typeof item === 'object' && ('request' in item) && ('response' in item);\n};\nexport class ResourceFilter implements Filter {\n // private requestFilter: RequestFilterType;\n private resourceDistPath?: string;\n private resources?: (DataDist|PathDist)[];\n constructor(resourceDistPath: string, resourceRegex: PathDist[]);\n constructor(resourceRegex: DataDist[]);\n constructor(resourceDistPathOrResourceRegex: string | DataDist[], resourceRegex?: PathDist[]) {\n if (typeof resourceDistPathOrResourceRegex === 'string') {\n this.resourceDistPath = resourceDistPathOrResourceRegex;\n this.resources = resourceRegex;\n } else {\n this.resources = resourceDistPathOrResourceRegex;\n // this.requestFilter = resourceDistPathOrResourceRegex\n }\n }\n // constructor(private resourceDistPath: string, private resourceRegex: (RequestFilterType | { request: RequestFilterType, dist: string | ((rr: RequestResponse, app: SimpleBootHttpServer) => (string|Promise<Blob |ArrayBuffer| Response>)) })[] = []) {\n // }\n\n async onInit(app: SimpleBootHttpServer) {\n }\n\n async proceedBefore({rr, app}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n const url = (rr.reqUrlPathName ?? '').replace(/\\.\\./g, '');\n const urlObj = rr.reqUrlObject;\n // const requestUrl = parse(rr.reqUrl ?? '', true);\n // console.log('resource filter!!**-------', url);\n let sw = true;\n const regExps = this.resources?.filter(it => {\n // console.log('---it', it, it instanceof RegExp, typeof it)\n if (it instanceof RegExp) {\n // console.log('--------', it.test(url))\n return it.test(url);\n }\n\n if (typeof it === 'string') {\n return RegExp(it).test(url);\n }\n\n if (typeof it === 'function') {\n return it(rr, app);\n }\n\n if (typeof it === 'object' && 'request' in it) {\n if (typeof it.request === 'function') {\n return it.request(rr, app);\n } else if (it .request instanceof RegExp) {\n return it.request.test(url);\n } else {\n return RegExp(it.request).test(url);\n }\n }\n })??[]\n // console.log('regExps', regExps, url);\n // eslint-disable-next-line no-unused-vars\n for (const it of regExps) {\n sw = false;\n //DataDist\n if (isDataDist(it)) {\n let distValue = typeof it.response === 'function' ? it.response(rr,app) : it.response;\n if (distValue instanceof Promise) {\n const result = await distValue;\n if (result instanceof Response) {\n await rr.resEnd(result);\n break;\n } else if (result instanceof Blob) {\n rr.resStatusCode(HttpStatus.Ok);\n await rr.resEnd(result);\n break;\n }\n }\n } else {\n //PathDist or undefined\n const dist = typeof it === 'object' && 'dist' in it ? it.dist : urlObj.pathname;\n let distValue = typeof dist === 'function' ? dist(rr, app) : dist;\n if (this.resourceDistPath) {\n // It's a string path\n const resourcePath = path.join(this.resourceDistPath, distValue);\n // console.log('-----------',this.resourceDistPath, resourcePath);\n if (fs.existsSync(resourcePath)) {\n rr.resStatusCode(HttpStatus.Ok);\n rr.resSetHeader(HttpHeaders.ContentType, mime.lookup(resourcePath).toString());\n await rr.resEnd(fs.readFileSync(resourcePath));\n break;\n } else {\n rr.resStatusCode(HttpStatus.NotFound);\n await rr.resEnd();\n break;\n }\n } else {\n rr.resStatusCode(HttpStatus.InternalServerError);\n await rr.resEnd();\n break;\n }\n }\n sw = true;\n }\n return sw;\n }\n\n async proceedAfter({rr, app}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n // console.log('resource filter!!end@@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s';\nimport path from 'node:path';\nimport mime from 'mime-types';\nimport { HttpHeaders } from '../codes/HttpHeaders';\nimport { HttpStatus } from '../codes/HttpStatus';\nimport { SimpleBootHttpServer } from '../SimpleBootHttpServer';\nimport { RequestResponse } from '../models/RequestResponse';\nimport { Blob } from 'node:buffer';\n\nexport type RequestFilterType = string | RegExp | ((rr: RequestResponse, app: SimpleBootHttpServer) => boolean) | ((rr: RequestResponse, app: SimpleBootHttpServer) => Promise<boolean>);\n\ntype PathDist = RequestFilterType|{request: RequestFilterType, dist: string | ((rr: RequestResponse, app: SimpleBootHttpServer) => string)};\n\ntype DataDist = {request: RequestFilterType, response: (rr: RequestResponse, app: SimpleBootHttpServer) => (string | Promise<Blob | ArrayBuffer | Response>)};\nexport const isPathDist = (item: any): item is PathDist => {\n return typeof item === 'object' && ('request' in item) && ('dist' in item);\n};\nexport const isDataDist = (item: any): item is DataDist => {\n return typeof item === 'object' && ('request' in item) && ('response' in item);\n};\nexport class ResourceFilter implements Filter {\n // private requestFilter: RequestFilterType;\n private resourceDistPath?: string;\n private resources?: (DataDist|PathDist)[];\n constructor(resourceDistPath: string, resourceRegex: PathDist[]);\n constructor(resourceRegex: DataDist[]);\n constructor(resourceDistPathOrResourceRegex: string | DataDist[], resourceRegex?: PathDist[]) {\n if (typeof resourceDistPathOrResourceRegex === 'string') {\n this.resourceDistPath = resourceDistPathOrResourceRegex;\n this.resources = resourceRegex;\n } else {\n this.resources = resourceDistPathOrResourceRegex;\n // this.requestFilter = resourceDistPathOrResourceRegex\n }\n }\n // constructor(private resourceDistPath: string, private resourceRegex: (RequestFilterType | { request: RequestFilterType, dist: string | ((rr: RequestResponse, app: SimpleBootHttpServer) => (string|Promise<Blob |ArrayBuffer| Response>)) })[] = []) {\n // }\n\n async onInit(app: SimpleBootHttpServer) {\n }\n\n async proceedBefore({rr, app}: {rr: RequestResponse, app: SimpleBootHttpServer, carrier: Map<string, any>}) {\n const url = (rr.reqUrlPathName ?? '').replace(/\\.\\./g, '');\n const urlObj = rr.reqUrlObject;\n // const requestUrl = parse(rr.reqUrl ?? '', true);\n // console.log('resource filter!!**-------', url);\n let sw = true;\n const regExps = this.resources?.filter(it => {\n // console.log('---it', it, it instanceof RegExp, typeof it)\n if (it instanceof RegExp) {\n // console.log('--------', it.test(url))\n return it.test(url);\n }\n\n if (typeof it === 'string') {\n console.log('url!!!!!!!', url)\n return it === url;\n // return RegExp(it).test(url);\n }\n\n if (typeof it === 'function') {\n return it(rr, app);\n }\n\n if (typeof it === 'object' && 'request' in it) {\n if (typeof it.request === 'function') {\n return it.request(rr, app);\n } else if (it .request instanceof RegExp) {\n return it.request.test(url);\n } else {\n // return RegExp(it.request).test(url);\n return it.request === url\n }\n }\n })??[]\n // console.log('regExps', regExps, url);\n // eslint-disable-next-line no-unused-vars\n for (const it of regExps) {\n sw = false;\n //DataDist\n if (isDataDist(it)) {\n let distValue = typeof it.response === 'function' ? it.response(rr,app) : it.response;\n if (distValue instanceof Promise) {\n const result = await distValue;\n if (result instanceof Response) {\n await rr.resEnd(result);\n break;\n } else if (result instanceof Blob) {\n rr.resStatusCode(HttpStatus.Ok);\n await rr.resEnd(result);\n break;\n }\n }\n } else {\n //PathDist or undefined\n const dist = typeof it === 'object' && 'dist' in it ? it.dist : urlObj.pathname;\n let distValue = typeof dist === 'function' ? dist(rr, app) : dist;\n if (this.resourceDistPath) {\n // It's a string path\n const resourcePath = path.join(this.resourceDistPath, distValue);\n // console.log('-----------',this.resourceDistPath, resourcePath);\n if (fs.existsSync(resourcePath)) {\n rr.resStatusCode(HttpStatus.Ok);\n rr.resSetHeader(HttpHeaders.ContentType, mime.lookup(resourcePath).toString());\n await rr.resEnd(fs.readFileSync(resourcePath));\n break;\n } else {\n rr.resStatusCode(HttpStatus.NotFound);\n await rr.resEnd();\n break;\n }\n } else {\n rr.resStatusCode(HttpStatus.InternalServerError);\n await rr.resEnd();\n break;\n }\n }\n sw = true;\n }\n return sw;\n }\n\n async proceedAfter({rr, app}: {rr: Request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  "names": []
7
7
  }
@@ -5,4 +5,5 @@ export * from "./HttpStatusFilter.js";
5
5
  export * from "./OpenApi3Filter.js";
6
6
  export * from "./ResourceFilter.js";
7
7
  export * from "./ThrowFilter.js";
8
+ export * from "./IntentSchemeFilter.js";
8
9
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/filters/index.ts"],
4
- "sourcesContent": ["export * from './CacheFilter';\nexport * from './Filter';\nexport * from './TopicProtocolFilter';\nexport * from './HttpStatusFilter';\nexport * from './OpenApi3Filter';\nexport * from './ResourceFilter';\nexport * from './ThrowFilter';\n"],
5
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["export * from './CacheFilter';\nexport * from './Filter';\nexport * from './TopicProtocolFilter';\nexport * from './HttpStatusFilter';\nexport * from './OpenApi3Filter';\nexport * from './ResourceFilter';\nexport * from './ThrowFilter';\nexport * from './IntentSchemeFilter'"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
@@ -3,6 +3,7 @@ export * from "./decorators/index.js";
3
3
  export * from "./endpoints/index.js";
4
4
  export * from "./errors/index.js";
5
5
  export * from "./filters/index.js";
6
+ export * from "./proxy/index.js";
6
7
  export * from "./inject/index.js";
7
8
  export * from "./lifecycle/index.js";
8
9
  export * from "./models/index.js";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './codes';\nexport * from './decorators';\nexport * from './endpoints';\nexport * from './errors';\nexport * from './filters';\nexport * from './inject';\nexport * from './lifecycle';\nexport * from './models';\nexport * from './option';\nexport * from './resolvers';\nexport * from './session';\nexport * from './SimpleBootHttpServer';\nexport default {}"],
5
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,IAAO,cAAQ,CAAC;",
4
+ "sourcesContent": ["export * from './codes';\nexport * from './decorators';\nexport * from './endpoints';\nexport * from './errors';\nexport * from './filters';\nexport * from './proxy';\nexport * from './inject';\nexport * from './lifecycle';\nexport * from './models';\nexport * from './option';\nexport * from './resolvers';\nexport * from './session';\nexport * from './SimpleBootHttpServer';\nexport default {}"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,IAAO,cAAQ,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  var InjectSituationType;
2
2
  ((InjectSituationType2) => {
3
- InjectSituationType2.TransactionManager = Symbol("TransactionManager");
3
+ InjectSituationType2.TransactionManager = Symbol.for("simple-boot-http-server:transaction-manager-token");
4
4
  })(InjectSituationType || (InjectSituationType = {}));
5
5
  export {
6
6
  InjectSituationType
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/inject/InjectSituationType.ts"],
4
- "sourcesContent": ["export namespace InjectSituationType {\n export const TransactionManager = Symbol('TransactionManager');\n}"],
5
- "mappings": "AAAO,IAAU;AAAA,CAAV,CAAUA,yBAAV;AACE,EAAMA,qBAAA,qBAAqB,OAAO,oBAAoB;AAAA,GAD9C;",
4
+ "sourcesContent": ["export namespace InjectSituationType {\n export const TransactionManager = Symbol.for('simple-boot-http-server:transaction-manager-token');\n}"],
5
+ "mappings": "AAAO,IAAU;AAAA,CAAV,CAAUA,yBAAV;AACE,EAAMA,qBAAA,qBAAqB,OAAO,IAAI,mDAAmD;AAAA,GADjF;",
6
6
  "names": ["InjectSituationType"]
7
7
  }
@@ -92,10 +92,24 @@ class RequestResponse {
92
92
  return new Intent(this.reqPathSearchParamUrl);
93
93
  }
94
94
  reqHasContentTypeHeader(mime) {
95
- return (this.reqHeaderFirst(HttpHeaders.ContentType) ?? "").toLowerCase().indexOf(mime.toLocaleLowerCase()) > -1;
95
+ const contentType = this.reqHeader(HttpHeaders.ContentType);
96
+ if (!contentType) return false;
97
+ const targetMime = mime.toString().toLowerCase();
98
+ const contentTypes = Array.isArray(contentType) ? contentType : [contentType];
99
+ return contentTypes.some((ct) => {
100
+ const [mimeType] = ct.split(";").map((m) => m.trim());
101
+ return mimeType.toLowerCase() === targetMime || mimeType.toLowerCase().includes(targetMime);
102
+ });
96
103
  }
97
104
  reqHasAcceptHeader(mime) {
98
- return (this.reqHeaderFirst(HttpHeaders.Accept) ?? "").toLowerCase().indexOf(mime.toLocaleLowerCase()) > -1;
105
+ const accept = this.reqHeader(HttpHeaders.Accept);
106
+ if (!accept) return false;
107
+ const targetMime = mime.toString().toLowerCase();
108
+ const acceptHeaders = Array.isArray(accept) ? accept : [accept];
109
+ return acceptHeaders.some((acceptHeader) => {
110
+ const acceptMimes = acceptHeader.split(",").map((m) => m.split(";")[0].trim().toLowerCase());
111
+ return acceptMimes.some((acceptMime) => acceptMime.includes(targetMime));
112
+ });
99
113
  }
100
114
  reqBodyData() {
101
115
  return new Promise((resolve, reject) => {
@@ -289,6 +303,9 @@ class RequestResponse {
289
303
  reqMethod() {
290
304
  return this.req.method?.toUpperCase();
291
305
  }
306
+ reqIsMethod(method) {
307
+ return this.reqMethod().toUpperCase() === method.toUpperCase();
308
+ }
292
309
  reqHeader(key) {
293
310
  return this.req.headers[key.toLowerCase()];
294
311
  }