Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade bare-server-node to v1.2.2 #12

Merged
merged 3 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
});
21 changes: 0 additions & 21 deletions index.mjs

This file was deleted.

199 changes: 183 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"bare-server-node": "github:tomphttp/bare-server-node",
"@tomphttp/bare-server-node": "^1.2.2",
"node-static": "^0.7.11",
"npm": "^8.7.0",
"path": "^0.12.7",
Expand All @@ -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