refactor(api): ♻️ Use OpenAPIHono instead of Hono in preparation for future changes

This commit is contained in:
Jesse Wierzbinski 2024-08-27 16:40:11 +02:00
parent 3c1b330d4b
commit df466ecaa0
No known key found for this signature in database
6 changed files with 10 additions and 8 deletions

4
app.ts
View file

@ -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,
});

BIN
bun.lockb

Binary file not shown.

View file

@ -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",

View file

@ -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 =

View file

@ -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,

View file

@ -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,