Skip to content

Commit

Permalink
remove weird module wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
e9x committed Nov 23, 2022
1 parent e8f70bf commit 2a19502
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 42 deletions.
41 changes: 38 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
(async() => {
await import('./index.mjs');
})();
import createBareServer from "@tomphttp/bare-server-node";
import http from "node:http";

const httpServer = http.createServer();

const bareServer = createBareServer("/", {
logErrors: false,
localAddress: undefined,
maintainer: {
email: "[email protected]",
website: "https://github.com/tomphttp/",
},
});

httpServer.on("request", (req, res) => {
if (bareServer.shouldRoute(req)) {
bareServer.routeRequest(req, res);
} else {
res.writeHead(400);
res.end("Not found.");
}
});

httpServer.on("upgrade", (req, socket, head) => {
if (bareServer.shouldRoute(req)) {
bareServer.routeUpgrade(req, socket, head);
} else {
socket.end();
}
});

httpServer.on("listening", () => {
console.log("HTTP server listening");
});

httpServer.listen({
port: process.env.PORT || 6969,
});
38 changes: 0 additions & 38 deletions index.mjs

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"name": "uv-app",
"version": "1.0.0",
"description": "Ultraviolet instance",
"type": "module",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node ."
"start": "node index.js"
},
"keywords": [
"proxy"
Expand Down

0 comments on commit 2a19502

Please sign in to comment.