Skip to content

Commit f4a0b75

Browse files
committed
Update config options, Added port & password protection
1 parent e683dfd commit f4a0b75

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Interstellar V6
2+
23
This is an unstable version of the Interstellar project, completely rewritten from the ground up.
34

45
# Deployment
6+
57
To deploy Interstellar on your server, follow these steps:
68

79
#### 1. Clone the Repository
10+
811
First, clone the **Interstellar** repository to your server:
912

1013
```bash
@@ -13,6 +16,7 @@ cd Interstellar
1316
```
1417

1518
#### 2. Install Dependencies and Start the Project
19+
1620
Once you've cloned the repository, install the required dependencies and start the application:
1721

1822
```bash
@@ -22,6 +26,7 @@ pnpm install && pnpm start
2226
This will install all the necessary dependencies and start the application in production mode.
2327

2428
# Development
29+
2530
If you are developing for Interstellar , use the following commands:
2631

2732
```bash

config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import type { Config } from "@/types/config";
2+
23
const config: Config = {
3-
// config options here...
4+
// Customize the port Interstellar runs on (Default: 8080)
5+
port: 8080,
6+
7+
// Protect your Instance with logins (Optional)
8+
auth: {
9+
challenge: false, // Password protection (Default: False)
10+
users: {
11+
interstellar: "password", // Add usernames and passwords here
12+
},
13+
},
414
};
15+
516
export default config;

index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import { execSync } from "node:child_process";
12
import fs from "node:fs";
23
import { createServer } from "node:http";
34
import type { Socket } from "node:net";
45
import path from "node:path";
5-
import { execSync } from "node:child_process";
66
import fastifyMiddie from "@fastify/middie";
77
import fastifyStatic from "@fastify/static";
8-
// @ts-expect-error shut
8+
// @ts-expect-error
99
import { server as wisp } from "@mercuryworkshop/wisp-js/server";
1010
import { build } from "astro";
1111
import Fastify from "fastify";
12-
import inConfig from "./config";
12+
import INConfig from "./config";
1313

1414
const RenamedFiles: { [key: string]: string } = {};
1515

@@ -95,12 +95,13 @@ async function Start() {
9595

9696
if (FirstRun) {
9797
console.log("Restarting Server...");
98-
execSync("pnpm disable && pnpm start", { stdio: "inherit" });
98+
execSync("pnpm disable && pnpm start", { stdio: "inherit" });
9999
process.exit(0);
100100
}
101101
}
102102

103-
const port = Number.parseInt(process.env.PORT as string) || inConfig.port || 8080;
103+
const port = INConfig.port || 8080;
104+
104105
const app = Fastify({
105106
serverFactory: (handler) =>
106107
createServer(handler).on("upgrade", (req, socket: Socket, head) =>
@@ -114,11 +115,11 @@ async function Start() {
114115
encodings: ["br", "gzip", "deflate"],
115116
});
116117

117-
if (inConfig.auth?.challenge) {
118+
if (INConfig.auth?.challenge) {
118119
await app.register(import("@fastify/basic-auth"), {
119120
authenticate: true,
120121
validate(username, password, _req, _reply, done) {
121-
for (const [user, pass] of Object.entries(inConfig.auth?.users || {})) {
122+
for (const [user, pass] of Object.entries(INConfig.auth?.users || {})) {
122123
if (username === user && password === pass) {
123124
return done();
124125
}

0 commit comments

Comments
 (0)