@kiyasov/platform-hono 1.2.3 → 1.2.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/dist/cjs/src/adapters/hono-adapter.d.ts +2 -3
- package/dist/cjs/src/adapters/hono-adapter.js +12 -4
- 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 +12 -4
- 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 +14 -8
- 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
|
|
|
@@ -221,17 +220,20 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
221
220
|
this.instance.use(this.bodyLimit(bodyLimit), async (ctx, next) => {
|
|
222
221
|
const contentType = ctx.req.header("content-type");
|
|
223
222
|
|
|
224
|
-
if (rawBody) {
|
|
225
|
-
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
226
|
-
}
|
|
227
|
-
|
|
228
223
|
switch (type) {
|
|
229
224
|
case "application/json":
|
|
230
|
-
if (contentType?.startsWith("application/json"))
|
|
225
|
+
if (contentType?.startsWith("application/json")) {
|
|
226
|
+
if (rawBody) {
|
|
227
|
+
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
228
|
+
}
|
|
231
229
|
(ctx.req as any).body = await ctx.req.json();
|
|
230
|
+
}
|
|
232
231
|
break;
|
|
233
232
|
case "text/plain":
|
|
234
233
|
if (contentType?.startsWith("text/plain")) {
|
|
234
|
+
if (rawBody) {
|
|
235
|
+
(ctx.req as any).rawBody = Buffer.from(await ctx.req.text());
|
|
236
|
+
}
|
|
235
237
|
(ctx.req as any).body = await ctx.req.json();
|
|
236
238
|
}
|
|
237
239
|
break;
|
|
@@ -252,6 +254,10 @@ export class HonoAdapter extends AbstractHttpAdapter<
|
|
|
252
254
|
}
|
|
253
255
|
|
|
254
256
|
public initHttpServer(options: NestApplicationOptions) {
|
|
257
|
+
this.instance.use((ctx, next) => {
|
|
258
|
+
ctx.req["headers"] = Object.fromEntries(ctx.req.raw.headers);
|
|
259
|
+
return next();
|
|
260
|
+
});
|
|
255
261
|
const isHttpsEnabled = options?.httpsOptions;
|
|
256
262
|
const createServer = isHttpsEnabled
|
|
257
263
|
? 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";
|