mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): ♻️ Move from @hono/zod-openapi to hono-openapi
hono-openapi is easier to work with and generates better OpenAPI definitions
This commit is contained in:
parent
0576aff972
commit
58342e86e1
240 changed files with 9494 additions and 9575 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { z } from "@hono/zod-openapi";
|
||||
import { z } from "zod";
|
||||
import { Hooks } from "./hooks.ts";
|
||||
import { Plugin } from "./plugin.ts";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import type { OpenAPIHono } from "@hono/zod-openapi";
|
||||
import type { MiddlewareHandler } from "hono";
|
||||
import type { Hono, MiddlewareHandler } from "hono";
|
||||
import { createMiddleware } from "hono/factory";
|
||||
import type { z } from "zod";
|
||||
import { type ZodError, fromZodError } from "zod-validation-error";
|
||||
|
|
@ -17,7 +16,7 @@ export class Plugin<ConfigSchema extends z.ZodTypeAny> {
|
|||
private store: z.infer<ConfigSchema> | null = null;
|
||||
private routes: {
|
||||
path: string;
|
||||
fn: (app: OpenAPIHono<HonoPluginEnv<ConfigSchema>>) => void;
|
||||
fn: (app: Hono<HonoPluginEnv<ConfigSchema>>) => void;
|
||||
}[] = [];
|
||||
|
||||
public constructor(private configSchema: ConfigSchema) {}
|
||||
|
|
@ -34,7 +33,7 @@ export class Plugin<ConfigSchema extends z.ZodTypeAny> {
|
|||
|
||||
public registerRoute(
|
||||
path: string,
|
||||
fn: (app: OpenAPIHono<HonoPluginEnv<ConfigSchema>>) => void,
|
||||
fn: (app: Hono<HonoPluginEnv<ConfigSchema>>) => void,
|
||||
): void {
|
||||
this.routes.push({
|
||||
path,
|
||||
|
|
@ -55,12 +54,10 @@ export class Plugin<ConfigSchema extends z.ZodTypeAny> {
|
|||
}
|
||||
}
|
||||
|
||||
protected _addToApp(app: OpenAPIHono<HonoEnv>): void {
|
||||
protected _addToApp(app: Hono<HonoEnv>): void {
|
||||
for (const route of this.routes) {
|
||||
app.use(route.path, this.middleware);
|
||||
route.fn(
|
||||
app as unknown as OpenAPIHono<HonoPluginEnv<ConfigSchema>>,
|
||||
);
|
||||
route.fn(app as unknown as Hono<HonoPluginEnv<ConfigSchema>>);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { z } from "@hono/zod-openapi";
|
||||
import { z } from "zod";
|
||||
|
||||
export const manifestSchema = z.object({
|
||||
// biome-ignore lint/style/useNamingConvention: <explanation>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue