refactor(api): ♻️ More OpenAPI refactoring work

This commit is contained in:
Jesse Wierzbinski 2024-09-16 15:29:09 +02:00
parent 6d9e385a04
commit 5aa1c4e625
No known key found for this signature in database
35 changed files with 4883 additions and 1815 deletions

View file

@ -1,4 +1,5 @@
import { apiRoute, applyConfig } from "@/api";
import { createRoute, z } from "@hono/zod-openapi";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({
@ -13,14 +14,34 @@ export const meta = applyConfig({
route: "/.well-known/host-meta",
});
const route = createRoute({
method: "get",
path: "/.well-known/host-meta",
summary: "Well-known host-meta",
responses: {
200: {
description: "Host-meta",
content: {
"application/xrd+xml": {
schema: z.any(),
},
},
},
},
});
export default apiRoute((app) =>
app.on(meta.allowedMethods, meta.route, (context) => {
app.openapi(route, (context) => {
context.header("Content-Type", "application/xrd+xml");
context.status(200);
return context.body(
`<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" template="${new URL(
"/.well-known/webfinger",
config.http.base_url,
).toString()}?resource={uri}"/></XRD>`,
);
200,
// biome-ignore lint/suspicious/noExplicitAny: Hono doesn't type this response so this has a TS error, it's joever
) as any;
}),
);