33 lines
1.2 KiB
TypeScript
Executable file
33 lines
1.2 KiB
TypeScript
Executable file
#!/bin/env -S deno run --allow-net --unstable-kv --watch --allow-read=./pages,./local,./lib,. --allow-write=./local
|
|
|
|
import { Hono } from "https://deno.land/x/hono@v4.3.10/mod.ts";
|
|
import { serveStatic } from "https://deno.land/x/hono@v4.3.10/middleware.ts";
|
|
import { CookieStore, Session, sessionMiddleware } from "https://deno.land/x/hono_sessions@v0.5.8/mod.ts";
|
|
|
|
export type FeurEnv = { Variables: { session: Session } };
|
|
const app = new Hono<FeurEnv>();
|
|
|
|
app.use("/static/*", serveStatic({ root: "./pages/" }));
|
|
|
|
const store = new CookieStore();
|
|
const encryptionKey = "FeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeurFeur";
|
|
app.use("*", sessionMiddleware({ store, encryptionKey }));
|
|
|
|
app.get("/", (c) => c.redirect("/home"));
|
|
|
|
import HomePage from "./pages/home.tsx";
|
|
app.get("/home", (c) => c.html(HomePage(c)));
|
|
|
|
import LoginPage from "./pages/login.tsx";
|
|
app.get("/login", (c) => c.html(LoginPage()));
|
|
|
|
import { login_route } from "./api/login.ts";
|
|
app.post("/api/login", (c) => login_route(c));
|
|
|
|
import { logout_route } from "./api/logout.ts";
|
|
app.get("/api/logout", (c) => logout_route(c));
|
|
|
|
import UserPage from "./pages/user.tsx";
|
|
app.get("/user", async (c) => await UserPage(c));
|
|
|
|
Deno.serve(app.fetch);
|