@dooboostore/simple-boot-http-server 1.0.22 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.MD +1 -3
  2. package/dist/cjs/SimpleBootHttpServer.js +17 -0
  3. package/dist/cjs/SimpleBootHttpServer.js.map +2 -2
  4. package/dist/cjs/codes/HttpStatus.js +1 -0
  5. package/dist/cjs/codes/HttpStatus.js.map +2 -2
  6. package/dist/cjs/decorators/MethodMapping.js +1 -0
  7. package/dist/cjs/decorators/MethodMapping.js.map +2 -2
  8. package/dist/cjs/filters/ResourceFilter.js.map +2 -2
  9. package/dist/cjs/models/RequestResponse.js +6 -1
  10. package/dist/cjs/models/RequestResponse.js.map +2 -2
  11. package/dist/cjs/models/datas/search/ReqSearchParamsObj.js +29 -0
  12. package/dist/cjs/models/datas/search/ReqSearchParamsObj.js.map +7 -0
  13. package/dist/esm/SimpleBootHttpServer.js +17 -0
  14. package/dist/esm/SimpleBootHttpServer.js.map +2 -2
  15. package/dist/esm/codes/HttpStatus.js +1 -0
  16. package/dist/esm/codes/HttpStatus.js.map +2 -2
  17. package/dist/esm/decorators/MethodMapping.js +1 -0
  18. package/dist/esm/decorators/MethodMapping.js.map +2 -2
  19. package/dist/esm/filters/ResourceFilter.js.map +2 -2
  20. package/dist/esm/models/RequestResponse.js +6 -1
  21. package/dist/esm/models/RequestResponse.js.map +2 -2
  22. package/dist/esm/models/datas/search/ReqSearchParamsObj.js +6 -0
  23. package/dist/esm/models/datas/search/ReqSearchParamsObj.js.map +7 -0
  24. package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +261 -73
  25. package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +3 -3
  26. package/dist/types/SimpleBootHttpServer.d.ts.map +1 -1
  27. package/dist/types/codes/HttpStatus.d.ts +13 -1
  28. package/dist/types/codes/HttpStatus.d.ts.map +1 -1
  29. package/dist/types/decorators/MethodMapping.d.ts +1 -0
  30. package/dist/types/decorators/MethodMapping.d.ts.map +1 -1
  31. package/dist/types/filters/ResourceFilter.d.ts.map +1 -1
  32. package/dist/types/models/RequestResponse.d.ts +1 -0
  33. package/dist/types/models/RequestResponse.d.ts.map +1 -1
  34. package/dist/types/models/datas/search/ReqSearchParamsObj.d.ts +4 -0
  35. package/dist/types/models/datas/search/ReqSearchParamsObj.d.ts.map +1 -0
  36. package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +261 -73
  37. package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +3 -3
  38. package/package.json +6 -6
  39. package/src/SimpleBootHttpServer.ts +18 -1
  40. package/src/codes/HttpStatus.ts +19 -1
  41. package/src/decorators/MethodMapping.ts +2 -0
  42. package/src/filters/ResourceFilter.ts +1 -0
  43. package/src/models/RequestResponse.ts +6 -1
  44. package/src/models/datas/search/ReqSearchParamsObj.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooboostore/simple-boot-http-server",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -86,11 +86,11 @@
86
86
  "@types/node-gzip": "^1.1.0",
87
87
  "esbuild-plugin-tsc": "^0.5.0",
88
88
  "esbuild": "^0.23.0",
89
- "@dooboostore/core": "1.0.26",
90
- "@dooboostore/core-node": "1.0.9",
91
- "@dooboostore/dom-render": "1.0.110",
92
- "@dooboostore/core-web": "1.0.8",
93
- "@dooboostore/simple-boot": "1.0.52"
89
+ "@dooboostore/core": "1.0.28",
90
+ "@dooboostore/core-node": "1.0.10",
91
+ "@dooboostore/dom-render": "1.0.112",
92
+ "@dooboostore/core-web": "1.0.9",
93
+ "@dooboostore/simple-boot": "1.0.53"
94
94
  },
95
95
  "dependencies": {
96
96
  "fast-json-patch": "^3.1.0",
@@ -27,6 +27,7 @@ import { URLSearchParams } from 'url';
27
27
  import { HttpMethod } from './codes/HttpMethod';
28
28
  import { SessionManager } from './session/SessionManager';
29
29
  import { InjectSituationType } from './inject/InjectSituationType';
30
+ import {ReqSearchParamsObj} from "./models/datas/search/ReqSearchParamsObj";
30
31
 
31
32
  export class SimpleBootHttpServer extends SimpleApplication {
32
33
  public server?: HttpServer | HttpsServer;
@@ -190,6 +191,7 @@ export class SimpleBootHttpServer extends SimpleApplication {
190
191
  const validIndexs = getValidIndex(moduleInstance, it.propertyKey);
191
192
  if (injects) {
192
193
  const isJson = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_JSON_BODY);
194
+ const isSearchParamsObj = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_URL_SEARCH_PARAMS_OBJ);
193
195
  const isFormUrl = injects.find(it => it.config?.situationType === UrlMappingSituationType.REQ_FORM_URL_BODY);
194
196
  const isTransactionManager = injects.find(it => it.config?.situationType === InjectSituationType.TransactionManager);
195
197
  const siturationContainers = new SituationTypeContainers();
@@ -209,6 +211,19 @@ export class SimpleBootHttpServer extends SimpleApplication {
209
211
  data
210
212
  }));
211
213
  }
214
+ if (isSearchParamsObj) {
215
+ let data = rr.reqUrlSearchParamsObj
216
+ if (validIndexs.includes(isSearchParamsObj.index)) {
217
+ const inValid = execValidationInValid(data);
218
+ if ((inValid?.length ?? 0) > 0) {
219
+ throw new ValidException(inValid);
220
+ }
221
+ }
222
+ siturationContainers.push(new SituationTypeContainer({
223
+ situationType: UrlMappingSituationType.REQ_URL_SEARCH_PARAMS_OBJ,
224
+ data
225
+ }));
226
+ }
212
227
  if (isFormUrl) {
213
228
  let data = await rr.reqBodyFormUrlData()
214
229
  if (isFormUrl.type) {
@@ -240,7 +255,9 @@ export class SimpleBootHttpServer extends SimpleApplication {
240
255
  otherStorage.set(ReqFormUrlBody, await rr.reqBodyReqFormUrlBody())
241
256
  } else if (paramType === ReqJsonBody) {
242
257
  otherStorage.set(ReqJsonBody, await rr.reqBodyReqJsonBody())
243
- } else if (paramType === URLSearchParams) {
258
+ } else if (paramType === ReqSearchParamsObj) {
259
+ otherStorage.set(ReqSearchParamsObj, rr.reqUrlSearchParamsObj)
260
+ }else if (paramType === URLSearchParams) {
244
261
  otherStorage.set(URLSearchParams, rr.reqUrlSearchParams)
245
262
  } else if (paramType === ReqMultipartFormBody) {
246
263
  otherStorage.set(ReqMultipartFormBody, rr.reqBodyMultipartFormData())
@@ -2,31 +2,49 @@ export enum HttpStatus {
2
2
  Ok = 200,
3
3
 
4
4
  /**
5
+ * Multiple Choices ⇢ 요청에 대해서 둘 이상의 가능한 응답이 있음을 나타낸다.
6
+ * 클라이언트가 동시에 여러 리소스를 가리키는 URL을 요청한 경우, 그 리소스의 목록과 함께 반환된다.
7
+ * 어떤 서버가 하나의 HTML 문서를 영어와 프랑스어 모두로 제공하는 경우 등에 사용할 수 있다.
8
+ * 그러나 응답 중 하나를 선택하는 표준화된 방법이 없기 때문에, 이 응답 코드는 실무에선 거의 사용되지 않는다.
9
+ */
10
+ MultipleChoices = 300,
11
+
12
+ /**
13
+ * 영구
5
14
  * HTTP 301 Moved Permanently 리디렉션 상태 응답 코드는 요청한 리소스가 Location 헤더에 주어진 URL로 완전히 옮겨졌다는 것을 나타냅니다. 브라우저는 이 페이지로 리디렉트하고, 검색 엔진은 해당 리소스로 연결되는 링크를 갱신합니다.
15
+ * Moved Permanently ⇢ 영구적으로 이동 (영구 리다이렉션)
16
+ * 요청된 리소스가 Location 헤더가 지정한 URL로 이동되었음을 나타낸다.
17
+ * 해당 URL로 리다이렉션 되면, 요청 메서드가 GET으로 변하고 본문이 제거될수 있다.
18
+ * 따라서 301 코드는 GET 또는 HEAD 방법에 대한 응답으로만 사용하고, 대신 POST, PUT 같은 경우는 같은 영구 리디렉션인 308 Permanent Redirect 을 사용하는 것이 좋다.
6
19
  */
7
20
  MovedPermanently = 301,
8
- /**
21
+
22
+ /** 임시
9
23
  * https://developer.mozilla.org/ko/docs/Web/HTTP/Reference/Status/302
10
24
  * HTTP(HyperText Transfer Protocol) 302 Found 리디렉션 상태 응답 코드는 요청한 리소스가 Location 헤더에 지정된 URL로 일시적으로 이동되었음을 나타냅니다. 브라우저는 이 페이지로 리디렉션되지만 검색 엔진은 리소스에 대한 링크를 업데이트하지 않습니다('SEO-speak'에서는 'link-juice'가 새 URL로 전송되지 않는다고 합니다).
11
25
  * 명세서에서 리디렉션이 수행될 때 메서드(및 본문)가 변경되지 않도록 요구하더라도 모든 사용자 에이전트가 이를 준수하는 것은 아닙니다. 여러분은 여전히 이러한 유형의 버그가 있는 소프트웨어를 찾을 수 있습니다. 따라서 따라서 302 코드는 GET 또는 HEAD 메서드에 대한 응답으로만 설정하고 이 경우 메서드 변경이 명시적으로 금지되므로 307 Temporary Redirect 를 대신 사용하는 것이 좋습니다.
12
26
  * 사용하던 메서드를 GET으로 변경하려는 경우, 303 See Other을 대신 사용하십시오. PUT 메서드에 대한 응답을 업로드된 리소스가 아니라 'You successfully updown XYZ'와 같은 확인 메시지로 주고 싶을때 유용합니다.
13
27
  */
14
28
  Found = 302,
29
+
15
30
  /**
16
31
  * HTTP(HyperText Transfer Protocol) 303 See Other 리디렉션 상태 응답 코드는 리디렉션이 요청한 리소스 자체에 연결되지 않고 다른 페이지(예: 확인 페이지, 실제 개체 표시(HTTP range-14 참조) 또는 업로드 진행률 페이지)에 연결됨을 나타냅니다. 이 응답 코드는 PUT 또는 POST의 결과로 다시 전송되는 경우가 많습니다. 이 리디렉션 페이지를 표시하는 데 사용되는 방법은 항상 GET입니다.
17
32
  */
18
33
  SeeOther = 303,
34
+
19
35
  /**
20
36
  * 클라이언트 리디렉션 응답 코드 304 Not Modified 는 요청된 리소스를 재전송할 필요가 없음을 나타낸다. 캐시된 자원으로의 암묵적인 리디렉션이다. 이 는 GET 나 HEAD 요청처럼 요청 방법이 안전 한 경우 또는 요청이 조건부로 If-None-Match 또는 If-Modified-Since 헤더를 사용할 때 응답 된다.
21
37
  * 이에 상응하는 200 OK 응답에는 Cache-Control, Content-Location, Date, ETag, Expires, 그리고 Vary 가 포함되어 있었을 것이다.
22
38
  */
23
39
  NotModified = 304,
40
+
24
41
  /**
25
42
  * HTTP 307 Temporary Redirect 리다이렉트 상태 응답 코드는 요청한 리소스가 Location 헤더에 주어진 URL 로 임시로 옮겨졌다는 것을 나타냅니다.
26
43
  * 원래 요청한 메소드와 Body 를 재사용하여 요청을 리다이렉트 합니다. 여기서 메소드를 GET으로 바꾸기 위해서 303 See Other를 사용하시면 됩니다. 이것은 PUT요청에 업로드된 리소스가 아닌 "You successfully uploaded XYZ"와 같은 확인메시지 응답을 제공 하는데에 유용합니다.
27
44
  * 307과 302가 유일하게 다른점은 307은 Method 와 Body 를 변경하지 않고 리다이렉트 요청을 하도록 보장합니다. 302응답으로 인하여 일부 오래된 클라이언트들은 메소드를 GET으로 틀리게 변경하였습니다. GET이 아닌 다른 메소드에 302동작은 웹에서 예상되지 않지만 307 동작은 예상할수 있습니다. GET 요청에 대해서는 동일하게 동작 합니다.
28
45
  */
29
46
  TemporaryRedirect = 307,
47
+
30
48
  /**
31
49
  * 하이퍼텍스트 전송 프로토콜 (HTTP) 308 Permanent Redirect 리디렉션 상태 응답 코드는 요청된 리소스가 Location 헤더에 지정된 URL로 확실히 이동되었음을 나타냅니다. 브라우저가 이 페이지로 리디렉션되고 검색엔진은 리소스에 대한 링크를 업데이트합니다('SEO-speak'에서는 'link-juice'가 새 URL로 전송됩니다).
32
50
  * 요청 메서드와 본문은 변경되지 않지만, 301은 때때로 GET 메서드로 잘못 변경될 수 있습니다.
@@ -7,6 +7,8 @@ import { HttpMethod } from '../codes/HttpMethod';
7
7
 
8
8
  export enum UrlMappingSituationType {
9
9
  REQ_JSON_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY',
10
+ // REQ_URL_SEARCH_PARAMS = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS',
11
+ REQ_URL_SEARCH_PARAMS_OBJ = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_URL_SEARCH_PARAMS_OBJ',
10
12
  REQ_FORM_URL_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY'
11
13
  }
12
14
  export type MappingConfig = {
@@ -91,6 +91,7 @@ export class ResourceFilter implements Filter {
91
91
  if (this.resourceDistPath) {
92
92
  // It's a string path
93
93
  const resourcePath = path.join(this.resourceDistPath, distValue);
94
+ // console.log('-----------',this.resourceDistPath, resourcePath);
94
95
  if (fs.existsSync(resourcePath)) {
95
96
  rr.resStatusCode(HttpStatus.Ok);
96
97
  rr.resSetHeader(HttpHeaders.ContentType, mime.lookup(resourcePath).toString());
@@ -175,7 +175,7 @@ export class RequestResponse {
175
175
 
176
176
  for (const it of m) {
177
177
  if (it.isFile) {
178
- formData[it.name] = await FileUtils.writeFile(it.value, {originalName: it.filename });
178
+ formData[it.name] = await FileUtils.writeFile(it.value, {originalName: it.filename, etcData: it });
179
179
  } else {
180
180
  const target = formData[it.name];
181
181
  if (Array.isArray(target)) {
@@ -640,6 +640,11 @@ export class RequestResponse {
640
640
  // return this.createRequestResponseChain();
641
641
  // }
642
642
 
643
+ resRedirect(statusCode: number, location: string) {
644
+ this.res.statusCode = statusCode;
645
+ this.res.setHeader(HttpHeaders.Location, location);
646
+ this.res.end();
647
+ }
643
648
  resWriteHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[] | { [key: string]: string | string[] }) {
644
649
  return this.createRequestResponseChain(this.res.writeHead(statusCode, headers));
645
650
  }
@@ -0,0 +1,3 @@
1
+ export class ReqSearchParamsObj {
2
+ [key: string]: any
3
+ }