From bae874eb4593e206c29d5bb6fae1eecb3ea35fb5 Mon Sep 17 00:00:00 2001
From: MeiMei <30769358+mei23@users.noreply.github.com>
Date: Thu, 21 Feb 2019 23:20:25 +0900
Subject: [PATCH] =?UTF-8?q?/api/v1/instance/peers=20=E5=BE=A9=E6=B4=BB=20(?=
 =?UTF-8?q?#4339)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* /api/v1/instance/peers 復活

* use Instance
---
 src/server/api/index.ts | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/server/api/index.ts b/src/server/api/index.ts
index 711e0791e..6c523a9d4 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;