Skip to content

Commit 271aa2f

Browse files
committed
Optimizations and cleaning
1 parent 6a4acb3 commit 271aa2f

34 files changed

+1952
-1874
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ Thank you for your interest in contributing to this repository! To ensure a smoo
1818
```bash
1919
npm run format
2020
```
21+
2122
4. **Minifying JSON**
22-
23-
- Before finalizing your changes visit https://codebeautify.org/jsonminifier and compress your json and put it in the ``.min.json`` file. (Ex. If you are editing ``a.json`` you would put the minified code in ``a.min.json``
23+
24+
- Before finalizing your changes visit https://codebeautify.org/jsonminifier and compress your json and put it in the `.min.json` file. (Ex. If you are editing `a.json` you would put the minified code in `a.min.json`
2425

2526
5. **Test Your Changes:**
2627

@@ -30,11 +31,11 @@ Thank you for your interest in contributing to this repository! To ensure a smoo
3031
3132
- Provide clear, concise descriptions for your pull requests. Include details on the problem addressed and how your changes resolve it.
3233
33-
8. **Responsive Design:**
34+
7. **Responsive Design:**
3435
3536
- Confirm that changes adhere to responsive design principles, ensuring a seamless user experience across various devices.
3637
37-
9. **Collaboration:**
38+
8. **Collaboration:**
3839
- Be open to feedback and responsive to comments during the review process.
3940
4041
We appreciate your efforts in contributing to this project!

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414
## Features
1515

16-
- About:Blank Cloaking
17-
- Tab Cloaking
18-
- Wide collection of apps & games
19-
- Clean, Easy to use UI
20-
- Inspect Element
21-
- Various Themes
22-
- Password Protection (Optional)
23-
- Built-in Tab System
24-
- Now.gg Support
25-
- Fast Speeds
26-
- Geforce NOW Support
16+
- About:Blank Cloaking
17+
- Tab Cloaking
18+
- Wide collection of apps & games
19+
- Clean, Easy to use UI
20+
- Inspect Element
21+
- Various Themes
22+
- Password Protection (Optional)
23+
- Built-in Tab System
24+
- Now.gg Support
25+
- Fast Speeds
26+
- Geforce NOW Support
2727

2828
## Deployment
2929

@@ -62,8 +62,8 @@ As of January 1st, 2024, Replit is [no longer free](https://blog.replit.com/host
6262
2. Click "Code" (green button) and then "Create Codespace on main."
6363
3. In the terminal at the bottom, paste `pnpm i && pnpm start`.
6464
4. Respond to the application popup by clicking "Make public."
65-
> [!IMPORTANT]
66-
> Make sure you click the "Make public." button, or the proxy won't function properly.
65+
> [!IMPORTANT]
66+
> Make sure you click the "Make public." button, or the proxy won't function properly.
6767
5. Access the deployed website from the ports tab.
6868
6. For subsequent uses in the same codespace, just run `pnpm start`
6969

@@ -74,14 +74,16 @@ As of January 1st, 2024, Replit is [no longer free](https://blog.replit.com/host
7474
3. Go to the ports tab, Click Forward A Port, And type the port number.
7575
4. Right-click Visibility and set Port Visibility to Public.
7676

77-
> [!NOTE]
78-
> We are committed to making Interstellar easy and personalized however, as of now we need your support in making it ad-free. Consider keeping ads so Interstellar can run freely or contribute by being a supporter.
77+
> [!NOTE]
78+
> We are committed to making Interstellar easy and personalized however, as of now we need your support in making it ad-free. Consider keeping ads so Interstellar can run freely or contribute by being a supporter.
7979
8080
## Report Issues
8181

8282
If you encounter problems, open an issue on GitHub, and we'll address it promptly.
83+
8384
> [!TIP]
8485
> If you're having trouble, don't hesitate to reach out to us on [Discord](https://discord.gg/interstellar) for personalized support.
86+
8587
# Credits
8688

8789
A huge thanks goes out to all of the people who have contributed to Interstellar.

config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const config = {
22
challenge: false, // Set to true if you want to enable password protection.
33
users: {
44
// You can add multiple users by doing username: 'password'.
5-
interstellar: 'password',
5+
interstellar: "password",
66
},
77
routes: true, // Change this to false if you just want to host a bare server.
88
local: true, // Change this to false to disable local assets.

index.js

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
import express from "express";
2-
import basicAuth from "express-basic-auth";
3-
import http from "node:http";
4-
import { createBareServer } from "@tomphttp/bare-server-node";
5-
import path from "node:path";
6-
import cors from "cors";
7-
import config from "./config.js";
8-
9-
const __dirname = process.cwd();
10-
const server = http.createServer();
11-
const app = express(server);
12-
const bareServer = createBareServer("/o/");
13-
const PORT = process.env.PORT || 8080;
1+
import express from "express"
2+
import basicAuth from "express-basic-auth"
3+
import http from "node:http"
4+
import { createBareServer } from "@tomphttp/bare-server-node"
5+
import path from "node:path"
6+
import cors from "cors"
7+
import config from "./config.js"
8+
9+
const __dirname = process.cwd()
10+
const server = http.createServer()
11+
const app = express(server)
12+
const bareServer = createBareServer("/o/")
13+
const PORT = process.env.PORT || 8080
1414

1515
if (config.challenge) {
16-
console.log("Password protection is enabled. Usernames are: " + Object.keys(config.users));
17-
console.log("Passwords are: " + Object.values(config.users));
16+
console.log("Password protection is enabled. Usernames are: " + Object.keys(config.users))
17+
console.log("Passwords are: " + Object.values(config.users))
1818

1919
app.use(
2020
basicAuth({
2121
users: config.users,
2222
challenge: true,
2323
})
24-
);
24+
)
2525
}
2626

27-
app.use(express.json());
28-
app.use(express.urlencoded({ extended: true }));
29-
app.use(cors());
30-
app.use(express.static(path.join(__dirname, "static")));
27+
app.use(express.json())
28+
app.use(express.urlencoded({ extended: true }))
29+
app.use(cors())
30+
app.use(express.static(path.join(__dirname, "static")))
3131

3232
if (config.routes !== false) {
3333
const routes = [
@@ -38,76 +38,80 @@ if (config.routes !== false) {
3838
{ path: "/p", file: "go.html" },
3939
{ path: "/", file: "index.html" },
4040
{ path: "/tos", file: "tos.html" },
41-
];
41+
]
4242

4343
routes.forEach((route) => {
4444
app.get(route.path, (req, res) => {
45-
res.sendFile(path.join(__dirname, "static", route.file));
46-
});
47-
});
45+
res.sendFile(path.join(__dirname, "static", route.file))
46+
})
47+
})
4848
}
4949

5050
if (config.local !== false) {
5151
app.get("/e/*", (req, res, next) => {
52-
const baseUrls = ["https://raw.githubusercontent.com/v-5x/x/fixy", "https://raw.githubusercontent.com/ypxa/y/main", "https://raw.githubusercontent.com/ypxa/w/master"];
53-
fetchData(req, res, next, baseUrls);
54-
});
52+
const baseUrls = [
53+
"https://raw.githubusercontent.com/v-5x/x/fixy",
54+
"https://raw.githubusercontent.com/ypxa/y/main",
55+
"https://raw.githubusercontent.com/ypxa/w/master",
56+
]
57+
fetchData(req, res, next, baseUrls)
58+
})
5559
}
5660

5761
const fetchData = async (req, res, next, baseUrls) => {
5862
try {
59-
const reqTarget = baseUrls.map((baseUrl) => `${baseUrl}/${req.params[0]}`);
60-
let data;
61-
let asset;
63+
const reqTarget = baseUrls.map((baseUrl) => `${baseUrl}/${req.params[0]}`)
64+
let data
65+
let asset
6266

6367
for (const target of reqTarget) {
64-
asset = await fetch(target);
68+
asset = await fetch(target)
6569
if (asset.ok) {
66-
data = await asset.arrayBuffer();
67-
break;
70+
data = await asset.arrayBuffer()
71+
break
6872
}
6973
}
7074

7175
if (data) {
72-
res.end(Buffer.from(data));
76+
res.end(Buffer.from(data))
7377
} else {
74-
res.status(404).send();
78+
res.status(404).send()
7579
}
7680
} catch (error) {
77-
console.error(`Error fetching ${req.url}:`, error);
78-
res.status(500).send();
81+
console.error(`Error fetching ${req.url}:`, error)
82+
res.status(500).send()
7983
}
80-
};
84+
}
8185

8286
app.get("*", (req, res) => {
83-
res.status(404).send();
84-
});
87+
res.status(404).send()
88+
})
8589

8690
app.use((err, req, res, next) => {
87-
console.error(err.stack);
88-
res.status(500).send();
89-
});
91+
console.error(err.stack)
92+
res.status(500).send()
93+
})
9094

9195
server.on("request", (req, res) => {
9296
if (bareServer.shouldRoute(req)) {
93-
bareServer.routeRequest(req, res);
97+
bareServer.routeRequest(req, res)
9498
} else {
95-
app(req, res);
99+
app(req, res)
96100
}
97-
});
101+
})
98102

99103
server.on("upgrade", (req, socket, head) => {
100104
if (bareServer.shouldRoute(req)) {
101-
bareServer.routeUpgrade(req, socket, head);
105+
bareServer.routeUpgrade(req, socket, head)
102106
} else {
103-
socket.end();
107+
socket.end()
104108
}
105-
});
109+
})
106110

107111
server.on("listening", () => {
108-
console.log(`Running at http://localhost:${PORT}`);
109-
});
112+
console.log(`Running at http://localhost:${PORT}`)
113+
})
110114

111115
server.listen({
112116
port: PORT,
113-
});
117+
})

0 commit comments

Comments
 (0)