@dooboostore/simple-boot-http-server 1.0.25 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -14
- package/dist/cjs/SimpleBootHttpServer.js +34 -18
- package/dist/cjs/SimpleBootHttpServer.js.map +2 -2
- package/dist/cjs/bundle-entry.js +34 -24
- package/dist/cjs/bundle-entry.js.map +2 -2
- package/dist/cjs/codes/Mimes.js +2 -0
- package/dist/cjs/codes/Mimes.js.map +2 -2
- package/dist/cjs/decorators/MethodMapping.js +2 -2
- package/dist/cjs/decorators/MethodMapping.js.map +2 -2
- package/dist/cjs/filters/ResourceFilter.js +0 -1
- package/dist/cjs/filters/ResourceFilter.js.map +2 -2
- package/dist/cjs/option/HttpServerOption.js.map +2 -2
- package/dist/cjs/proxy/TopicProtocolApiServiceProxy.js +244 -266
- package/dist/cjs/proxy/TopicProtocolApiServiceProxy.js.map +3 -3
- package/dist/cjs/websocket/WebSocketClient.js +2 -1
- package/dist/cjs/websocket/WebSocketClient.js.map +2 -2
- package/dist/cjs/websocket/WebSocketManager.js +68 -40
- package/dist/cjs/websocket/WebSocketManager.js.map +2 -2
- package/dist/esm/SimpleBootHttpServer.js +34 -18
- package/dist/esm/SimpleBootHttpServer.js.map +2 -2
- package/dist/esm/bundle-entry.js +14 -12
- package/dist/esm/bundle-entry.js.map +2 -2
- package/dist/esm/codes/Mimes.js +2 -0
- package/dist/esm/codes/Mimes.js.map +2 -2
- package/dist/esm/decorators/MethodMapping.js +2 -2
- package/dist/esm/decorators/MethodMapping.js.map +2 -2
- package/dist/esm/filters/ResourceFilter.js +0 -1
- package/dist/esm/filters/ResourceFilter.js.map +2 -2
- package/dist/esm/option/HttpServerOption.js.map +2 -2
- package/dist/esm/proxy/TopicProtocolApiServiceProxy.js +244 -266
- package/dist/esm/proxy/TopicProtocolApiServiceProxy.js.map +3 -3
- package/dist/esm/websocket/WebSocketClient.js +3 -2
- package/dist/esm/websocket/WebSocketClient.js.map +2 -2
- package/dist/esm/websocket/WebSocketManager.js +68 -40
- package/dist/esm/websocket/WebSocketManager.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +19134 -9180
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +4 -4
- package/dist/types/SimpleBootHttpServer.d.ts.map +1 -1
- package/dist/types/bundle-entry.d.ts +7 -12
- package/dist/types/bundle-entry.d.ts.map +1 -1
- package/dist/types/codes/Mimes.d.ts +2 -0
- package/dist/types/codes/Mimes.d.ts.map +1 -1
- package/dist/types/decorators/MethodMapping.d.ts +8 -0
- package/dist/types/decorators/MethodMapping.d.ts.map +1 -1
- package/dist/types/filters/ResourceFilter.d.ts.map +1 -1
- package/dist/types/option/HttpServerOption.d.ts +6 -2
- package/dist/types/option/HttpServerOption.d.ts.map +1 -1
- package/dist/types/proxy/TopicProtocolApiServiceProxy.d.ts +5 -15
- package/dist/types/proxy/TopicProtocolApiServiceProxy.d.ts.map +1 -1
- package/dist/types/websocket/WebSocketClient.d.ts.map +1 -1
- package/dist/types/websocket/WebSocketManager.d.ts +3 -1
- package/dist/types/websocket/WebSocketManager.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +19121 -9173
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +4 -4
- package/dist/umd-bundle/websocket-client.umd.js +412 -1482
- package/dist/umd-bundle/websocket-client.umd.js.map +4 -4
- package/package.json +8 -8
- package/src/SimpleBootHttpServer.ts +37 -18
- package/src/bundle-entry.ts +12 -12
- package/src/codes/Mimes.ts +2 -0
- package/src/decorators/MethodMapping.ts +14 -7
- package/src/filters/ResourceFilter.ts +0 -1
- package/src/option/HttpServerOption.ts +4 -2
- package/src/proxy/TopicProtocolApiServiceProxy.ts +260 -275
- package/src/websocket/WebSocketClient.ts +3 -2
- package/src/websocket/WebSocketManager.ts +69 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooboostore/simple-boot-http-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -91,18 +91,18 @@
|
|
|
91
91
|
"typescript": "^5.9.2",
|
|
92
92
|
"webpack": "^5.93.0",
|
|
93
93
|
"webpack-cli": "^5.1.4",
|
|
94
|
-
"webpack-dev-server": "^5.2.0"
|
|
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"
|
|
94
|
+
"webpack-dev-server": "^5.2.0"
|
|
100
95
|
},
|
|
101
96
|
"dependencies": {
|
|
102
97
|
"fast-json-patch": "^3.1.0",
|
|
103
98
|
"mime-types": "^2.1.34",
|
|
104
99
|
"node-gzip": "^1.1.2",
|
|
105
|
-
"ws": "^8.18.3"
|
|
100
|
+
"ws": "^8.18.3",
|
|
101
|
+
"@dooboostore/core": "1.0.32",
|
|
102
|
+
"@dooboostore/core-node": "1.0.13",
|
|
103
|
+
"@dooboostore/core-web": "1.0.13",
|
|
104
|
+
"@dooboostore/simple-boot": "1.0.57",
|
|
105
|
+
"@dooboostore/dom-render": "1.0.114"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|
|
108
108
|
"clean": "rm -rf dist",
|
|
@@ -48,7 +48,7 @@ export class SimpleBootHttpServer extends SimpleApplication {
|
|
|
48
48
|
otherInstanceSim ??= new Map<ConstructorType<any> | Function | SimConfig | symbol, any>();
|
|
49
49
|
otherInstanceSim.set(SimpleBootHttpServer, this);
|
|
50
50
|
super.run(otherInstanceSim);
|
|
51
|
-
const targets = [...this.option.closeEndPoints ?? [], ...this.option.errorEndPoints ?? [], ...this.option.requestEndPoints ?? [], ...this.option.filters ?? []];
|
|
51
|
+
const targets = [...this.option.closeEndPoints ?? [], ...this.option.errorEndPoints ?? [], ...this.option.requestEndPoints ?? [], ...(this.option.filters ?? []).map(it=>it.filter)];
|
|
52
52
|
Promise.all(targets.map(it => (typeof it === 'function' ? this.simstanceManager.getOrNewSim({target: it as ConstructorType<any>}) : it) as OnInit).map(it => it.onInit(this))).then(it => {
|
|
53
53
|
this.startServer();
|
|
54
54
|
});
|
|
@@ -158,8 +158,22 @@ export class SimpleBootHttpServer extends SimpleApplication {
|
|
|
158
158
|
};
|
|
159
159
|
for (let i = 0; this.option.filters && i < this.option.filters.length; i++) {
|
|
160
160
|
const it = this.option.filters[i];
|
|
161
|
-
|
|
161
|
+
|
|
162
|
+
let isSkip = false;
|
|
163
|
+
if (typeof it.isSupport === 'boolean') {
|
|
164
|
+
isSkip = !it.isSupport;
|
|
165
|
+
} else if (typeof it.isSupport === 'object') {
|
|
166
|
+
isSkip = !it.isSupport.test(rr.reqUrlPathName)
|
|
167
|
+
} else if (typeof it.isSupport === 'function') {
|
|
168
|
+
isSkip = !it.isSupport(rr);
|
|
169
|
+
}
|
|
170
|
+
if(isSkip) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
|
|
162
174
|
let sw = true;
|
|
175
|
+
const itFilter = it.filter;
|
|
176
|
+
const execute = (typeof itFilter === 'function' ? this.simstanceManager.getOrNewSim({target: itFilter}) : itFilter) as Filter;
|
|
163
177
|
if (execute?.proceedBefore) {
|
|
164
178
|
sw = await execute.proceedBefore({rr, app: this, carrier: filter.carrier});
|
|
165
179
|
filter.filters.push({filter: execute, sw});
|
|
@@ -312,23 +326,28 @@ export class SimpleBootHttpServer extends SimpleApplication {
|
|
|
312
326
|
여기에서 정해진 타입 리턴에 따른 조치
|
|
313
327
|
...
|
|
314
328
|
*/
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
329
|
+
const resConfig = it.config?.res;
|
|
330
|
+
if (resConfig?.manual === true) {
|
|
331
|
+
// 핸들러가 ServerResponse를 직접 주입받아 스스로 write/end를 제어한다 (예: SSE 스트리밍)
|
|
332
|
+
} else {
|
|
333
|
+
if (it.config?.resolver) {
|
|
334
|
+
const execute = typeof it.config.resolver === 'function' ? this.simstanceManager.getOrNewSim({target: it.config.resolver}) : it.config.resolver;
|
|
335
|
+
data = await execute?.resolve?.(data, rr);
|
|
336
|
+
}
|
|
337
|
+
const status = resConfig?.status ?? HttpStatus.Ok;
|
|
338
|
+
const headers = resConfig?.header ?? {};
|
|
339
|
+
if (resConfig?.contentType) {
|
|
340
|
+
headers[HttpHeaders.ContentType] = resConfig.contentType;
|
|
341
|
+
}
|
|
342
|
+
if ((resConfig?.contentType?.toLowerCase().indexOf(Mimes.ApplicationJson.toLowerCase()) ?? -1) > -1) {
|
|
343
|
+
data = JSON.stringify(data);
|
|
344
|
+
} else if (data && typeof data === 'object') {
|
|
345
|
+
data = JSON.stringify(data);
|
|
346
|
+
}
|
|
347
|
+
rr.resSetHeaders(headers)
|
|
348
|
+
rr.resSetStatusCode(status);
|
|
349
|
+
rr.resWrite(data);
|
|
328
350
|
}
|
|
329
|
-
rr.resSetHeaders(headers)
|
|
330
|
-
rr.resSetStatusCode(status);
|
|
331
|
-
rr.resWrite(data);
|
|
332
351
|
}
|
|
333
352
|
}
|
|
334
353
|
|
package/src/bundle-entry.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export * from './
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
export * from '
|
|
9
|
-
export * from '
|
|
10
|
-
export * from '
|
|
11
|
-
export * from '
|
|
12
|
-
export * from '
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
|
|
3
|
+
// simple-boot-http-server itself
|
|
4
|
+
export * from './index';
|
|
5
|
+
|
|
6
|
+
// Re-export peer dependencies so bundle consumers can access them
|
|
7
|
+
// without separately importing each package
|
|
8
|
+
export * as Core from '@dooboostore/core';
|
|
9
|
+
export * as CoreNode from '@dooboostore/core-node';
|
|
10
|
+
export * as CoreWeb from '@dooboostore/core-web';
|
|
11
|
+
export * as DomRender from '@dooboostore/dom-render';
|
|
12
|
+
export * as SimpleBoot from '@dooboostore/simple-boot';
|
package/src/codes/Mimes.ts
CHANGED
|
@@ -24,6 +24,8 @@ export enum Mimes {
|
|
|
24
24
|
ImageXpixmap = 'image/x-xpixmap',
|
|
25
25
|
ImageXxbm = 'image/x-xbm',
|
|
26
26
|
MultipartFormData = 'multipart/form-data',
|
|
27
|
+
TextEventStream = 'text/event-stream', // SSE 실시간 텍스트 스트리밍
|
|
28
|
+
ApplicationXndjson = 'application/x-ndjson',
|
|
27
29
|
ApplicationJsonPostSimpleBootSsrIntentScheme = 'application/json-post+simple-boot-ssr-intent-scheme',
|
|
28
30
|
Intent = 'intent'
|
|
29
31
|
}
|
|
@@ -24,11 +24,18 @@ export type MappingConfig = {
|
|
|
24
24
|
accept?: (Mimes|string)[];
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
res?:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
res?:
|
|
28
|
+
| {
|
|
29
|
+
status?: number;
|
|
30
|
+
header?: {[key: string]: string};
|
|
31
|
+
contentType?: Mimes | string;
|
|
32
|
+
manual?: false;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* manual: true — 리턴값을 이용한 자동 status/header/body 처리(및 resolver 호출)를 건너뛴다.
|
|
36
|
+
* SSE 등 핸들러가 ServerResponse를 직접 주입받아 writeHead/write/end를 스스로 제어하는 경우 사용.
|
|
37
|
+
*/
|
|
38
|
+
| { manual: true };
|
|
32
39
|
resolver?: Resolver|ConstructorType<Resolver>;
|
|
33
40
|
}
|
|
34
41
|
export type SaveMappingConfig = {propertyKey: string | symbol; config: MappingConfig}
|
|
@@ -156,7 +163,7 @@ export const getPATCH = (target: any, propertyKey: string | symbol): MappingConf
|
|
|
156
163
|
return getUrlMapping(target, propertyKey);
|
|
157
164
|
}
|
|
158
165
|
export const getPATCHS = (target: any): SaveMappingConfig[] => {
|
|
159
|
-
return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.
|
|
166
|
+
return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PATCH);
|
|
160
167
|
}
|
|
161
168
|
export function OPTIONS(config: Omit<MappingConfig, 'method'>): ReflectMethod;
|
|
162
169
|
export function OPTIONS(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
@@ -194,7 +201,7 @@ export const getHEAD = (target: any, propertyKey: string | symbol): MappingConfi
|
|
|
194
201
|
return getUrlMapping(target, propertyKey);
|
|
195
202
|
}
|
|
196
203
|
export const getHEADS = (target: any): SaveMappingConfig[] => {
|
|
197
|
-
return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.
|
|
204
|
+
return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.HEAD);
|
|
198
205
|
}
|
|
199
206
|
export function TRACE(config: Omit<MappingConfig, 'method'>): ReflectMethod;
|
|
200
207
|
export function TRACE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
@@ -33,12 +33,14 @@ export type SessionOption = {
|
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
export type FilterSupportType = { filter: Filter | ConstructorType<Filter>, isSupport: boolean | ((rr: RequestResponse) => boolean) | RegExp };
|
|
37
|
+
|
|
36
38
|
export class HttpServerOption extends SimOption {
|
|
37
39
|
public static readonly DEFAULT_PORT = 8081;
|
|
38
40
|
public static readonly DEFAULT_HOSTNAME = '127.0.0.1';
|
|
39
41
|
public serverOption?: ServerOptions | HttpsServerOption;
|
|
40
42
|
public listen: ListenData;
|
|
41
|
-
public filters?:
|
|
43
|
+
public filters?: FilterSupportType[];
|
|
42
44
|
public fileUploadTempPath?: string;
|
|
43
45
|
public requestEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];
|
|
44
46
|
public webSocketEndPoints?: (WebSocketEndPoint | ConstructorType<WebSocketEndPoint>)[];
|
|
@@ -66,7 +68,7 @@ export class HttpServerOption extends SimOption {
|
|
|
66
68
|
}: {
|
|
67
69
|
serverOption?: ServerOptions | HttpsServerOption;
|
|
68
70
|
listen?: Listen;
|
|
69
|
-
filters?: (
|
|
71
|
+
filters?: (FilterSupportType)[];
|
|
70
72
|
requestEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];
|
|
71
73
|
closeEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];
|
|
72
74
|
errorEndPoints?: (EndPoint | ConstructorType<EndPoint>)[];
|