server/api/well-known/nodeinfo/index.ts
Jesse Wierzbinski 58342e86e1
refactor(api): ♻️ Move from @hono/zod-openapi to hono-openapi
hono-openapi is easier to work with and generates better OpenAPI definitions
2025-03-29 03:30:06 +01:00

48 lines
1.5 KiB
TypeScript

import { apiRoute } from "@/api";
import { describeRoute } from "hono-openapi";
import { resolver } from "hono-openapi/zod";
import { z } from "zod";
import { config } from "~/config.ts";
export default apiRoute((app) =>
app.get(
"/.well-known/nodeinfo",
describeRoute({
summary: "Well-known nodeinfo",
tags: ["Federation"],
responses: {
200: {
description: "Nodeinfo links",
content: {
"application/json": {
schema: resolver(
z.object({
links: z.array(
z.object({
rel: z.string(),
href: z.string(),
}),
),
}),
),
},
},
},
},
}),
(context) => {
return context.json({
links: [
{
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
href: new URL(
"/.well-known/nodeinfo/2.0",
config.http.base_url,
).toString(),
},
],
});
},
),
);