import { OpenAPIHono } from "@hono/zod-openapi"; import { swaggerUI } from "@hono/swagger-ui"; import { handleError } from "./api-error"; import { env } from "~/env"; export function getApp() { const app = new OpenAPIHono().basePath("/api"); app.onError(handleError); // The OpenAPI documentation will be available at /doc app.doc("/v1/doc", (c) => ({ openapi: "3.0.0", info: { version: "1.0.0", title: "Unsend API", }, servers: [{ url: `${env.NEXTAUTH_URL}/api` }], })); app.openAPIRegistry.registerComponent("securitySchemes", "Bearer", { type: "http", scheme: "bearer", }); app.get("/v1/ui", swaggerUI({ url: "/api/v1/doc" })); return app; } export type PublicAPIApp = ReturnType;