diff --git a/packages/backend/src/server/api/compatibility.ts b/packages/backend/src/server/api/compatibility.ts index 7e44fa8b2e..42be40e104 100644 --- a/packages/backend/src/server/api/compatibility.ts +++ b/packages/backend/src/server/api/compatibility.ts @@ -1,11 +1,13 @@ import type { IEndpoint } from "./endpoints"; -import * as cp___instanceInfo from "./endpoints/compatibility/instance-info.js"; -import * as cp___customEmojis from "./endpoints/compatibility/custom-emojis.js"; +import * as cp___instance_info from "./endpoints/compatibility/instance-info.js"; +import * as cp___custom_emojis from "./endpoints/compatibility/custom-emojis.js"; +import * as ep___instance_peers from "./endpoints/compatibility/peers.js"; const cps = [ - ["v1/instance", cp___instanceInfo], - ["v1/custom_emojis", cp___customEmojis], + ["v1/instance", cp___instance_info], + ["v1/custom_emojis", cp___custom_emojis], + ["v1/instance/peers", ep___instance_peers], ]; const compatibility: IEndpoint[] = cps.map(([name, cp]) => { diff --git a/packages/backend/src/server/api/endpoints/compatibility/peers.ts b/packages/backend/src/server/api/endpoints/compatibility/peers.ts new file mode 100644 index 0000000000..30f6e0e937 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/compatibility/peers.ts @@ -0,0 +1,25 @@ +import { Instances } from "@/models/index.js"; +import define from "../../define.js"; + +export const meta = { + tags: ["meta"], + requireCredential: false, + requireCredentialPrivateMode: true, + allowGet: true, + cacheSec: 60, +} as const; + +export const paramDef = { + type: "object", +} as const; + +export default define(meta, paramDef, async (ps) => { + const instances = await Instances.find({ + select: ["host"], + where: { + isSuspended: false, + }, + }); + + return instances.map((instance) => instance.host); +}); diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index 3568a27b25..29cfbf93c0 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -87,7 +87,7 @@ mastoFileRouter.post("/v1/media", upload.single("file"), async (ctx) => { const accessTokens = ctx.headers.authorization; const client = getClient(BASE_URL, accessTokens); try { - let multipartData = await ctx.file; + const multipartData = await ctx.file; if (!multipartData) { ctx.body = { error: "No image" }; ctx.status = 401; @@ -106,7 +106,7 @@ mastoFileRouter.post("/v2/media", upload.single("file"), async (ctx) => { const accessTokens = ctx.headers.authorization; const client = getClient(BASE_URL, accessTokens); try { - let multipartData = await ctx.file; + const multipartData = await ctx.file; if (!multipartData) { ctx.body = { error: "No image" }; ctx.status = 401; @@ -185,17 +185,6 @@ router.use(discord.routes()); router.use(github.routes()); router.use(twitter.routes()); -router.get("/v1/instance/peers", async (ctx) => { - const instances = await Instances.find({ - select: ["host"], - where: { - isSuspended: false, - }, - }); - - ctx.body = instances.map((instance) => instance.host); -}); - router.post("/miauth/:session/check", async (ctx) => { const token = await AccessTokens.findOneBy({ session: ctx.params.session,