mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-15 09:15:44 +01:00
/api/v1/instance/peers 復活 (#4339)
* /api/v1/instance/peers 復活 * use Instance
This commit is contained in:
parent
60da17940d
commit
bae874eb45
1 changed files with 13 additions and 0 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue