-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
54 lines (48 loc) · 2.11 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { flashMiddleware, IS_LOCAL_DEV, Server } from "$server";
import account from "./handlers/account.tsx";
import credCreatOpt from "./handlers/auth/cred_creation_options.ts";
import credCreatVer from "./handlers/auth/cred_creation_verify.ts";
import credReqOpt from "./handlers/auth/cred_request_options.ts";
import credReqVer from "./handlers/auth/cred_request_verify.ts";
import logout from "./handlers/auth/logout.ts";
import passkeyDelete from "./handlers/auth/passkey_delete.ts";
import passkeyRename from "./handlers/auth/passkey_rename.ts";
import spaceChat from "./handlers/chat/space_chat.ts";
import toggleChatDisabled from "./handlers/chat/toggle_chat_disabled.ts";
import home from "./handlers/home.tsx";
import notFound from "./handlers/not_found.tsx";
import checkSpaceName from "./handlers/spaces/check_name_available.ts";
import createSpace from "./handlers/spaces/create_space.ts";
import deleteSpace from "./handlers/spaces/delete_space.ts";
import showSpace from "./handlers/spaces/show_space.tsx";
import { errorMiddleware } from "./middleware/server_error.tsx";
import { sessionMiddleware } from "./middleware/session.ts";
const app = new Server();
app.use(errorMiddleware);
app.use(sessionMiddleware);
app.use(flashMiddleware);
app.get("/", home);
app.post("/logout", logout);
app.post("/spaces", createSpace);
app.post("/spaces/delete", deleteSpace);
app.post("/spaces/check-name-available", checkSpaceName);
app.get("/chat/space/:spaceId", spaceChat);
app.post("/chat/toggle-disabled", toggleChatDisabled);
app.get("/account", account);
app.get("/:spaceName", showSpace);
app.post("/auth/cred-creation-options", credCreatOpt);
app.post("/auth/cred-creation-verify", credCreatVer);
app.post("/auth/cred-request-options", credReqOpt);
app.post("/auth/cred-request-verify", credReqVer);
app.post("/auth/passkey-delete", passkeyDelete);
app.post("/auth/passkey-rename", passkeyRename);
app.all("*", notFound);
let serverOpt;
if (IS_LOCAL_DEV) {
serverOpt = {
cert: await Deno.readTextFile("cert/hotspace.local.crt"),
key: await Deno.readTextFile("cert/hotspace.local.key"),
port: 443,
};
}
app.serve(serverOpt);