@kiyasov/platform-hono 1.1.3 → 1.1.5
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/package.json
CHANGED
|
@@ -53,11 +53,15 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
53
53
|
private createRouteHandler(routeHandler: HonoHandler) {
|
|
54
54
|
return async (ctx: Context, next: Next) => {
|
|
55
55
|
await routeHandler(ctx.req, ctx, next);
|
|
56
|
-
|
|
57
|
-
return typeof body === "string" ? ctx.text(body) : ctx.json(body);
|
|
56
|
+
return this.send(ctx);
|
|
58
57
|
};
|
|
59
58
|
}
|
|
60
59
|
|
|
60
|
+
private send(ctx: Context) {
|
|
61
|
+
const body = ctx.get("body");
|
|
62
|
+
return typeof body === "string" ? ctx.text(body) : ctx.json(body);
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
public get(pathOrHandler: string | HonoHandler, handler?: HonoHandler) {
|
|
62
66
|
const [routePath, routeHandler] = this.getRouteAndHandler(
|
|
63
67
|
pathOrHandler,
|
|
@@ -149,16 +153,14 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
149
153
|
public setErrorHandler(handler: ErrorHandler) {
|
|
150
154
|
this.instance.onError(async (err: Error, ctx: Context) => {
|
|
151
155
|
await handler(err, ctx.req, ctx);
|
|
152
|
-
|
|
153
|
-
return typeof body === "string" ? ctx.text(body) : ctx.json(body);
|
|
156
|
+
return this.send(ctx);
|
|
154
157
|
});
|
|
155
158
|
}
|
|
156
159
|
|
|
157
160
|
public setNotFoundHandler(handler: RequestHandler) {
|
|
158
161
|
this.instance.notFound(async (ctx: Context) => {
|
|
159
162
|
await handler(ctx.req, ctx);
|
|
160
|
-
|
|
161
|
-
return typeof body === "string" ? ctx.text(body) : ctx.json(body);
|
|
163
|
+
return this.send(ctx);
|
|
162
164
|
});
|
|
163
165
|
}
|
|
164
166
|
|
|
@@ -17,7 +17,7 @@ export const getMultipartRequest = (ctx: HttpArgumentsHost) => {
|
|
|
17
17
|
const req = ctx.getRequest<THonoRequest>();
|
|
18
18
|
|
|
19
19
|
if (!req.header("content-type")?.startsWith("multipart/form-data")) {
|
|
20
|
-
throw new BadRequestException("Not a multipart request");
|
|
20
|
+
// throw new BadRequestException("Not a multipart request");
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return req;
|