|
1 | | -import { createBareServer } from "@tomphttp/bare-server-node"; |
2 | | -import express from "express"; |
3 | | -import cors from "cors"; |
4 | | -import http from "node:http"; |
5 | | -import path from "node:path"; |
6 | | -import { uvPath } from "@titaniumnetwork-dev/ultraviolet" |
| 1 | +import { createBareServer } from '@tomphttp/bare-server-node'; |
| 2 | +import express from 'express'; |
| 3 | +import cors from 'cors'; |
| 4 | +import http from 'node:http'; |
| 5 | +import path from 'node:path'; |
| 6 | +import { uvPath } from '@titaniumnetwork-dev/ultraviolet'; |
7 | 7 |
|
8 | 8 | const server = http.createServer(); |
9 | 9 | const app = express(); |
10 | 10 | const __dirname = process.cwd(); |
11 | | -const bare = createBareServer("/bare/"); |
| 11 | +const bare = createBareServer('/bare/'); |
12 | 12 | const PORT = 6060; |
13 | 13 |
|
14 | 14 | app.use(cors()); |
15 | 15 | app.use(express.urlencoded({ extended: true })); |
16 | 16 | app.use(express.json()); |
17 | | -app.use(express.static(path.join(__dirname, "public"))); |
18 | | -app.use("/!", express.static(uvPath)); |
| 17 | +app.use(express.static(path.join(__dirname, 'public'))); |
| 18 | +app.use('/!', express.static(uvPath)); |
19 | 19 |
|
20 | | -app.get("/", (req, res) => { |
21 | | - res.sendFile(path.join(__dirname, "public/index.html")); |
| 20 | +app.get('/', (req, res) => { |
| 21 | + res.sendFile(path.join(__dirname, 'public/index.html')); |
22 | 22 | }); |
23 | 23 |
|
24 | | -app.get("/&", (req, res) => { |
25 | | - res.sendFile(path.join(__dirname, "public/&.html")); |
26 | | -});; |
| 24 | +app.get('/&', (req, res) => { |
| 25 | + res.sendFile(path.join(__dirname, 'public/&.html')); |
| 26 | +}); |
27 | 27 |
|
28 | | -app.get("/~", (req, res) => { |
29 | | - res.sendFile(path.join(__dirname, "public/~.html")); |
30 | | -});; |
| 28 | +app.get('/~', (req, res) => { |
| 29 | + res.sendFile(path.join(__dirname, 'public/~.html')); |
| 30 | +}); |
31 | 31 |
|
32 | | -app.get("/g", (req, res) => { |
33 | | - res.sendFile(path.join(__dirname, "public/g.html")); |
34 | | -});; |
| 32 | +app.get('/g', (req, res) => { |
| 33 | + res.sendFile(path.join(__dirname, 'public/g.html')); |
| 34 | +}); |
35 | 35 |
|
36 | | -app.get("/a", (req, res) => { |
37 | | - res.sendFile(path.join(__dirname, "public/a.html")); |
38 | | -});; |
| 36 | +app.get('/a', (req, res) => { |
| 37 | + res.sendFile(path.join(__dirname, 'public/a.html')); |
| 38 | +}); |
39 | 39 |
|
40 | | -app.get("/err", (req, res) => { |
41 | | - res.sendFile(path.join(__dirname, "public/err.html")); |
42 | | -});; |
| 40 | +app.get('/err', (req, res) => { |
| 41 | + res.sendFile(path.join(__dirname, 'public/err.html')); |
| 42 | +}); |
43 | 43 |
|
44 | | -app.get("/500", (req, res) => { |
45 | | - res.sendFile(path.join(__dirname, "public/500.html")); |
46 | | -});; |
| 44 | +app.get('/500', (req, res) => { |
| 45 | + res.sendFile(path.join(__dirname, 'public/500.html')); |
| 46 | +}); |
47 | 47 |
|
48 | | -app.get("/a", (req, res) => { |
49 | | - res.sendFile(path.join(__dirname, "public/a.html")); |
50 | | -});; |
51 | | -app.get("/g", (req, res) => { |
52 | | - res.sendFile(path.join(__dirname, "public/g.html")); |
53 | | -});; |
| 48 | +app.get('/a', (req, res) => { |
| 49 | + res.sendFile(path.join(__dirname, 'public/a.html')); |
| 50 | +}); |
| 51 | +app.get('/g', (req, res) => { |
| 52 | + res.sendFile(path.join(__dirname, 'public/g.html')); |
| 53 | +}); |
54 | 54 |
|
55 | | -server.on("request", (req, res) => { |
56 | | - if (bare.shouldRoute(req)) { |
57 | | - bare.routeRequest(req, res); |
58 | | - } else { |
59 | | - app(req, res); |
60 | | - } |
| 55 | +server.on('request', (req, res) => { |
| 56 | + if (bare.shouldRoute(req)) { |
| 57 | + bare.routeRequest(req, res); |
| 58 | + } else { |
| 59 | + app(req, res); |
| 60 | + } |
61 | 61 | }); |
62 | 62 |
|
63 | | -server.on("upgrade", (req, socket, head) => { |
64 | | - if (bare.shouldRoute(req)) { |
65 | | - bare.routeUpgrade(req, socket, head); |
66 | | - } else { |
67 | | - socket.destroy(); |
68 | | - } |
| 63 | +server.on('upgrade', (req, socket, head) => { |
| 64 | + if (bare.shouldRoute(req)) { |
| 65 | + bare.routeUpgrade(req, socket, head); |
| 66 | + } else { |
| 67 | + socket.destroy(); |
| 68 | + } |
69 | 69 | }); |
70 | 70 |
|
71 | | -server.on("listening", () => { |
72 | | - console.log(`Server listening on port ${PORT}`); |
| 71 | +server.on('listening', () => { |
| 72 | + console.log(`Server listening on port ${PORT}`); |
73 | 73 | }); |
74 | 74 |
|
75 | 75 | server.listen(PORT); |
0 commit comments