@kiyasov/platform-hono 1.2.4 → 1.2.6
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 +2 -3
- package/dist/cjs/src/adapters/hono-adapter.js +15 -1
- package/dist/cjs/src/adapters/hono-adapter.js.map +1 -1
- package/dist/cjs/src/interfaces/hono.d.ts +4 -0
- package/dist/cjs/src/interfaces/hono.interface.d.ts +4 -0
- package/dist/cjs/src/interfaces/hono.interface.js +3 -0
- package/dist/cjs/src/interfaces/hono.interface.js.map +1 -0
- package/dist/cjs/src/interfaces/hono.js +3 -0
- package/dist/cjs/src/interfaces/hono.js.map +1 -0
- package/dist/cjs/src/interfaces/index.d.ts +2 -1
- package/dist/cjs/src/interfaces/index.js +1 -0
- package/dist/cjs/src/interfaces/index.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/adapters/hono-adapter.d.ts +2 -3
- package/dist/esm/src/adapters/hono-adapter.js +15 -1
- package/dist/esm/src/adapters/hono-adapter.js.map +1 -1
- package/dist/esm/src/interfaces/hono.d.ts +4 -0
- package/dist/esm/src/interfaces/hono.interface.d.ts +4 -0
- package/dist/esm/src/interfaces/hono.interface.js +2 -0
- package/dist/esm/src/interfaces/hono.interface.js.map +1 -0
- package/dist/esm/src/interfaces/hono.js +2 -0
- package/dist/esm/src/interfaces/hono.js.map +1 -0
- package/dist/esm/src/interfaces/index.d.ts +2 -1
- package/dist/esm/src/interfaces/index.js +2 -1
- package/dist/esm/src/interfaces/index.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/adapters/hono-adapter.ts +16 -4
- package/src/interfaces/hono.interface.ts +5 -0
- package/src/interfaces/index.ts +2 -1
package/package.json
CHANGED
|
@@ -14,14 +14,13 @@ import {
|
|
|
14
14
|
serveStatic,
|
|
15
15
|
} from "@hono/node-server/serve-static";
|
|
16
16
|
import { AbstractHttpAdapter } from "@nestjs/core/adapters/http-adapter";
|
|
17
|
-
import { Context,
|
|
18
|
-
import { Hono } from "hono";
|
|
17
|
+
import { Context, Next, Hono } from "hono";
|
|
19
18
|
import { cors } from "hono/cors";
|
|
20
19
|
import { RedirectStatusCode, StatusCode } from "hono/utils/http-status";
|
|
21
20
|
import * as http from "http";
|
|
22
21
|
import { Http2SecureServer, Http2Server } from "http2";
|
|
23
22
|
import * as https from "https";
|
|
24
|
-
import { TypeBodyParser } from "../interfaces";
|
|
23
|
+
import { HonoRequest, TypeBodyParser } from "../interfaces";
|
|
25
24
|
|
|
26
25
|
type HonoHandler = RequestHandler<HonoRequest, Context>;
|
|
27
26
|
|
|
@@ -239,7 +238,16 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
239
238
|
}
|
|
240
239
|
break;
|
|
241
240
|
default:
|
|
242
|
-
|
|
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
|
+
}
|
|
243
251
|
break;
|
|
244
252
|
}
|
|
245
253
|
await next();
|
|
@@ -255,6 +263,10 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
255
263
|
}
|
|
256
264
|
|
|
257
265
|
public initHttpServer(options: NestApplicationOptions) {
|
|
266
|
+
this.instance.use((ctx, next) => {
|
|
267
|
+
ctx.req["headers"] = Object.fromEntries(ctx.req.raw.headers);
|
|
268
|
+
return next();
|
|
269
|
+
});
|
|
258
270
|
const isHttpsEnabled = options?.httpsOptions;
|
|
259
271
|
const createServer = isHttpsEnabled
|
|
260
272
|
? https.createServer
|
package/src/interfaces/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./nest-hono-application.interface";
|
|
2
|
+
export * from "./hono.interface";
|