diff --git a/app.ts b/app.ts index aa23623e..54104069 100644 --- a/app.ts +++ b/app.ts @@ -1,8 +1,8 @@ import { sentry } from "@/sentry"; -import { Hono } from "@hono/hono"; import { cors } from "@hono/hono/cors"; import { prettyJSON } from "@hono/hono/pretty-json"; import { secureHeaders } from "@hono/hono/secure-headers"; +import { OpenAPIHono } from "@hono/zod-openapi"; /* import { prometheus } from "@hono/prometheus"; */ import { getLogger } from "@logtape/logtape"; import { config } from "~/packages/config-manager/index"; @@ -18,7 +18,7 @@ import type { ApiRouteExports } from "./types/api"; export const appFactory = async () => { const serverLogger = getLogger("server"); - const app = new Hono({ + const app = new OpenAPIHono({ strict: false, }); diff --git a/bun.lockb b/bun.lockb index 8cc4d7ce..c4db7f36 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index b66cc473..7ae47eb9 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,7 @@ "@hackmd/markdown-it-task-lists": "^2.1.4", "@hono/hono": "npm:@jsr/hono__hono@4.5.9", "@hono/prometheus": "^1.0.1", + "@hono/zod-openapi": "^0.16.0", "@hono/zod-validator": "^0.2.2", "@inquirer/confirm": "^3.1.22", "@inquirer/input": "^2.2.9", diff --git a/types/api.ts b/types/api.ts index 75e023c3..04e49db2 100644 --- a/types/api.ts +++ b/types/api.ts @@ -1,5 +1,5 @@ -import type { Hono } from "@hono/hono"; import type { RouterRoute } from "@hono/hono/types"; +import type { OpenAPIHono } from "@hono/zod-openapi"; import type { Delete, Follow, @@ -49,7 +49,7 @@ export interface ApiRouteExports { query?: z.AnyZodObject; body?: z.AnyZodObject; }; - default: (app: Hono) => RouterRoute; + default: (app: OpenAPIHono) => RouterRoute; } export type KnownEntity = diff --git a/utils/api.ts b/utils/api.ts index a8ac6326..0823603d 100644 --- a/utils/api.ts +++ b/utils/api.ts @@ -1,6 +1,7 @@ -import type { Context, Hono } from "@hono/hono"; +import type { Context } from "@hono/hono"; import { createMiddleware } from "@hono/hono/factory"; import { validator } from "@hono/hono/validator"; +import type { OpenAPIHono } from "@hono/zod-openapi"; import { getLogger } from "@logtape/logtape"; import { extractParams, verifySolution } from "altcha-lib"; import chalk from "chalk"; @@ -46,7 +47,7 @@ export const applyConfig = (routeMeta: ApiRouteMetadata) => { export const apiRoute = ( fn: ( - app: Hono /* <{ + app: OpenAPIHono /* <{ Bindings: {}; }> */, ) => void, diff --git a/utils/server.ts b/utils/server.ts index 963391f0..c6de74c2 100644 --- a/utils/server.ts +++ b/utils/server.ts @@ -1,7 +1,7 @@ -import type { Hono } from "@hono/hono"; +import type { OpenAPIHono } from "@hono/zod-openapi"; import type { Config } from "~/packages/config-manager/config.type"; -export const createServer = (config: Config, app: Hono) => +export const createServer = (config: Config, app: OpenAPIHono) => Bun.serve({ port: config.http.bind_port, reusePort: true,