mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
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 server’s 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,
|
||
});
|
||
},
|
||
),
|
||
);
|