i need to seperate 404 to own route

This commit is contained in:
cutestnekoaqua 2023-02-11 00:51:45 +01:00
parent fcc59cd35f
commit 103d655ed4
No known key found for this signature in database
GPG Key ID: 6BF0964A5069C1E0
2 changed files with 13 additions and 5 deletions

View File

@ -39,6 +39,7 @@ app.use(async (ctx, next) => {
// Init router
const router = new Router();
const mastoRouter = new Router();
const errorRouter = new Router();
// Init multer instance
const upload = multer({
@ -60,7 +61,10 @@ router.use(
}),
);
mastoRouter.use(koaBody({ multipart: true }));
mastoRouter.use(koaBody({
multipart: true,
urlencoded: true
}));
apiMastodonCompatible(mastoRouter);
@ -148,12 +152,13 @@ router.post("/miauth/:session/check", async (ctx) => {
});
// Return 404 for unknown API
router.all("(.*)", async (ctx) => {
errorRouter.all("(.*)", async (ctx) => {
ctx.status = 404;
});
// Register router
app.use(router.routes());
app.use(mastoRouter.routes());
app.use(router.routes());
app.use(errorRouter.routes());
export default app;

View File

@ -72,7 +72,10 @@ app.use(mount("/proxy", proxyServer));
const router = new Router();
const mastoRouter = new Router();
mastoRouter.use(koaBody({ multipart: true }));
mastoRouter.use(koaBody({
multipart: true,
urlencoded: true
}));
// Routing
router.use(activityPub.routes());
@ -174,8 +177,8 @@ mastoRouter.post("/oauth/token", async (ctx) => {
});
// Register router
app.use(router.routes());
app.use(mastoRouter.routes());
app.use(router.routes());
app.use(mount(webServer));