Skip to content

Commit 2a19502

Browse files
committed
remove weird module wrapper
1 parent e8f70bf commit 2a19502

File tree

3 files changed

+40
-42
lines changed

3 files changed

+40
-42
lines changed

index.js

+38-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1-
(async() => {
2-
await import('./index.mjs');
3-
})();
1+
import createBareServer from "@tomphttp/bare-server-node";
2+
import http from "node:http";
3+
4+
const httpServer = http.createServer();
5+
6+
const bareServer = createBareServer("/", {
7+
logErrors: false,
8+
localAddress: undefined,
9+
maintainer: {
10+
11+
website: "https://github.com/tomphttp/",
12+
},
13+
});
14+
15+
httpServer.on("request", (req, res) => {
16+
if (bareServer.shouldRoute(req)) {
17+
bareServer.routeRequest(req, res);
18+
} else {
19+
res.writeHead(400);
20+
res.end("Not found.");
21+
}
22+
});
23+
24+
httpServer.on("upgrade", (req, socket, head) => {
25+
if (bareServer.shouldRoute(req)) {
26+
bareServer.routeUpgrade(req, socket, head);
27+
} else {
28+
socket.end();
29+
}
30+
});
31+
32+
httpServer.on("listening", () => {
33+
console.log("HTTP server listening");
34+
});
35+
36+
httpServer.listen({
37+
port: process.env.PORT || 6969,
38+
});

index.mjs

-38
This file was deleted.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
"name": "uv-app",
1111
"version": "1.0.0",
1212
"description": "Ultraviolet instance",
13+
"type": "module",
1314
"main": "index.js",
1415
"scripts": {
1516
"test": "echo \"Error: no test specified\" && exit 1",
16-
"start": "node ."
17+
"start": "node index.js"
1718
},
1819
"keywords": [
1920
"proxy"

0 commit comments

Comments
 (0)