mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 13:59:16 +01:00
refactor(api): ♻️ Move from @hono/zod-openapi to hono-openapi
hono-openapi is easier to work with and generates better OpenAPI definitions
This commit is contained in:
parent
0576aff972
commit
58342e86e1
240 changed files with 9494 additions and 9575 deletions
|
|
@ -1,37 +1,28 @@
|
|||
import { apiRoute } from "@/api";
|
||||
import { createRoute, z } from "@hono/zod-openapi";
|
||||
import { getLogger } from "@logtape/logtape";
|
||||
import chalk from "chalk";
|
||||
|
||||
const route = createRoute({
|
||||
method: "post",
|
||||
path: "/messaging",
|
||||
summary: "Endpoint for the Instance Messaging Versia Extension.",
|
||||
description: "https://versia.pub/extensions/instance-messaging.",
|
||||
tags: ["Federation"],
|
||||
request: {
|
||||
body: {
|
||||
content: {
|
||||
"text/plain": {
|
||||
schema: z.string(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
description: "Message saved",
|
||||
},
|
||||
},
|
||||
});
|
||||
import { describeRoute } from "hono-openapi";
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.openapi(route, async (context) => {
|
||||
const content = await context.req.text();
|
||||
app.post(
|
||||
"/messaging",
|
||||
describeRoute({
|
||||
summary: "Endpoint for the Instance Messaging Versia Extension.",
|
||||
description: "https://versia.pub/extensions/instance-messaging.",
|
||||
tags: ["Federation"],
|
||||
responses: {
|
||||
200: {
|
||||
description: "Message saved",
|
||||
},
|
||||
},
|
||||
}),
|
||||
async (context) => {
|
||||
const content = await context.req.text();
|
||||
|
||||
getLogger(["federation", "messaging"])
|
||||
.info`Received message via ${chalk.bold("Instance Messaging")}:\n${content}`;
|
||||
getLogger(["federation", "messaging"])
|
||||
.info`Received message via ${chalk.bold("Instance Messaging")}:\n${content}`;
|
||||
|
||||
return context.text("", 200);
|
||||
}),
|
||||
return context.text("", 200);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue