Page MenuHomeSealhub

No OneTemporary

diff --git a/src/back/routes/index.ts b/src/back/routes/index.ts
index 8551b1a..17bfe95 100644
--- a/src/back/routes/index.ts
+++ b/src/back/routes/index.ts
@@ -1,14 +1,28 @@
-import Router from "@koa/router";
+import type Router from "@koa/router";
+import type { default as Koa } from "koa";
+import mount from "koa-mount";
+import Static from "koa-static";
import { Middlewares } from "sealious";
-import { MainView } from "./common/main-view.js";
+import type TheApp from "../app.js";
+import { imageRouter, RESPONSIVE_IMAGES_URL_PATH } from "../image-router.js";
import mountAutoRoutes from "./routes.js";
+import _locreq from "locreq";
+const locreq = _locreq(new URL("./", import.meta.url).pathname);
-export const mainRouter = (router: Router): void => {
- router.get("/", Middlewares.extractContext(), async (ctx) => {
- ctx.body = MainView(ctx);
- });
+export const mainRouter = (app: TheApp, koa_app: Koa, router: Router): void => {
+ const started_at = Date.now(); // necessary to detect aplication restarts
+
+ koa_app.use(mount("/", Static(locreq.resolve("public"))));
+ koa_app.use(Middlewares.extractContext());
+ app.initRouter(router);
+ koa_app.use(router.routes());
router.use(Middlewares.extractContext());
+ router.get("/status.json", Middlewares.extractContext(), async (ctx) => {
+ ctx.body = { status: ctx.$app.status, started_at };
+ });
+
+ router.use(RESPONSIVE_IMAGES_URL_PATH, imageRouter.getRoutes());
mountAutoRoutes(router);
};

File Metadata

Mime Type
text/x-diff
Expires
Sat, Oct 11, 08:33 (14 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
982004
Default Alt Text
(1 KB)

Event Timeline