diff --git a/src/server/api/index.ts b/src/server/api/index.ts index 711e0791e7..6c523a9d49 100644 --- a/src/server/api/index.ts +++ b/src/server/api/index.ts @@ -15,6 +15,8 @@ import signin from './private/signin'; import discord from './service/discord'; import github from './service/github'; import twitter from './service/twitter'; +import Instance from '../../models/instance'; +import { toASCII } from 'punycode'; // Init app const app = new Koa(); @@ -60,6 +62,17 @@ router.use(discord.routes()); router.use(github.routes()); router.use(twitter.routes()); +router.get('/v1/instance/peers', async ctx => { + const instances = await Instance.find({ + }, { + host: 1 + }); + + const punyCodes = instances.map(instance => toASCII(instance.host)); + + ctx.body = punyCodes; +}); + // Return 404 for unknown API router.all('*', async ctx => { ctx.status = 404;