mirror of
https://github.com/outline/outline.git
synced 2026-12-06 11:12:32 +03:00
Move static assets, shares, embeds and the app catch-all into their own routers, and extract workspace redirect and render option logic so the index file only composes middleware in order.
30 lines
710 B
TypeScript
30 lines
710 B
TypeScript
import Koa from "koa";
|
|
import env from "@server/env";
|
|
import apexRedirect from "@server/middlewares/apexRedirect";
|
|
import appHeaders from "@server/middlewares/appHeaders";
|
|
import app from "./app";
|
|
import assets from "./assets";
|
|
import discovery from "./discovery";
|
|
import embeds from "./embeds";
|
|
import errors from "./errors";
|
|
import shares from "./shares";
|
|
|
|
const koa = new Koa();
|
|
|
|
koa.use(appHeaders());
|
|
koa.use(apexRedirect());
|
|
|
|
if (env.ENVIRONMENT === "test") {
|
|
koa.use(errors.routes());
|
|
}
|
|
|
|
koa.use(assets.routes());
|
|
koa.use(discovery.routes());
|
|
koa.use(embeds.routes());
|
|
koa.use(shares.routes());
|
|
|
|
// The app router has a catch-all route, so it must be last.
|
|
koa.use(app.routes());
|
|
|
|
export default koa;
|