mirror of
https://github.com/versia-pub/server.git
synced 2025-12-07 00:48:18 +01:00
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { apiRoute, auth } from "@/api";
|
|
import { createRoute, z } from "@hono/zod-openapi";
|
|
import { Rule as RuleSchema } from "~/classes/schemas/rule";
|
|
import { config } from "~/config.ts";
|
|
|
|
const route = createRoute({
|
|
method: "get",
|
|
path: "/api/v1/instance/rules",
|
|
summary: "List of rules",
|
|
description: "Rules that the users of this service should follow.",
|
|
externalDocs: {
|
|
url: "https://docs.joinmastodon.org/methods/instance/#rules",
|
|
},
|
|
tags: ["Instance"],
|
|
middleware: [
|
|
auth({
|
|
auth: false,
|
|
}),
|
|
],
|
|
responses: {
|
|
200: {
|
|
description: "Instance rules",
|
|
content: {
|
|
"application/json": {
|
|
schema: z.array(RuleSchema),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
export default apiRoute((app) =>
|
|
app.openapi(route, (context) => {
|
|
return context.json(
|
|
config.instance.rules.map((r, index) => ({
|
|
id: String(index),
|
|
text: r.text,
|
|
hint: r.hint,
|
|
})),
|
|
);
|
|
}),
|
|
);
|