mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): ♻️ More OpenAPI refactoring work
This commit is contained in:
parent
6d9e385a04
commit
5aa1c4e625
35 changed files with 4883 additions and 1815 deletions
|
|
@ -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;
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue