diff --git a/app.ts b/app.ts index 667fd9a1..3bef1c7a 100644 --- a/app.ts +++ b/app.ts @@ -5,6 +5,7 @@ import { secureHeaders } from "@hono/hono/secure-headers"; import { OpenAPIHono } from "@hono/zod-openapi"; /* import { prometheus } from "@hono/prometheus"; */ import { getLogger } from "@logtape/logtape"; +import pkg from "~/package.json" with { type: "application/json" }; import { config } from "~/packages/config-manager/index"; import { agentBans } from "./middlewares/agent-bans"; import { bait } from "./middlewares/bait"; @@ -12,6 +13,7 @@ import { boundaryCheck } from "./middlewares/boundary-check"; import { ipBans } from "./middlewares/ip-bans"; import { logger } from "./middlewares/logger"; import { routes } from "./routes"; +import { swaggerUI } from "@hono/swagger-ui"; import type { ApiRouteExports, HonoEnv } from "./types/api"; export const appFactory = async () => { @@ -96,6 +98,32 @@ export const appFactory = async () => { route.default(app); } + app.doc31("/openapi.json", { + openapi: "3.1.0", + info: { + title: "Versia Server API", + version: pkg.version, + license: { + name: "AGPL-3.0", + url: "https://www.gnu.org/licenses/agpl-3.0.html", + }, + contact: pkg.author, + }, + }); + app.doc("/openapi.3.0.0.json", { + openapi: "3.0.0", + info: { + title: "Versia Server API", + version: pkg.version, + license: { + name: "AGPL-3.0", + url: "https://www.gnu.org/licenses/agpl-3.0.html", + }, + contact: pkg.author, + }, + }); + app.get("/docs", swaggerUI({ url: "/openapi.json" })); + app.options("*", (context) => { return context.text("", 204); }); diff --git a/bun.lockb b/bun.lockb index c4db7f36..ca3fbb26 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index bb92b55d..ad4a2080 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "description": "A project to build a federated social network", "author": { "email": "contact@cpluspatch.com", - "name": "CPlusPatch", + "name": "Jesse Wierzbinski", "url": "https://cpluspatch.com" }, "bugs": { @@ -19,7 +19,7 @@ "maintainers": [ { "email": "contact@cpluspatch.com", - "name": "CPlusPatch", + "name": "Jesse Wierzbinski", "url": "https://cpluspatch.com" } ], @@ -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/swagger-ui": "^0.4.1", "@hono/zod-openapi": "^0.16.0", "@hono/zod-validator": "^0.2.2", "@inquirer/confirm": "^3.1.22",