Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9583036
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
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
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 11, 08:33 (1 d, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
982004
Default Alt Text
(1 KB)
Attached To
Mode
rMIN sealious-minimal
Attached
Detach File
Event Timeline
Log In to Comment