i need to seperate 404 to own route
This commit is contained in:
parent
fcc59cd35f
commit
103d655ed4
|
@ -39,6 +39,7 @@ app.use(async (ctx, next) => {
|
||||||
// Init router
|
// Init router
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
const mastoRouter = new Router();
|
const mastoRouter = new Router();
|
||||||
|
const errorRouter = new Router();
|
||||||
|
|
||||||
// Init multer instance
|
// Init multer instance
|
||||||
const upload = multer({
|
const upload = multer({
|
||||||
|
@ -60,7 +61,10 @@ router.use(
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
mastoRouter.use(koaBody({ multipart: true }));
|
mastoRouter.use(koaBody({
|
||||||
|
multipart: true,
|
||||||
|
urlencoded: true
|
||||||
|
}));
|
||||||
|
|
||||||
apiMastodonCompatible(mastoRouter);
|
apiMastodonCompatible(mastoRouter);
|
||||||
|
|
||||||
|
@ -148,12 +152,13 @@ router.post("/miauth/:session/check", async (ctx) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return 404 for unknown API
|
// Return 404 for unknown API
|
||||||
router.all("(.*)", async (ctx) => {
|
errorRouter.all("(.*)", async (ctx) => {
|
||||||
ctx.status = 404;
|
ctx.status = 404;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register router
|
// Register router
|
||||||
app.use(router.routes());
|
|
||||||
app.use(mastoRouter.routes());
|
app.use(mastoRouter.routes());
|
||||||
|
app.use(router.routes());
|
||||||
|
app.use(errorRouter.routes());
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
@ -72,7 +72,10 @@ app.use(mount("/proxy", proxyServer));
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
const mastoRouter = new Router();
|
const mastoRouter = new Router();
|
||||||
|
|
||||||
mastoRouter.use(koaBody({ multipart: true }));
|
mastoRouter.use(koaBody({
|
||||||
|
multipart: true,
|
||||||
|
urlencoded: true
|
||||||
|
}));
|
||||||
|
|
||||||
// Routing
|
// Routing
|
||||||
router.use(activityPub.routes());
|
router.use(activityPub.routes());
|
||||||
|
@ -174,8 +177,8 @@ mastoRouter.post("/oauth/token", async (ctx) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register router
|
// Register router
|
||||||
app.use(router.routes());
|
|
||||||
app.use(mastoRouter.routes());
|
app.use(mastoRouter.routes());
|
||||||
|
app.use(router.routes());
|
||||||
|
|
||||||
app.use(mount(webServer));
|
app.use(mount(webServer));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue