@kiyasov/platform-hono 1.2.6 → 1.2.8
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/cjs/src/adapters/hono-adapter.js +23 -31
- package/dist/cjs/src/adapters/hono-adapter.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/adapters/hono-adapter.js +23 -31
- package/dist/esm/src/adapters/hono-adapter.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/adapters/hono-adapter.ts +28 -30
package/package.json
CHANGED
|
@@ -220,37 +220,35 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
220
220
|
this.instance.use(this.bodyLimit(bodyLimit), async (ctx, next) => {
|
|
221
221
|
const contentType = ctx.req.header("content-type");
|
|
222
222
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (contentType?.startsWith("text/plain")) {
|
|
234
|
-
if (rawBody) {
|
|
235
|
-
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
236
|
-
}
|
|
237
|
-
(ctx.req as any).body = await ctx.req.json();
|
|
238
|
-
}
|
|
239
|
-
break;
|
|
240
|
-
default:
|
|
241
|
-
{
|
|
242
|
-
try {
|
|
243
|
-
if (rawBody) {
|
|
244
|
-
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
245
|
-
}
|
|
246
|
-
(ctx.req as any).body = await ctx.req.json();
|
|
247
|
-
} catch {
|
|
248
|
-
(ctx.req as any).body = await ctx.req.parseBody({ all: true });
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
break;
|
|
223
|
+
if (
|
|
224
|
+
contentType?.startsWith("application/json") ||
|
|
225
|
+
contentType?.startsWith("text/plain")
|
|
226
|
+
) {
|
|
227
|
+
if (rawBody) {
|
|
228
|
+
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
229
|
+
}
|
|
230
|
+
(ctx.req as any).body = await ctx.req.json();
|
|
231
|
+
|
|
232
|
+
return await next();
|
|
252
233
|
}
|
|
253
|
-
|
|
234
|
+
|
|
235
|
+
if (contentType !== type) {
|
|
236
|
+
return await next();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (contentType?.startsWith("application/json")) {
|
|
240
|
+
if (rawBody) {
|
|
241
|
+
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
242
|
+
}
|
|
243
|
+
(ctx.req as any).body = await ctx.req.json();
|
|
244
|
+
} else if (contentType?.startsWith("text/plain")) {
|
|
245
|
+
if (rawBody) {
|
|
246
|
+
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
247
|
+
}
|
|
248
|
+
(ctx.req as any).body = await ctx.req.json();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return await next();
|
|
254
252
|
});
|
|
255
253
|
|
|
256
254
|
// To avoid the Nest application init to override our custom
|