aboutsummaryrefslogtreecommitdiff
path: root/src/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.ts')
-rw-r--r--src/main.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/main.ts b/src/main.ts
index 1772e97..94f8b33 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -3,14 +3,11 @@ import { Application } from "https://deno.land/x/abc@master/mod.ts";
import type { Context } from "https://deno.land/x/abc@master/mod.ts";
import { renderFile } from "https://deno.land/x/dejs/mod.ts";
import * as groups from "./groups/index.ts";
+import { handlePath } from "./handler/fileView.ts";
import DBController from "./db/DBController.ts";
-let dbc: DBController;
// Ugly solution
-(async () => {
- dbc = new DBController();
- await dbc.init();
-})();
+(async () => await new DBController().init())();
const port = parseInt(Deno.env.get("PORT") || "8080");
const app = new Application();
@@ -21,8 +18,10 @@ app.renderer = {
},
};
-app.static("/", "./src/public/"); // Manage static files - TODO: Consider serving css/js files separately
-app.get("/", async (c: Context) => await c.render("./src/public/test.html", { name: "test" })); // Render index on /
+app.static("/public/", "./src/public/"); // Manage static files
+app.get("/", async (c: Context) => await c.render("./src/views/index.html")); // Render index on /
+
+app.get("/files/*", handlePath);
// Load groups dynamically
// deno-lint-ignore ban-ts-comment