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

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 (164) hide show
  1. package/README.md +113 -0
  2. package/dist/cjs/SimpleBootHttpServer.js +2 -2
  3. package/dist/cjs/SimpleBootHttpServer.js.map +1 -1
  4. package/dist/cjs/decorators/MethodMapping.js +33 -3
  5. package/dist/cjs/decorators/MethodMapping.js.map +2 -2
  6. package/dist/cjs/errors/BadRequestError.js +2 -1
  7. package/dist/cjs/errors/BadRequestError.js.map +2 -2
  8. package/dist/cjs/errors/ForbiddenError.js +2 -1
  9. package/dist/cjs/errors/ForbiddenError.js.map +2 -2
  10. package/dist/cjs/errors/InternalServerError.js +2 -1
  11. package/dist/cjs/errors/InternalServerError.js.map +2 -2
  12. package/dist/cjs/errors/NotFoundError.js +2 -1
  13. package/dist/cjs/errors/NotFoundError.js.map +2 -2
  14. package/dist/cjs/errors/UnauthorizedError.js +2 -1
  15. package/dist/cjs/errors/UnauthorizedError.js.map +2 -2
  16. package/dist/cjs/filters/IntentSchemeFilter.js +1 -2
  17. package/dist/cjs/filters/IntentSchemeFilter.js.map +2 -2
  18. package/dist/cjs/filters/ResourceFilter.js +3 -2
  19. package/dist/cjs/filters/ResourceFilter.js.map +2 -2
  20. package/dist/cjs/filters/index.js +3 -1
  21. package/dist/cjs/filters/index.js.map +2 -2
  22. package/dist/cjs/index.js +2 -0
  23. package/dist/cjs/index.js.map +2 -2
  24. package/dist/cjs/inject/InjectSituationType.js +1 -1
  25. package/dist/cjs/inject/InjectSituationType.js.map +2 -2
  26. package/dist/cjs/models/RequestResponse.js +19 -2
  27. package/dist/cjs/models/RequestResponse.js.map +2 -2
  28. package/dist/cjs/models/datas/body/index.js +28 -0
  29. package/dist/cjs/models/datas/body/index.js.map +7 -0
  30. package/dist/cjs/models/datas/index.js +32 -0
  31. package/dist/cjs/models/datas/index.js.map +7 -0
  32. package/dist/cjs/models/datas/{body → path}/ReqPathData.js.map +1 -1
  33. package/dist/cjs/models/datas/{search → path}/ReqSearchParamsObj.js.map +1 -1
  34. package/dist/cjs/models/datas/path/index.js +24 -0
  35. package/dist/cjs/models/datas/path/index.js.map +7 -0
  36. package/dist/cjs/models/index.js +4 -16
  37. package/dist/cjs/models/index.js.map +2 -2
  38. package/dist/cjs/models/method/index.js +22 -0
  39. package/dist/cjs/models/method/index.js.map +7 -0
  40. package/dist/cjs/models/method/patch/index.js +22 -0
  41. package/dist/cjs/models/method/patch/index.js.map +7 -0
  42. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js +98 -95
  43. package/dist/cjs/proxy/SymbolIntentApiServiceProxy.js.map +3 -3
  44. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js +1 -1
  45. package/dist/cjs/proxy/SymbolIntentApiServiceProxyBase.js.map +2 -2
  46. package/dist/esm/SimpleBootHttpServer.js +2 -2
  47. package/dist/esm/SimpleBootHttpServer.js.map +1 -1
  48. package/dist/esm/decorators/MethodMapping.js +22 -2
  49. package/dist/esm/decorators/MethodMapping.js.map +2 -2
  50. package/dist/esm/errors/BadRequestError.js +2 -1
  51. package/dist/esm/errors/BadRequestError.js.map +2 -2
  52. package/dist/esm/errors/ForbiddenError.js +2 -1
  53. package/dist/esm/errors/ForbiddenError.js.map +2 -2
  54. package/dist/esm/errors/InternalServerError.js +2 -1
  55. package/dist/esm/errors/InternalServerError.js.map +2 -2
  56. package/dist/esm/errors/NotFoundError.js +2 -1
  57. package/dist/esm/errors/NotFoundError.js.map +2 -2
  58. package/dist/esm/errors/UnauthorizedError.js +2 -1
  59. package/dist/esm/errors/UnauthorizedError.js.map +2 -2
  60. package/dist/esm/filters/IntentSchemeFilter.js +2 -3
  61. package/dist/esm/filters/IntentSchemeFilter.js.map +2 -2
  62. package/dist/esm/filters/ResourceFilter.js +3 -2
  63. package/dist/esm/filters/ResourceFilter.js.map +2 -2
  64. package/dist/esm/filters/index.js +1 -0
  65. package/dist/esm/filters/index.js.map +2 -2
  66. package/dist/esm/index.js +1 -0
  67. package/dist/esm/index.js.map +2 -2
  68. package/dist/esm/inject/InjectSituationType.js +1 -1
  69. package/dist/esm/inject/InjectSituationType.js.map +2 -2
  70. package/dist/esm/models/RequestResponse.js +19 -2
  71. package/dist/esm/models/RequestResponse.js.map +2 -2
  72. package/dist/esm/models/datas/body/index.js +5 -0
  73. package/dist/esm/models/datas/body/index.js.map +7 -0
  74. package/dist/esm/models/datas/index.js +7 -0
  75. package/dist/esm/models/datas/index.js.map +7 -0
  76. package/dist/esm/models/datas/{body → path}/ReqPathData.js.map +1 -1
  77. package/dist/esm/models/datas/{search → path}/ReqSearchParamsObj.js.map +1 -1
  78. package/dist/esm/models/datas/path/index.js +3 -0
  79. package/dist/esm/models/datas/path/index.js.map +7 -0
  80. package/dist/esm/models/index.js +2 -8
  81. package/dist/esm/models/index.js.map +2 -2
  82. package/dist/esm/models/method/index.js +2 -0
  83. package/dist/esm/models/method/index.js.map +7 -0
  84. package/dist/esm/models/method/patch/index.js +2 -0
  85. package/dist/esm/models/method/patch/index.js.map +7 -0
  86. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js +98 -95
  87. package/dist/esm/proxy/SymbolIntentApiServiceProxy.js.map +3 -3
  88. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js +2 -2
  89. package/dist/esm/proxy/SymbolIntentApiServiceProxyBase.js.map +2 -2
  90. package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +5580 -974
  91. package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +4 -4
  92. package/dist/types/SimpleBootHttpServer.d.ts +1 -1
  93. package/dist/types/decorators/MethodMapping.d.ts +10 -0
  94. package/dist/types/decorators/MethodMapping.d.ts.map +1 -1
  95. package/dist/types/errors/BadRequestError.d.ts +2 -2
  96. package/dist/types/errors/BadRequestError.d.ts.map +1 -1
  97. package/dist/types/errors/ForbiddenError.d.ts +2 -2
  98. package/dist/types/errors/ForbiddenError.d.ts.map +1 -1
  99. package/dist/types/errors/InternalServerError.d.ts +2 -2
  100. package/dist/types/errors/InternalServerError.d.ts.map +1 -1
  101. package/dist/types/errors/NotFoundError.d.ts +2 -2
  102. package/dist/types/errors/NotFoundError.d.ts.map +1 -1
  103. package/dist/types/errors/UnauthorizedError.d.ts +2 -2
  104. package/dist/types/errors/UnauthorizedError.d.ts.map +1 -1
  105. package/dist/types/filters/ResourceFilter.d.ts.map +1 -1
  106. package/dist/types/filters/index.d.ts +1 -0
  107. package/dist/types/filters/index.d.ts.map +1 -1
  108. package/dist/types/index.d.ts +1 -0
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/inject/InjectSituationType.d.ts.map +1 -1
  111. package/dist/types/models/RequestResponse.d.ts +3 -1
  112. package/dist/types/models/RequestResponse.d.ts.map +1 -1
  113. package/dist/types/models/datas/body/index.d.ts +5 -0
  114. package/dist/types/models/datas/body/index.d.ts.map +1 -0
  115. package/dist/types/models/datas/index.d.ts +7 -0
  116. package/dist/types/models/datas/index.d.ts.map +1 -0
  117. package/dist/types/models/datas/{body → path}/ReqPathData.d.ts.map +1 -1
  118. package/dist/types/models/datas/path/ReqSearchParamsObj.d.ts.map +1 -0
  119. package/dist/types/models/datas/path/index.d.ts +3 -0
  120. package/dist/types/models/datas/path/index.d.ts.map +1 -0
  121. package/dist/types/models/index.d.ts +2 -8
  122. package/dist/types/models/index.d.ts.map +1 -1
  123. package/dist/types/models/method/index.d.ts +2 -0
  124. package/dist/types/models/method/index.d.ts.map +1 -0
  125. package/dist/types/models/method/patch/index.d.ts +2 -0
  126. package/dist/types/models/method/patch/index.d.ts.map +1 -0
  127. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts +6 -8
  128. package/dist/types/proxy/SymbolIntentApiServiceProxy.d.ts.map +1 -1
  129. package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +5583 -977
  130. package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +4 -4
  131. package/dist/umd-bundle/websocket-client.umd.js +182 -2
  132. package/dist/umd-bundle/websocket-client.umd.js.map +4 -4
  133. package/package.json +6 -6
  134. package/src/SimpleBootHttpServer.ts +4 -4
  135. package/src/decorators/MethodMapping.ts +13 -1
  136. package/src/errors/BadRequestError.ts +7 -3
  137. package/src/errors/ForbiddenError.ts +7 -3
  138. package/src/errors/InternalServerError.ts +7 -3
  139. package/src/errors/NotFoundError.ts +7 -3
  140. package/src/errors/UnauthorizedError.ts +7 -3
  141. package/src/filters/IntentSchemeFilter.ts +2 -2
  142. package/src/filters/ResourceFilter.ts +5 -2
  143. package/src/filters/index.ts +1 -0
  144. package/src/index.ts +1 -0
  145. package/src/inject/InjectSituationType.ts +1 -1
  146. package/src/models/RequestResponse.ts +28 -2
  147. package/src/models/datas/body/index.ts +4 -0
  148. package/src/models/datas/index.ts +6 -0
  149. package/src/models/datas/path/index.ts +2 -0
  150. package/src/models/index.ts +2 -8
  151. package/src/models/method/index.ts +1 -0
  152. package/src/models/method/patch/index.ts +1 -0
  153. package/src/proxy/SymbolIntentApiServiceProxy.ts +103 -97
  154. package/src/proxy/SymbolIntentApiServiceProxyBase.ts +2 -2
  155. package/README.MD +0 -62
  156. package/dist/types/models/datas/search/ReqSearchParamsObj.d.ts.map +0 -1
  157. /package/dist/cjs/models/datas/{body → path}/ReqPathData.js +0 -0
  158. /package/dist/cjs/models/datas/{search → path}/ReqSearchParamsObj.js +0 -0
  159. /package/dist/esm/models/datas/{body → path}/ReqPathData.js +0 -0
  160. /package/dist/esm/models/datas/{search → path}/ReqSearchParamsObj.js +0 -0
  161. /package/dist/types/models/datas/{body → path}/ReqPathData.d.ts +0 -0
  162. /package/dist/types/models/datas/{search → path}/ReqSearchParamsObj.d.ts +0 -0
  163. /package/src/models/datas/{body → path}/ReqPathData.ts +0 -0
  164. /package/src/models/datas/{search → path}/ReqSearchParamsObj.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooboostore/simple-boot-http-server",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -92,11 +92,11 @@
92
92
  "webpack": "^5.93.0",
93
93
  "webpack-cli": "^5.1.4",
94
94
  "webpack-dev-server": "^5.2.0",
95
- "@dooboostore/core": "1.0.30",
96
- "@dooboostore/simple-boot": "1.0.54",
97
- "@dooboostore/core-web": "1.0.10",
98
- "@dooboostore/dom-render": "1.0.113",
99
- "@dooboostore/core-node": "1.0.12"
95
+ "@dooboostore/core-node": "1.0.12",
96
+ "@dooboostore/core": "1.0.32",
97
+ "@dooboostore/core-web": "1.0.12",
98
+ "@dooboostore/simple-boot": "1.0.56",
99
+ "@dooboostore/dom-render": "1.0.113"
100
100
  },
101
101
  "dependencies": {
102
102
  "fast-json-patch": "^3.1.0",
@@ -28,9 +28,9 @@ import {URLSearchParams} from 'url';
28
28
  import {HttpMethod} from './codes/HttpMethod';
29
29
  import {SessionManager} from './session/SessionManager';
30
30
  import {InjectSituationType} from './inject/InjectSituationType';
31
- import {ReqSearchParamsObj} from "./models/datas/search/ReqSearchParamsObj";
31
+ import {ReqSearchParamsObj} from "./models/datas/path/ReqSearchParamsObj";
32
32
  import {SimConfig} from '@dooboostore/simple-boot';
33
- import {ReqPathData} from './models/datas/body/ReqPathData';
33
+ import {ReqPathData} from './models/datas/path/ReqPathData';
34
34
  import {WebSocketEndPoint} from './endpoints/WebSocketEndPoint';
35
35
 
36
36
  export class SimpleBootHttpServer extends SimpleApplication {
@@ -44,8 +44,8 @@ export class SimpleBootHttpServer extends SimpleApplication {
44
44
  }
45
45
 
46
46
 
47
- public run(otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | Symbol, any>) {
48
- otherInstanceSim ??= new Map<ConstructorType<any> | Function | SimConfig | Symbol, any>();
47
+ public run(otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>) {
48
+ otherInstanceSim ??= new Map<ConstructorType<any> | Function | SimConfig | symbol, any>();
49
49
  otherInstanceSim.set(SimpleBootHttpServer, this);
50
50
  super.run(otherInstanceSim);
51
51
  const targets = [...this.option.closeEndPoints ?? [], ...this.option.errorEndPoints ?? [], ...this.option.requestEndPoints ?? [], ...this.option.filters ?? []];
@@ -32,7 +32,7 @@ export type MappingConfig = {
32
32
  resolver?: Resolver|ConstructorType<Resolver>;
33
33
  }
34
34
  export type SaveMappingConfig = {propertyKey: string | symbol; config: MappingConfig}
35
- const MappingMetadataKey = Symbol('MappingMetadataKey');
35
+ const MappingMetadataKey = Symbol.for('simple-boot-http-server:mapping-metadata');
36
36
  // const GETSMappingMetadataKey = Symbol('GET_METHODS');
37
37
  // const GETMappingMetadataKey = Symbol('GET_METHOD');
38
38
 
@@ -234,3 +234,15 @@ export const getCONNECT = (target: any, propertyKey: string | symbol): MappingCo
234
234
  export const getCONNECTS = (target: any): SaveMappingConfig[] => {
235
235
  return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.CONNECT);
236
236
  }
237
+
238
+ // Aliases for lowercase
239
+ export const urlMapping = UrlMapping;
240
+ export const getMethod = GET;
241
+ export const postMethod = POST;
242
+ export const patchMethod = PATCH;
243
+ export const putMethod = PUT;
244
+ export const deleteMethod = DELETE;
245
+ export const optionsMethod = OPTIONS;
246
+ export const headMethod = HEAD;
247
+ export const traceMethod = TRACE;
248
+ export const connectMethod = CONNECT;
@@ -2,7 +2,11 @@ import {HttpError} from './HttpError';
2
2
  import {HttpStatus} from '../codes/HttpStatus';
3
3
 
4
4
  export class BadRequestError extends HttpError {
5
- constructor({status = HttpStatus.BadRequest, message = 'Bad Request'}: {status?: number, message?: string} = {}) {
6
- super({status, message});
7
- }
5
+ constructor(
6
+ input: { status?: number; message?: string } | string = {},
7
+ ) {
8
+ const {status = HttpStatus.BadRequest, message = 'Bad Request'} =
9
+ typeof input === 'string' ? {message: input} : input;
10
+ super({status, message});
11
+ }
8
12
  }
@@ -2,7 +2,11 @@ import {HttpError} from './HttpError';
2
2
  import {HttpStatus} from '../codes/HttpStatus';
3
3
 
4
4
  export class ForbiddenError extends HttpError {
5
- constructor({status = HttpStatus.Forbidden, message = 'Forbidden'}: {status?: number, message?: string} = {}) {
6
- super({status, message});
7
- }
5
+ constructor(
6
+ input: { status?: number; message?: string } | string = {},
7
+ ) {
8
+ const {status = HttpStatus.Forbidden, message = 'Forbidden'} =
9
+ typeof input === 'string' ? {message: input} : input;
10
+ super({status, message});
11
+ }
8
12
  }
@@ -2,7 +2,11 @@ import {HttpError} from './HttpError';
2
2
  import {HttpStatus} from '../codes/HttpStatus';
3
3
 
4
4
  export class InternalServerError extends HttpError {
5
- constructor({status = HttpStatus.InternalServerError, message = 'Internal Server Error'}: {status?: number, message?: string} = {}) {
6
- super({status, message});
7
- }
5
+ constructor(
6
+ input: { status?: number; message?: string } | string = {},
7
+ ) {
8
+ const {status = HttpStatus.InternalServerError, message = 'Internal Server Error'} =
9
+ typeof input === 'string' ? {message: input} : input;
10
+ super({status, message});
11
+ }
8
12
  }
@@ -2,7 +2,11 @@ import {HttpError} from './HttpError';
2
2
  import {HttpStatus} from '../codes/HttpStatus';
3
3
 
4
4
  export class NotFoundError extends HttpError {
5
- constructor({status = HttpStatus.NotFound, message = 'Not Found'}: {status?: number, message?: string} = {}) {
6
- super({status, message});
7
- }
5
+ constructor(
6
+ input: { status?: number; message?: string } | string = {},
7
+ ) {
8
+ const {status = HttpStatus.NotFound, message = 'Not Found'} =
9
+ typeof input === 'string' ? {message: input} : input;
10
+ super({status, message});
11
+ }
8
12
  }
@@ -2,7 +2,11 @@ import {HttpError} from './HttpError';
2
2
  import {HttpStatus} from '../codes/HttpStatus';
3
3
 
4
4
  export class UnauthorizedError extends HttpError {
5
- constructor({status = HttpStatus.Unauthorized, message = 'Unauthorized'}: {status?: number, message?: string} = {}) {
6
- super({status, message});
7
- }
5
+ constructor(
6
+ input: { status?: number; message?: string } | string = {},
7
+ ) {
8
+ const {status = HttpStatus.Unauthorized, message = 'Unauthorized'} =
9
+ typeof input === 'string' ? {message: input} : input;
10
+ super({status, message});
11
+ }
8
12
  }
@@ -1,6 +1,6 @@
1
1
  import { Filter } from './Filter';
2
2
  import { HttpHeaders } from '../codes/HttpHeaders';
3
- import { Intent } from '@dooboostore/simple-boot';
3
+ import {Intent, sim} from '@dooboostore/simple-boot';
4
4
  import { IntentManager } from '@dooboostore/simple-boot';
5
5
  import { Sim } from '@dooboostore/simple-boot';
6
6
  import { HttpStatus } from '../codes/HttpStatus';
@@ -9,7 +9,7 @@ import { SimpleBootHttpServer } from '../SimpleBootHttpServer';
9
9
  import { Mimes } from '../codes/Mimes';
10
10
  import { NotFoundError } from '../errors/NotFoundError';
11
11
 
12
- @Sim
12
+ @sim
13
13
  export class IntentSchemeFilter implements Filter {
14
14
  constructor(private intentManager: IntentManager) {}
15
15
 
@@ -54,7 +54,9 @@ export class ResourceFilter implements Filter {
54
54
  }
55
55
 
56
56
  if (typeof it === 'string') {
57
- return RegExp(it).test(url);
57
+ console.log('url!!!!!!!', url)
58
+ return it === url;
59
+ // return RegExp(it).test(url);
58
60
  }
59
61
 
60
62
  if (typeof it === 'function') {
@@ -67,7 +69,8 @@ export class ResourceFilter implements Filter {
67
69
  } else if (it .request instanceof RegExp) {
68
70
  return it.request.test(url);
69
71
  } else {
70
- return RegExp(it.request).test(url);
72
+ // return RegExp(it.request).test(url);
73
+ return it.request === url
71
74
  }
72
75
  }
73
76
  })??[]
@@ -5,3 +5,4 @@ export * from './HttpStatusFilter';
5
5
  export * from './OpenApi3Filter';
6
6
  export * from './ResourceFilter';
7
7
  export * from './ThrowFilter';
8
+ export * from './IntentSchemeFilter'
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export * from './decorators';
3
3
  export * from './endpoints';
4
4
  export * from './errors';
5
5
  export * from './filters';
6
+ export * from './proxy';
6
7
  export * from './inject';
7
8
  export * from './lifecycle';
8
9
  export * from './models';
@@ -1,3 +1,3 @@
1
1
  export namespace InjectSituationType {
2
- export const TransactionManager = Symbol('TransactionManager');
2
+ export const TransactionManager = Symbol.for('simple-boot-http-server:transaction-manager-token');
3
3
  }
@@ -20,6 +20,7 @@ import { RandomUtils } from '@dooboostore/core';
20
20
  import { FileUtils } from '@dooboostore/core-node';
21
21
  import { ConvertUtils as CoreConvertUtils } from '@dooboostore/core';
22
22
  import { ConvertUtils } from '@dooboostore/core-node';
23
+ import {HttpMethod} from "../codes";
23
24
 
24
25
  type Config = { sessionManager?: SessionManager; option: HttpServerOption };
25
26
 
@@ -134,11 +135,32 @@ export class RequestResponse {
134
135
  }
135
136
 
136
137
  reqHasContentTypeHeader(mime: Mimes | string): boolean {
137
- return (this.reqHeaderFirst(HttpHeaders.ContentType) ?? '').toLowerCase().indexOf(mime.toLocaleLowerCase()) > -1;
138
+ const contentType = this.reqHeader(HttpHeaders.ContentType);
139
+ if (!contentType) return false;
140
+
141
+ const targetMime = mime.toString().toLowerCase();
142
+ const contentTypes = Array.isArray(contentType) ? contentType : [contentType];
143
+
144
+ // 모든 Content-Type 헤더를 확인
145
+ return contentTypes.some(ct => {
146
+ // Content-Type은 보통 단일 값이지만, 파라미터가 붙을 수 있음 (charset=utf-8 등)
147
+ // 세미콜론으로 split해서 앞 부분(MIME 타입)만 비교
148
+ const [mimeType] = ct.split(';').map(m => m.trim());
149
+ return mimeType.toLowerCase() === targetMime || mimeType.toLowerCase().includes(targetMime);
150
+ });
138
151
  }
139
152
 
140
153
  reqHasAcceptHeader(mime: Mimes | string): boolean {
141
- return (this.reqHeaderFirst(HttpHeaders.Accept) ?? '').toLowerCase().indexOf(mime.toLocaleLowerCase()) > -1;
154
+ const accept = this.reqHeader(HttpHeaders.Accept);
155
+ if (!accept) return false;
156
+
157
+ const targetMime = mime.toString().toLowerCase();
158
+ const acceptHeaders = Array.isArray(accept) ? accept : [accept];
159
+
160
+ return acceptHeaders.some(acceptHeader => {
161
+ const acceptMimes = acceptHeader.split(',').map(m => m.split(';')[0].trim().toLowerCase());
162
+ return acceptMimes.some(acceptMime => acceptMime.includes(targetMime));
163
+ });
142
164
  }
143
165
 
144
166
  reqBodyData(): Promise<Buffer> {
@@ -365,6 +387,10 @@ export class RequestResponse {
365
387
  return this.req.method?.toUpperCase();
366
388
  }
367
389
 
390
+ reqIsMethod(method: HttpMethod | string) {
391
+ return this.reqMethod().toUpperCase() === (method as string).toUpperCase();
392
+ }
393
+
368
394
  reqHeader(key: keyof typeof HttpHeaders | string) {
369
395
  return this.req.headers[(key as string).toLowerCase()];
370
396
  }
@@ -0,0 +1,4 @@
1
+ export * from './ReqJsonBody'
2
+ export * from './ReqFormUrlBody'
3
+ export * from './ReqMultipartFormBody'
4
+ export * from '../path/ReqPathData'
@@ -0,0 +1,6 @@
1
+ export * from './body'
2
+ export * from './path'
3
+ export * from './HeaderData'
4
+ export * from './MultipartData'
5
+ export * from './Resource'
6
+ export * from './ReqHeader'
@@ -0,0 +1,2 @@
1
+ export * from './ReqSearchParamsObj'
2
+ export * from './ReqPathData'
@@ -1,9 +1,3 @@
1
1
  export * from './RequestResponse';
2
- export * from './datas/HeaderData';
3
- export * from './datas/MultipartData';
4
- export * from './datas/ReqHeader';
5
- export * from './datas/Resource';
6
- export * from './datas/body/ReqFormUrlBody';
7
- export * from './datas/body/ReqJsonBody';
8
- export * from './datas/body/ReqMultipartFormBody';
9
- export * from './method/patch/PatchJson';
2
+ export * from './datas'
3
+ export * from './method'
@@ -0,0 +1 @@
1
+ export * from './patch'
@@ -0,0 +1 @@
1
+ export * from './PatchJson'
@@ -1,9 +1,9 @@
1
- import { getSim, Sim } from '@dooboostore/simple-boot';
1
+ import {getSim, sim, Sim, SimConfig} from '@dooboostore/simple-boot';
2
2
  import { makeIntentHeaderBySymbolFor } from '../codes/HttpHeaders';
3
- import { ConvertUtils } from '@dooboostore/core';
3
+ import {ConstructorType, ConvertUtils} from '@dooboostore/core';
4
4
  import { ApiService } from '@dooboostore/simple-boot';
5
5
 
6
- export type Config<T = any> = {
6
+ export type SymbolIntentApiServiceConfig<T = any> = {
7
7
  method?: 'get' | 'post' | 'petch' | 'delete' | 'head';
8
8
  multipartFormData?: boolean;
9
9
  bypassTransform?: boolean;
@@ -14,107 +14,113 @@ export type Config<T = any> = {
14
14
  };
15
15
  const _ = ApiService;
16
16
 
17
- @Sim
18
- export class SymbolIntentApiServiceProxy<T extends object> implements ProxyHandler<T> {
19
- constructor(private apiService: ApiService) {
20
- // console.log('-------apiService', apiService);
21
- }
22
17
 
23
- static createHandler<T extends object>(apiService: ApiService): ProxyHandler<T> {
24
- return {
25
- get(target: T, prop: string | symbol, receiver: any): any {
26
- if (prop === '_SimpleBoot_origin') {
27
- return target;
28
- }
29
- const simConfig = getSim(target);
30
- const value = Reflect.get(target, prop, receiver);
31
- if (typeof value === 'function' && simConfig?.symbol) {
32
- return function (...args: any[]) {
33
- const f = value as Function;
34
- const p = (userConfig: Config) => {
35
- const headers = { ...(userConfig?.headers ?? {}), ...makeIntentHeaderBySymbolFor(simConfig.symbol as Symbol) };
36
- const method = userConfig?.method ?? 'post';
37
- if (method === 'post' && userConfig?.multipartFormData) {
38
- //@ts-ignore
39
- return apiService.post({
40
- target: `/${String(prop)}`,
41
- config: {
42
- responseTransform: userConfig?.bypassTransform ? 'response' : undefined,
43
- transformText: userConfig?.transformText,
44
- config: userConfig?.config,
45
- fetch: {
46
- credentials: 'include',
47
- headers: headers,
48
- body: ConvertUtils.toFormData(userConfig?.body)
49
- }
18
+ export const createHandler = <T extends object>(apiService: ApiService): ProxyHandler<T> => {
19
+ return {
20
+ get(target: T, prop: string | symbol, receiver: any): any {
21
+ if (prop === '_SimpleBoot_origin') {
22
+ return target;
23
+ }
24
+ const simConfig = getSim(target);
25
+ const value = Reflect.get(target, prop, receiver);
26
+ if (typeof value === 'function' && simConfig?.symbol) {
27
+ return function (...args: any[]) {
28
+ const f = value as Function;
29
+ const p = (userConfig: SymbolIntentApiServiceConfig) => {
30
+ const headers = {...(userConfig?.headers ?? {}), ...makeIntentHeaderBySymbolFor(simConfig.symbol as Symbol)};
31
+ const method = userConfig?.method ?? 'post';
32
+ if (method === 'post' && userConfig?.multipartFormData) {
33
+ //@ts-ignore
34
+ return apiService.post({
35
+ target: `/${String(prop)}`,
36
+ config: {
37
+ responseTransform: userConfig?.bypassTransform ? 'response' : undefined,
38
+ transformText: userConfig?.transformText,
39
+ config: userConfig?.config,
40
+ fetch: {
41
+ credentials: 'include',
42
+ headers: headers,
43
+ body: ConvertUtils.toFormData(userConfig?.body)
50
44
  }
51
- });
52
- } else if (method === 'post') {
53
- //@ts-ignore
54
- return apiService.postJson({
55
- target: `/${String(prop)}`,
56
- config: {
57
- responseTransform: userConfig?.bypassTransform ? 'response' : undefined,
58
- transformText: userConfig?.transformText,
59
- config: userConfig?.config,
60
- fetch: {
61
- credentials: 'include',
62
- headers: headers,
63
- body: userConfig?.body
64
- }
45
+ }
46
+ });
47
+ } else if (method === 'post') {
48
+ //@ts-ignore
49
+ return apiService.postJson({
50
+ target: `/${String(prop)}`,
51
+ config: {
52
+ responseTransform: userConfig?.bypassTransform ? 'response' : undefined,
53
+ transformText: userConfig?.transformText,
54
+ config: userConfig?.config,
55
+ fetch: {
56
+ credentials: 'include',
57
+ headers: headers,
58
+ body: userConfig?.body
65
59
  }
66
- });
67
- } else if (method === 'petch') {
68
- //@ts-ignore
69
- return apiService.patchJson({
70
- target: `/${String(prop)}`,
71
- config: {
72
- responseTransform: userConfig?.bypassTransform ? 'response' : undefined,
73
- transformText: userConfig?.transformText,
74
- config: userConfig?.config,
75
- fetch: {
76
- credentials: 'include',
77
- headers: headers,
78
- body: userConfig?.body
79
- }
60
+ }
61
+ });
62
+ } else if (method === 'petch') {
63
+ //@ts-ignore
64
+ return apiService.patchJson({
65
+ target: `/${String(prop)}`,
66
+ config: {
67
+ responseTransform: userConfig?.bypassTransform ? 'response' : undefined,
68
+ transformText: userConfig?.transformText,
69
+ config: userConfig?.config,
70
+ fetch: {
71
+ credentials: 'include',
72
+ headers: headers,
73
+ body: userConfig?.body
80
74
  }
81
- });
82
- } else {
83
- //@ts-ignore
84
- return apiService[method]({
85
- target: { url: `/${String(prop)}`, searchParams: userConfig?.body },
86
- config: {
87
- responseTransform: userConfig?.bypassTransform ? 'response' : undefined,
88
- transformText: userConfig?.transformText,
89
- config: userConfig?.config,
90
- fetch: {
91
- credentials: 'include',
92
- headers: headers
93
- }
75
+ }
76
+ });
77
+ } else {
78
+ //@ts-ignore
79
+ return apiService[method]({
80
+ target: {url: `/${String(prop)}`, searchParams: userConfig?.body},
81
+ config: {
82
+ responseTransform: userConfig?.bypassTransform ? 'response' : undefined,
83
+ transformText: userConfig?.transformText,
84
+ config: userConfig?.config,
85
+ fetch: {
86
+ credentials: 'include',
87
+ headers: headers
94
88
  }
95
- });
96
- }
97
- };
98
- args.push(p);
99
- return Reflect.apply(f, target, args);
89
+ }
90
+ });
91
+ }
100
92
  };
101
- }
102
- return Reflect.get(target, prop, receiver);
103
- },
104
-
105
- apply(target: T, thisArg: any, argArray: any[]): any {
106
- console.log('SymbolIntentApiServiceProxy apply');
107
- // @ts-ignore
108
- return Reflect.apply(target, thisArg, argArray);
93
+ args.push(p);
94
+ return Reflect.apply(f, target, args);
95
+ };
109
96
  }
110
- };
111
- }
97
+ return Reflect.get(target, prop, receiver);
98
+ },
112
99
 
113
- get(target: T, prop: string | symbol, receiver: any): any {
114
- return SymbolIntentApiServiceProxy.createHandler<T>(this.apiService).get!(target, prop, receiver);
115
- }
100
+ apply(target: T, thisArg: any, argArray: any[]): any {
101
+ console.log('SymbolIntentApiServiceProxy apply');
102
+ // @ts-ignore
103
+ return Reflect.apply(target, thisArg, argArray);
104
+ }
105
+ };
106
+ }
116
107
 
117
- apply(target: T, thisArg: any, argArray: any[]): any {
118
- return SymbolIntentApiServiceProxy.createHandler<T>(this.apiService).apply!(target, thisArg, argArray);
108
+ export default (config?: SimConfig): ConstructorType<any> => {
109
+
110
+ @sim(config)
111
+ class SymbolIntentApiServiceProxy<T extends object> implements ProxyHandler<T> {
112
+ constructor(private apiService: ApiService) {
113
+ // console.log('-------apiService', apiService);
114
+ }
115
+
116
+
117
+ get(target: T, prop: string | symbol, receiver: any): any {
118
+ return createHandler<T>(this.apiService).get!(target, prop, receiver);
119
+ }
120
+
121
+ apply(target: T, thisArg: any, argArray: any[]): any {
122
+ return createHandler<T>(this.apiService).apply!(target, thisArg, argArray);
123
+ }
119
124
  }
120
- }
125
+ return SymbolIntentApiServiceProxy;
126
+ }
@@ -1,5 +1,5 @@
1
1
  import {ApiService} from '@dooboostore/simple-boot';
2
- import {SymbolIntentApiServiceProxy} from './SymbolIntentApiServiceProxy';
2
+ import {createHandler} from './SymbolIntentApiServiceProxy';
3
3
 
4
4
  export class SymbolIntentApiServiceProxyBase<T extends object = any> {
5
5
  // 생성자는 프록시될 대상 객체(target)와 의존성을 주입받습니다.
@@ -7,7 +7,7 @@ export class SymbolIntentApiServiceProxyBase<T extends object = any> {
7
7
  apiService: ApiService,
8
8
  ) {
9
9
  // SymbolIntentApiServiceProxy의 static handler를 사용합니다.
10
- const handler = SymbolIntentApiServiceProxy.createHandler<T>(apiService);
10
+ const handler = createHandler<T>(apiService);
11
11
 
12
12
  // 생성자에서 Proxy 객체를 반환합니다.
13
13
  // @ts-ignore
package/README.MD DELETED
@@ -1,62 +0,0 @@
1
- # @dooboostore/simple-boot-http-server
2
-
3
- [![NPM version](https://img.shields.io/npm/v/@dooboostore/simple-boot-http-server.svg?style=flat-square)](https://www.npmjs.com/package/@dooboostore/simple-boot-http-server)
4
- [![Build and Test](https://github.com/dooboostore-develop/packages/actions/workflows/main.yaml/badge.svg?branch=main)](https://github.com/dooboostore-develop/packages/actions/workflows/main.yaml)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
6
-
7
- **Full Documentation:** [https://dooboostore-develop.github.io/@dooboostore/simple-boot-http-server](https://dooboostore-develop.github.io/@dooboostore/simple-boot-http-server)
8
-
9
- A lightweight and powerful HTTP web server framework for Node.js, built on `@dooboostore/simple-boot`.
10
-
11
- ---
12
-
13
- ## Features
14
-
15
- - **Declarative Routing**: Use decorators like `@Router`, `@Route`, `@GET`, `@POST`, etc., to map URL paths and HTTP methods directly to your controller methods.
16
- - **Middleware via Filters**: Intercept the request-response cycle with `Filter` classes to implement cross-cutting concerns like logging, authentication, and CORS.
17
- - **Lifecycle Endpoints**: Hook into the request lifecycle with `EndPoint` classes that run on request start, close, or error.
18
- - **Integrated Exception Handling**: Leverage `@simple-boot`'s AOP capabilities to create robust global error handlers.
19
- - **Built-in Session Management**: Easily manage user sessions with a built-in session manager and customizable storage.
20
- - **HTTPS and HTTP/2 Support**: Secure your server with HTTPS and HTTP/2 configuration.
21
- - **WebSocket Topics + Events**: Topic-based subscribe/request/response with server events.
22
- - **WebSocket Binary File Transfer**: Send/receive files inside regular message payloads (JSON + binary framing).
23
- - **WebSocket Auto Reconnect**: Automatic reconnect and re-subscribe with configurable retry.
24
-
25
- ## Quick Start
26
-
27
- ```bash
28
- npx @dooboostore/create-simple-boot-http-server my-server
29
- cd my-server
30
- npm start
31
- ```
32
-
33
- ## Security Hardening
34
-
35
- - Enforce TLS in production: configure HTTPS (or terminate TLS at a trusted reverse proxy) and redirect HTTP to HTTPS.
36
- - Keep session cookies hardened: use `httpOnly`, `secure`, `sameSite`, short expiration, and explicit `domain/path` when required.
37
- - Protect WebSocket endpoints: validate origin, authenticate at connect/subscribe time, and authorize per topic.
38
- - Validate all inputs: apply strict validation for route params, query/body payloads, and uploaded files (type/size/path).
39
- - Avoid sensitive data leakage: never return stack traces, internal file paths, raw SQL errors, or secrets in responses/logs.
40
- - Configure CORS minimally: allow only required origins/methods/headers, avoid wildcard credentials.
41
- - Add rate limiting and timeout guards: mitigate brute force and resource-exhaustion attacks.
42
- - Rotate secrets/keys regularly and load them from environment or a secret manager (never hardcode in source).
43
- - Keep dependencies updated and scan regularly for CVEs.
44
-
45
- ### Minimal Production Checklist
46
-
47
- - `HTTPS` enabled end-to-end
48
- - Session cookie options set (`httpOnly`, `secure`, `sameSite`)
49
- - CORS restricted to trusted origins
50
- - Request/WS auth + authorization enforced
51
- - Upload size/type limits configured
52
- - Error responses sanitized
53
-
54
- ## Learn More
55
-
56
- The detailed API documentation, including all decorators and usage examples, is available on our documentation website.
57
-
58
- - WebSocket Guide: [document/websocket/README.md](document/websocket/README.md)
59
-
60
- ## License
61
-
62
- This package is licensed under the [MIT License](https://opensource.org/licenses/MIT).
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReqSearchParamsObj.d.ts","sourceRoot":"","sources":["../../../../../src/models/datas/search/ReqSearchParamsObj.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAkB;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB"}
File without changes