forked from TheUnblockedHubOfficial/UBH-V1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
121 lines (95 loc) · 2.93 KB
/
index.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import express from "express";
import http from "node:http";
import createBareServer from "@tomphttp/bare-server-node";
import path from "node:path";
import * as dotenv from "dotenv";
dotenv.config();
const __dirname = process.cwd();
const server = http.createServer();
const app = express(server);
const bareServer = createBareServer("/bare/");
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
})
);
app.use(express.static(path.join(__dirname, "static")));
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "static", "index.html"));
});
app.get("/forest", (req, res) => {
res.sendFile(path.join(__dirname, "static", "forest.html"));
});
app.get("/photography", (req, res) => {
res.sendFile(path.join(__dirname, "static", "photography.html"));
});
app.get("/nature", (req, res) => {
res.sendFile(path.join(__dirname, "static", "play.html"));
});
app.get("/v2", (req, res) => {
res.sendFile(path.join(__dirname, "static", "v2transition.html"));
});
app.get("/go", (req, res) => {
res.sendFile(path.join(__dirname, "static", "go.html"));
});
app.get("/settings", (req, res) => {
res.sendFile(path.join(__dirname, "static", "settings.html"));
});
app.get("/ocean", (req, res) => {
res.sendFile(path.join(__dirname, "static", "ocean.html"));
});
app.get("/404", (req, res) => {
res.sendFile(path.join(__dirname, "static", "404.html"));
});
app.get("/*", (req, res) => {
res.redirect("/404");
});
app.get("/beta/", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "index.html"));
});
app.get("/beta/404", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "404.html"));
});
app.get("/beta/apps", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "apps.html"));
});
app.get("/beta/gs", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "gs.html"));
});
app.get("/beta/lgo", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "load.html"));
});
app.get("/beta/loading", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "fullscreen.html"));
});
app.get("/beta/search", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "search.html"));
});
app.get("/beta/settings", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "settings.html"));
});
app.get("/beta/utilities", (req, res) => {
res.sendFile(path.join(__dirname, "static", "beta", "utils.html"));
});
// Bare Server
server.on("request", (req, res) => {
if (bareServer.shouldRoute(req)) {
bareServer.routeRequest(req, res);
} else {
app(req, res);
}
});
server.on("upgrade", (req, socket, head) => {
if (bareServer.shouldRoute(req)) {
bareServer.routeUpgrade(req, socket, head);
} else {
socket.end();
}
});
server.on("listening", () => {
console.log(`The Unblocked Hub running at http://localhost:${process.env.PORT}`);
});
server.listen({
port: process.env.PORT,
});