forked from DogeNetwork/v4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
78 lines (71 loc) · 2.09 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
import express from "express";
import http from "node:http";
import path from "node:path";
import { createBareServer } from "@tomphttp/bare-server-node";
import request from "@cypress/request";
const __dirname = path.resolve();
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('/app', (req, res) => {
res.sendFile(path.join(__dirname, './static/index.html'));
});
app.get('/student', (req, res) => {
res.sendFile(path.join(__dirname, './static/loader.html'));
});
app.get('/apps', (req, res) => {
res.sendFile(path.join(__dirname, './static/apps.html'));
});
app.get('/gms', (req, res) => {
res.sendFile(path.join(__dirname, './static/gms.html'));
});
app.get('/lessons', (req, res) => {
res.sendFile(path.join(__dirname, './static/agloader.html'));
});
app.get('/credits', (req, res) => {
res.sendFile(path.join(__dirname, './static/credits.html'));
});
app.get('/partners', (req, res) => {
res.sendFile(path.join(__dirname, './static/partners.html'));
});
app.get("/worker.js", (req, res) => {
request("https://cdn.surfdoge.pro/worker.js", (error, response, body) => {
if (!error && response.statusCode === 200) {
res.setHeader("Content-Type", "text/javascript");
res.send(body);
} else {
res.status(500).send("Error fetching worker script");
}
});
});
app.use((req, res) => {
res.statusCode = 404;
res.sendFile(path.join(__dirname, './static/404.html'))
});
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(`Doge Unblocker @ Port 8000`);
});
server.listen({
port: 8000,
});