framework-do-dede 0.0.43 → 0.0.44
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/dist/http/HttpServer.js +33 -22
- package/package.json +1 -1
package/dist/http/HttpServer.js
CHANGED
|
@@ -38,29 +38,40 @@ export default class HttpServer {
|
|
|
38
38
|
}
|
|
39
39
|
elysia(httpServerParams, route, handler) {
|
|
40
40
|
const method = httpServerParams.method;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
(this.framework[method])(route, async ({ headers, set, query, params, body, request }) => {
|
|
42
|
+
// try {
|
|
43
|
+
headers['ip'] = this.framework.server?.requestIP(request).address;
|
|
44
|
+
set.status = httpServerParams.statusCode ?? 200;
|
|
45
|
+
return Promise.resolve().then(() => handler({
|
|
46
|
+
headers,
|
|
47
|
+
query,
|
|
48
|
+
params,
|
|
49
|
+
body
|
|
50
|
+
})).then((output) => output)
|
|
51
|
+
.catch((error) => {
|
|
52
|
+
if (error instanceof ServerError) {
|
|
53
|
+
set.status = error.getStatusCode();
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
set.status = 500;
|
|
57
|
+
throw new InternalServerError(error.message, this.defaultMessageError);
|
|
53
58
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
// const output = await handler({
|
|
60
|
+
// headers,
|
|
61
|
+
// query,
|
|
62
|
+
// params,
|
|
63
|
+
// body
|
|
64
|
+
// })
|
|
65
|
+
// return output
|
|
66
|
+
// } catch (error: any) {
|
|
67
|
+
// if (error instanceof ServerError) {
|
|
68
|
+
// set.status = error.getStatusCode()
|
|
69
|
+
// throw error;
|
|
70
|
+
// }
|
|
71
|
+
// set.status = 500
|
|
72
|
+
// throw new InternalServerError(error.message, this.defaultMessageError)
|
|
73
|
+
// }
|
|
74
|
+
});
|
|
64
75
|
}
|
|
65
76
|
express(httpServerParams, route, handler) {
|
|
66
77
|
const method = httpServerParams.method;
|