-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
74 lines (67 loc) · 3.03 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { flashMiddleware, IS_LOCAL_DEV, Server } from "$server";
import { uploadWorkerHandler } from "$upload";
import account from "./handlers/account/account.tsx";
import logout from "./handlers/account/logout.ts";
import register from "./handlers/account/register.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 passkeyDelete from "./handlers/auth/passkey_delete.ts";
import passkeyRename from "./handlers/auth/passkey_rename.ts";
import chatConnection from "./handlers/chat/connection.ts";
import chatLazyLoad from "./handlers/chat/lazy_load.tsx";
import chatSubs from "./handlers/chat/subs.ts";
import home from "./handlers/home.tsx";
import createDir from "./handlers/inodes/create_dir.ts";
import showDir from "./handlers/inodes/show-dir.tsx";
import showFile from "./handlers/inodes/show-file.tsx";
import toggleChat from "./handlers/inodes/toggle_chat.ts";
import completeUpload from "./handlers/inodes/upload/complete.tsx";
import initiateUpload from "./handlers/inodes/upload/initiate.tsx";
import subscribers from "./handlers/push_sub/subscribers.ts";
import vapid from "./handlers/push_sub/vapid.ts";
import { headersMiddleware } from "./middleware/headers.ts";
import { errorMiddleware } from "./middleware/server_error.tsx";
import { sessionMiddleware } from "./middleware/session.ts";
import { stateMiddleware } from "./middleware/state.ts";
import { kv } from "./util/kv/kv.ts";
import { queueHandler } from "./util/kv/queue_handlers/main_handler.ts";
const app = new Server({ trailingSlash: "mixed" });
app.use(errorMiddleware);
app.use(headersMiddleware);
app.use(sessionMiddleware);
app.use(stateMiddleware);
app.use(flashMiddleware);
app.get("/", home);
app.get("/register", register);
app.post("/logout", logout);
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.get("/account", account);
app.post("/account/passkeys/delete", passkeyDelete);
app.post("/account/passkeys/rename", passkeyRename);
app.post("/inodes/dirs", createDir);
app.post("/inodes/toggle_chat", toggleChat);
app.post("/inodes/upload/initiate", initiateUpload);
app.post("/inodes/upload/complete", completeUpload);
app.get("/inodes/upload/worker.js", uploadWorkerHandler);
app.get("/chat/lazy-load/:chatId", chatLazyLoad);
app.get("/chat/connection/:chatId", chatConnection);
app.all("/chat/subs", chatSubs);
app.post("/push-subs/subscribers", subscribers);
app.get("/push-subs/vapid", vapid);
app.get("*/", showDir);
app.get("*", showFile);
let serveOptions;
if (IS_LOCAL_DEV) {
serveOptions = {
cert: await Deno.readTextFile("util/cert/hotspace.local.crt"),
key: await Deno.readTextFile("util/cert/hotspace.local.key"),
port: 443,
};
}
app.serve(serveOptions);
kv.listenQueue(queueHandler);