0
0
Fork 0

die が 400 以外も返せるように

This commit is contained in:
Xeltica 2020-08-04 20:11:39 +09:00
parent a51947df76
commit 78476dbad9
2 changed files with 4 additions and 4 deletions

View file

@ -1,6 +1,6 @@
import { Context } from 'koa';
export const die = (ctx: Context, error: string): Promise<void> => {
ctx.status = 400;
export const die = (ctx: Context, error: string, status = 400): Promise<void> => {
ctx.status = status;
return ctx.render('error', { error });
};

View file

@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
import { config } from './config';
import axios from 'axios';
import { upsertUser, getUser, getUserCount, updateUser } from './users';
import { api } from './misskey';
export const router = new Router<DefaultState, Context>();
@ -98,6 +99,5 @@ router.get('/legacy-auth', async ctx => {
// Return 404 for other pages
router.all('(.*)', async ctx => {
ctx.status = 404;
await die(ctx, 'ページが見つかりませんでした');
await die(ctx, 'ページが見つかりませんでした', 404);
});