mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): ♻️ More OpenAPI refactoring work
This commit is contained in:
parent
6d9e385a04
commit
5aa1c4e625
35 changed files with 4883 additions and 1815 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { apiRoute, applyConfig } from "@/api";
|
||||
import { createRoute, z } from "@hono/zod-openapi";
|
||||
import manifest from "~/package.json";
|
||||
|
||||
export const meta = applyConfig({
|
||||
|
|
@ -13,8 +14,45 @@ export const meta = applyConfig({
|
|||
route: "/.well-known/nodeinfo/2.0",
|
||||
});
|
||||
|
||||
const route = createRoute({
|
||||
method: "get",
|
||||
path: "/.well-known/nodeinfo/2.0",
|
||||
summary: "Well-known nodeinfo 2.0",
|
||||
responses: {
|
||||
200: {
|
||||
description: "Nodeinfo 2.0",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: z.object({
|
||||
version: z.string(),
|
||||
software: z.object({
|
||||
name: z.string(),
|
||||
version: z.string(),
|
||||
}),
|
||||
protocols: z.array(z.string()),
|
||||
services: z.object({
|
||||
outbound: z.array(z.string()),
|
||||
inbound: z.array(z.string()),
|
||||
}),
|
||||
usage: z.object({
|
||||
users: z.object({
|
||||
total: z.number(),
|
||||
activeMonth: z.number(),
|
||||
activeHalfyear: z.number(),
|
||||
}),
|
||||
localPosts: z.number(),
|
||||
}),
|
||||
openRegistrations: z.boolean(),
|
||||
metadata: z.object({}),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.on(meta.allowedMethods, meta.route, (context) => {
|
||||
app.openapi(route, (context) => {
|
||||
return context.json({
|
||||
version: "2.0",
|
||||
software: { name: "versia-server", version: manifest.version },
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { apiRoute, applyConfig } from "@/api";
|
||||
import { createRoute } from "@hono/zod-openapi";
|
||||
import { config } from "~/packages/config-manager";
|
||||
|
||||
export const meta = applyConfig({
|
||||
|
|
@ -13,8 +14,19 @@ export const meta = applyConfig({
|
|||
route: "/.well-known/nodeinfo",
|
||||
});
|
||||
|
||||
const route = createRoute({
|
||||
method: "get",
|
||||
path: "/.well-known/nodeinfo",
|
||||
summary: "Well-known nodeinfo",
|
||||
responses: {
|
||||
301: {
|
||||
description: "Redirect to 2.0 Nodeinfo",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.on(meta.allowedMethods, meta.route, (context) => {
|
||||
app.openapi(route, (context) => {
|
||||
return context.redirect(
|
||||
new URL(
|
||||
"/.well-known/nodeinfo/2.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue