@kiyasov/platform-hono 1.2.7 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiyasov/platform-hono",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Nest adapter for Hono",
5
5
  "author": "Islam Kiiasov",
6
6
  "repository": {
@@ -220,28 +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
- switch (type) {
224
- case "application/json":
225
- if (contentType?.startsWith("application/json")) {
226
- if (rawBody) {
227
- (ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
228
- }
229
- (ctx.req as any).body = await ctx.req.json();
230
- }
231
- break;
232
- case "text/plain":
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
- (ctx.req as any).body = await ctx.req.parseBody({ all: true });
242
- 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();
243
233
  }
244
- await next();
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();
245
252
  });
246
253
 
247
254
  // To avoid the Nest application init to override our custom