Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUnblockedHubOfficial authored Oct 18, 2023
1 parent bdcaef0 commit b7f9f90
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import express from "express";
import http from "node:http";
import createBareServer from "@tomphttp/bare-server-node";
import path from "node:path";
import http from "http";
import path from "path";
import * as dotenv from "dotenv";
import rateLimit from "express-rate-limit"; // Import express-rate-limit
import rateLimit from "express-rate-limit";

dotenv.config();

const __dirname = process.cwd();
const server = http.createServer();
const app = express(server);
const bareServer = createBareServer("/bare/");
const app = express();
const server = http.createServer(app);
const port = process.env.PORT || 3000;

// Define the rate limit settings
const limiter = rateLimit({
Expand Down Expand Up @@ -37,6 +37,12 @@ app.get("/forest", (req, res) => {
res.sendFile(path.join(__dirname, "static", "forest.html"));
});

// Define other routes...

app.get("/forest", (req, res) => {
res.sendFile(path.join(__dirname, "static", "forest.html"));
});

app.get("/photography", (req, res) => {
res.sendFile(path.join(__dirname, "static", "photography.html"));
});
Expand Down Expand Up @@ -69,27 +75,6 @@ app.get("/*", (req, res) => {
res.redirect("/404");
});

// Bare Server
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(`The Unblocked Hub running at http://localhost:${process.env.PORT}`);
});

server.listen({
port: process.env.PORT,
server.listen(port, () => {
console.log(`The Unblocked Hub running at http://localhost:${port}`);
});

0 comments on commit b7f9f90

Please sign in to comment.