feur
This commit is contained in:
parent
8b6a86f17a
commit
3aea126342
14 changed files with 205 additions and 67 deletions
21
main.ts
21
main.ts
|
@ -1,17 +1,22 @@
|
|||
#!/bin/env -S deno run --allow-net --unstable-kv --watch --allow-read=./pages
|
||||
#!/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 { basicAuth, serveStatic } from "https://deno.land/x/hono@v4.3.10/middleware.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";
|
||||
|
||||
const app = new Hono();
|
||||
export type FeurEnv = { Variables: { session: Session } };
|
||||
const app = new Hono<FeurEnv>();
|
||||
|
||||
app.use("/static/*", serveStatic({ root: "./pages/" }));
|
||||
app.use("/user", basicAuth({ username: "feur", password: "feur" })); // todo : transition to verify_user
|
||||
|
||||
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()));
|
||||
app.get("/home", (c) => c.html(HomePage(c)));
|
||||
|
||||
import LoginPage from "./pages/login.tsx";
|
||||
app.get("/login", (c) => c.html(LoginPage()));
|
||||
|
@ -19,4 +24,10 @@ 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue