@kiyasov/platform-hono 1.2.0 → 1.2.3
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.d.ts +4 -2
- package/dist/cjs/src/adapters/hono-adapter.js +17 -7
- 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.d.ts +4 -2
- package/dist/esm/src/adapters/hono-adapter.js +17 -7
- 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 +16 -7
package/package.json
CHANGED
|
@@ -210,11 +210,21 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
210
210
|
this.instance.use(cors(options));
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
public useBodyParser(
|
|
214
|
-
|
|
213
|
+
public useBodyParser(
|
|
214
|
+
type: TypeBodyParser,
|
|
215
|
+
rawBody?: boolean,
|
|
216
|
+
bodyLimit?: number
|
|
217
|
+
) {
|
|
218
|
+
Logger.log(
|
|
219
|
+
`Registering body parser middleware for type: ${type} | bodyLimit: ${bodyLimit}`
|
|
220
|
+
);
|
|
215
221
|
this.instance.use(this.bodyLimit(bodyLimit), async (ctx, next) => {
|
|
216
222
|
const contentType = ctx.req.header("content-type");
|
|
217
223
|
|
|
224
|
+
if (rawBody) {
|
|
225
|
+
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
226
|
+
}
|
|
227
|
+
|
|
218
228
|
switch (type) {
|
|
219
229
|
case "application/json":
|
|
220
230
|
if (contentType?.startsWith("application/json"))
|
|
@@ -222,7 +232,6 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
222
232
|
break;
|
|
223
233
|
case "text/plain":
|
|
224
234
|
if (contentType?.startsWith("text/plain")) {
|
|
225
|
-
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
226
235
|
(ctx.req as any).body = await ctx.req.json();
|
|
227
236
|
}
|
|
228
237
|
break;
|
|
@@ -258,15 +267,15 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
258
267
|
return "hono";
|
|
259
268
|
}
|
|
260
269
|
|
|
261
|
-
public registerParserMiddleware(
|
|
270
|
+
public registerParserMiddleware(_prefix?: string, rawBody?: boolean) {
|
|
262
271
|
if (this._isParserRegistered) {
|
|
263
272
|
return;
|
|
264
273
|
}
|
|
265
274
|
|
|
266
275
|
Logger.log("Registering parser middleware");
|
|
267
|
-
this.useBodyParser("application/x-www-form-urlencoded");
|
|
268
|
-
this.useBodyParser("application/json");
|
|
269
|
-
this.useBodyParser("text/plain");
|
|
276
|
+
this.useBodyParser("application/x-www-form-urlencoded", rawBody);
|
|
277
|
+
this.useBodyParser("application/json", rawBody);
|
|
278
|
+
this.useBodyParser("text/plain", rawBody);
|
|
270
279
|
|
|
271
280
|
this._isParserRegistered = true;
|
|
272
281
|
}
|