@dooboostore/simple-boot-http-server 1.0.32 → 1.0.34
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 +34 -0
- package/dist/cjs/SimpleBootHttpServer.js +25 -4
- package/dist/cjs/SimpleBootHttpServer.js.map +2 -2
- package/dist/cjs/decorators/MethodMapping.js +9 -0
- package/dist/cjs/decorators/MethodMapping.js.map +2 -2
- package/dist/esm/SimpleBootHttpServer.js +25 -4
- package/dist/esm/SimpleBootHttpServer.js.map +2 -2
- package/dist/esm/decorators/MethodMapping.js +9 -0
- package/dist/esm/decorators/MethodMapping.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +34 -4
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +2 -2
- package/dist/types/SimpleBootHttpServer.d.ts +8 -0
- package/dist/types/SimpleBootHttpServer.d.ts.map +1 -1
- package/dist/types/decorators/MethodMapping.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +34 -4
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +2 -2
- package/package.json +10 -8
- package/src/SimpleBootHttpServer.ts +28 -4
- package/src/decorators/MethodMapping.ts +9 -0
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.34",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -55,16 +55,18 @@
|
|
|
55
55
|
"SeoDH <adonis_84@naver.com> (https://github.com/SeoDH)",
|
|
56
56
|
"tkyung (https://github.com/tkyungDev)",
|
|
57
57
|
"Hoil-Gang (https://github.com/khl1154)",
|
|
58
|
-
"hwangsero (https://github.com/hwangsero)"
|
|
58
|
+
"hwangsero (https://github.com/hwangsero)",
|
|
59
|
+
"visualkhh <visualkhh@gmail.com> (https://github.com/visualkhh)"
|
|
59
60
|
],
|
|
60
|
-
"homepage": "https://github.
|
|
61
|
+
"homepage": "https://dooboostore-develop.github.io/package/simple-boot-http-server",
|
|
61
62
|
"bugs": {
|
|
62
|
-
"url": "https://github.com/dooboostore-develop/packages",
|
|
63
|
+
"url": "https://github.com/dooboostore-develop/packages/issues",
|
|
63
64
|
"email": "dooboostore@gmail.com"
|
|
64
65
|
},
|
|
65
66
|
"repository": {
|
|
66
67
|
"type": "git",
|
|
67
|
-
"url": "https://github.com/dooboostore-develop/packages"
|
|
68
|
+
"url": "git+https://github.com/dooboostore-develop/packages.git",
|
|
69
|
+
"directory": "packages/@dooboostore/simple-boot-http-server"
|
|
68
70
|
},
|
|
69
71
|
"peerDependencies": {
|
|
70
72
|
"reflect-metadata": "^0.2.2"
|
|
@@ -99,10 +101,10 @@
|
|
|
99
101
|
"node-gzip": "^1.1.2",
|
|
100
102
|
"ws": "^8.18.3",
|
|
101
103
|
"@dooboostore/core": "1.0.33",
|
|
102
|
-
"@dooboostore/dom-render": "1.0.115",
|
|
103
|
-
"@dooboostore/core-node": "1.0.14",
|
|
104
104
|
"@dooboostore/core-web": "1.0.14",
|
|
105
|
-
"@dooboostore/simple-boot": "1.0.60"
|
|
105
|
+
"@dooboostore/simple-boot": "1.0.60",
|
|
106
|
+
"@dooboostore/dom-render": "1.0.115",
|
|
107
|
+
"@dooboostore/core-node": "1.0.14"
|
|
106
108
|
},
|
|
107
109
|
"scripts": {
|
|
108
110
|
"clean": "rm -rf dist",
|
|
@@ -44,6 +44,27 @@ export class SimpleBootHttpServer extends SimpleApplication {
|
|
|
44
44
|
this.sessionManager = new SessionManager(this.option);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Final response flush that can never escape as an unhandled rejection.
|
|
49
|
+
* When the response is already gone (sent, closed, or destroyed mid-write),
|
|
50
|
+
* there is nobody left to send to, so gone-response write errors
|
|
51
|
+
* (ERR_HTTP_HEADERS_SENT, ERR_STREAM_ALREADY_FINISHED,
|
|
52
|
+
* ERR_STREAM_DESTROYED, ECONNRESET) are swallowed; anything else still throws.
|
|
53
|
+
*/
|
|
54
|
+
private async safeResEnd(rr: RequestResponse): Promise<void> {
|
|
55
|
+
if (rr.resIsDone()) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
await rr.resEnd();
|
|
60
|
+
} catch (e: any) {
|
|
61
|
+
const code = e && (e.code || '');
|
|
62
|
+
if (code !== 'ERR_HTTP_HEADERS_SENT' && code !== 'ERR_STREAM_ALREADY_FINISHED' && code !== 'ERR_STREAM_DESTROYED' && code !== 'ECONNRESET') {
|
|
63
|
+
throw e;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
47
68
|
|
|
48
69
|
public run(otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>) {
|
|
49
70
|
otherInstanceSim ??= new Map<ConstructorType<any> | Function | SimConfig | symbol, any>();
|
|
@@ -95,7 +116,7 @@ export class SimpleBootHttpServer extends SimpleApplication {
|
|
|
95
116
|
}
|
|
96
117
|
|
|
97
118
|
if (!rr.resIsDone()) {
|
|
98
|
-
|
|
119
|
+
await this.safeResEnd(rr);
|
|
99
120
|
}
|
|
100
121
|
});
|
|
101
122
|
res.on('error', async () => {
|
|
@@ -113,7 +134,7 @@ export class SimpleBootHttpServer extends SimpleApplication {
|
|
|
113
134
|
}
|
|
114
135
|
|
|
115
136
|
if (!rr.resIsDone()) {
|
|
116
|
-
|
|
137
|
+
await this.safeResEnd(rr);
|
|
117
138
|
}
|
|
118
139
|
});
|
|
119
140
|
|
|
@@ -390,7 +411,10 @@ export class SimpleBootHttpServer extends SimpleApplication {
|
|
|
390
411
|
console.error('request error:', e);
|
|
391
412
|
transactionManager?.catch(e);
|
|
392
413
|
rr.resStatusCode(e instanceof HttpError ? e.status : HttpStatus.InternalServerError)
|
|
393
|
-
const
|
|
414
|
+
const globalAdvice = this.option.globalAdvice;
|
|
415
|
+
// getOrNewSim takes { target }; passing the class directly
|
|
416
|
+
// destructures to undefined and silently disables globalAdvice.
|
|
417
|
+
const execute = typeof globalAdvice === 'function' ? this.simstanceManager.getOrNewSim({ target: globalAdvice }) : globalAdvice;
|
|
394
418
|
if (!execute) {
|
|
395
419
|
rr.resEnd();
|
|
396
420
|
// rr.resEnd().catch(e => {
|
|
@@ -416,7 +440,7 @@ export class SimpleBootHttpServer extends SimpleApplication {
|
|
|
416
440
|
}
|
|
417
441
|
|
|
418
442
|
if (!rr.resIsDone()) {
|
|
419
|
-
|
|
443
|
+
await this.safeResEnd(rr);
|
|
420
444
|
}
|
|
421
445
|
});
|
|
422
446
|
|
|
@@ -69,6 +69,7 @@ export function GET(configOrTarget?: Omit<MappingConfig, 'method'> | any, proper
|
|
|
69
69
|
process({ method: HttpMethod.GET }, configOrTarget, propertyKey, descriptor);
|
|
70
70
|
} else {
|
|
71
71
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
72
|
+
configOrTarget = configOrTarget ?? {};
|
|
72
73
|
configOrTarget.method = HttpMethod.GET;
|
|
73
74
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
74
75
|
};
|
|
@@ -88,6 +89,7 @@ export function POST(configOrTarget?: Omit<MappingConfig, 'method'> | any, prope
|
|
|
88
89
|
process({ method: HttpMethod.POST }, configOrTarget, propertyKey, descriptor);
|
|
89
90
|
} else {
|
|
90
91
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
92
|
+
configOrTarget = configOrTarget ?? {};
|
|
91
93
|
configOrTarget.method = HttpMethod.POST;
|
|
92
94
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
93
95
|
};
|
|
@@ -107,6 +109,7 @@ export function DELETE(configOrTarget?: Omit<MappingConfig, 'method'> | any, pro
|
|
|
107
109
|
process({ method: HttpMethod.DELETE }, configOrTarget, propertyKey, descriptor);
|
|
108
110
|
} else {
|
|
109
111
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
112
|
+
configOrTarget = configOrTarget ?? {};
|
|
110
113
|
configOrTarget.method = HttpMethod.DELETE;
|
|
111
114
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
112
115
|
};
|
|
@@ -126,6 +129,7 @@ export function PUT(configOrTarget?: Omit<MappingConfig, 'method'> | any, proper
|
|
|
126
129
|
process({ method: HttpMethod.PUT }, configOrTarget, propertyKey, descriptor);
|
|
127
130
|
} else {
|
|
128
131
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
132
|
+
configOrTarget = configOrTarget ?? {};
|
|
129
133
|
configOrTarget.method = HttpMethod.PUT;
|
|
130
134
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
131
135
|
};
|
|
@@ -145,6 +149,7 @@ export function PATCH(configOrTarget?: Omit<MappingConfig, 'method'> | any, prop
|
|
|
145
149
|
process({ method: HttpMethod.PATCH }, configOrTarget, propertyKey, descriptor);
|
|
146
150
|
} else {
|
|
147
151
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
152
|
+
configOrTarget = configOrTarget ?? {};
|
|
148
153
|
configOrTarget.method = HttpMethod.PATCH;
|
|
149
154
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
150
155
|
};
|
|
@@ -164,6 +169,7 @@ export function OPTIONS(configOrTarget?: Omit<MappingConfig, 'method'> | any, pr
|
|
|
164
169
|
process({ method: HttpMethod.OPTIONS }, configOrTarget, propertyKey, descriptor);
|
|
165
170
|
} else {
|
|
166
171
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
172
|
+
configOrTarget = configOrTarget ?? {};
|
|
167
173
|
configOrTarget.method = HttpMethod.OPTIONS;
|
|
168
174
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
169
175
|
};
|
|
@@ -183,6 +189,7 @@ export function HEAD(configOrTarget?: Omit<MappingConfig, 'method'> | any, prope
|
|
|
183
189
|
process({ method: HttpMethod.HEAD }, configOrTarget, propertyKey, descriptor);
|
|
184
190
|
} else {
|
|
185
191
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
192
|
+
configOrTarget = configOrTarget ?? {};
|
|
186
193
|
configOrTarget.method = HttpMethod.HEAD;
|
|
187
194
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
188
195
|
};
|
|
@@ -202,6 +209,7 @@ export function TRACE(configOrTarget?: Omit<MappingConfig, 'method'> | any, prop
|
|
|
202
209
|
process({ method: HttpMethod.TRACE }, configOrTarget, propertyKey, descriptor);
|
|
203
210
|
} else {
|
|
204
211
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
212
|
+
configOrTarget = configOrTarget ?? {};
|
|
205
213
|
configOrTarget.method = HttpMethod.TRACE;
|
|
206
214
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
207
215
|
};
|
|
@@ -221,6 +229,7 @@ export function CONNECT(configOrTarget?: Omit<MappingConfig, 'method'> | any, pr
|
|
|
221
229
|
process({ method: HttpMethod.CONNECT }, configOrTarget, propertyKey, descriptor);
|
|
222
230
|
} else {
|
|
223
231
|
return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
232
|
+
configOrTarget = configOrTarget ?? {};
|
|
224
233
|
configOrTarget.method = HttpMethod.CONNECT;
|
|
225
234
|
process(configOrTarget, target, propertyKey, descriptor);
|
|
226
235
|
};
|