server/packages/api/routes/api/v1/instance/terms_of_service.ts
2025-06-15 23:43:27 +02:00

45 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { TermsOfService as TermsOfServiceSchema } from "@versia/client/schemas";
import { apiRoute } from "@versia/kit/api";
import { markdownToHtml } from "@versia/kit/markdown";
import { config } from "@versia-server/config";
import { describeRoute } from "hono-openapi";
import { resolver } from "hono-openapi/zod";
export default apiRoute((app) =>
app.get(
"/api/v1/instance/terms_of_service",
describeRoute({
summary: "View terms of service",
description:
"Obtain the contents of this servers terms of service, if configured.",
externalDocs: {
url: "https://docs.joinmastodon.org/methods/instance/#terms_of_service",
},
tags: ["Instance"],
responses: {
200: {
description: "Server terms of service",
content: {
"application/json": {
schema: resolver(TermsOfServiceSchema),
},
},
},
},
}),
async (context) => {
const content = await markdownToHtml(
config.instance.tos_path?.content ??
"This instance has not provided any terms of service.",
);
return context.json({
updated_at: new Date(
config.instance.tos_path?.file.lastModified ?? 0,
).toISOString(),
content,
});
},
),
);