This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@@ -23,7 +23,7 @@ import config from '@/config';
const app = new Koa();
app.use(cors({
origin: '*'
origin: '*',
}));
// No caching
@@ -34,7 +34,7 @@ app.use(async (ctx, next) => {
app.use(bodyParser({
// リクエストが multipart/form-data でない限りはJSONだと見なす
detectJSON: ctx => !ctx.is('multipart/form-data')
detectJSON: ctx => !ctx.is('multipart/form-data'),
}));
// Init multer instance
@@ -43,7 +43,7 @@ const upload = multer({
limits: {
fileSize: config.maxFileSize || 262144000,
files: 1,
}
},
});
// Init router
@@ -74,7 +74,7 @@ router.use(twitter.routes());
router.get('/v1/instance/peers', async ctx => {
const instances = await Instances.find({
select: ['host']
select: ['host'],
});
ctx.body = instances.map(instance => instance.host);
@@ -82,18 +82,18 @@ router.get('/v1/instance/peers', async ctx => {
router.post('/miauth/:session/check', async ctx => {
const token = await AccessTokens.findOne({
session: ctx.params.session
session: ctx.params.session,
});
if (token && token.session != null && !token.fetched) {
AccessTokens.update(token.id, {
fetched: true
fetched: true,
});
ctx.body = {
ok: true,
token: token.token,
user: await Users.pack(token.userId, null, { detail: true })
user: await Users.pack(token.userId, null, { detail: true }),
};
} else {
ctx.body = {