/api/v1/instance/peers 復活 (#4339)

* /api/v1/instance/peers 復活

* use Instance
This commit is contained in:
MeiMei 2019-02-21 23:20:25 +09:00 committed by syuilo
parent 60da17940d
commit bae874eb45

View File

@ -15,6 +15,8 @@ import signin from './private/signin';
import discord from './service/discord'; import discord from './service/discord';
import github from './service/github'; import github from './service/github';
import twitter from './service/twitter'; import twitter from './service/twitter';
import Instance from '../../models/instance';
import { toASCII } from 'punycode';
// Init app // Init app
const app = new Koa(); const app = new Koa();
@ -60,6 +62,17 @@ router.use(discord.routes());
router.use(github.routes()); router.use(github.routes());
router.use(twitter.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 // Return 404 for unknown API
router.all('*', async ctx => { router.all('*', async ctx => {
ctx.status = 404; ctx.status = 404;