die が 400 以外も返せるように
This commit is contained in:
parent
a51947df76
commit
78476dbad9
2 changed files with 4 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { Context } from 'koa';
|
import { Context } from 'koa';
|
||||||
|
|
||||||
export const die = (ctx: Context, error: string): Promise<void> => {
|
export const die = (ctx: Context, error: string, status = 400): Promise<void> => {
|
||||||
ctx.status = 400;
|
ctx.status = status;
|
||||||
return ctx.render('error', { error });
|
return ctx.render('error', { error });
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { v4 as uuid } from 'uuid';
|
||||||
import { config } from './config';
|
import { config } from './config';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { upsertUser, getUser, getUserCount, updateUser } from './users';
|
import { upsertUser, getUser, getUserCount, updateUser } from './users';
|
||||||
|
import { api } from './misskey';
|
||||||
|
|
||||||
export const router = new Router<DefaultState, Context>();
|
export const router = new Router<DefaultState, Context>();
|
||||||
|
|
||||||
|
@ -98,6 +99,5 @@ router.get('/legacy-auth', async ctx => {
|
||||||
|
|
||||||
// Return 404 for other pages
|
// Return 404 for other pages
|
||||||
router.all('(.*)', async ctx => {
|
router.all('(.*)', async ctx => {
|
||||||
ctx.status = 404;
|
await die(ctx, 'ページが見つかりませんでした', 404);
|
||||||
await die(ctx, 'ページが見つかりませんでした');
|
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue