Skip to content

Commit 91c525f

Browse files
committed
Use template literals + Move port to server block in config
1 parent 74f4cd4 commit 91c525f

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import type { Config } from "@/types/config";
22

33
const config: Config = {
44
// Server Configuration
5-
port: 8080, // The port on which Interstellar runs (Default: 8080)
5+
server: {
6+
port: 8080, // The port on which Interstellar runs (Default: 8080)
7+
},
68

79
// Authentication Configuration (Optional)
810
auth: {
@@ -13,7 +15,7 @@ const config: Config = {
1315
// Format: username: "password",
1416
// IMPORTANT: Replace default credentials before deployment
1517
users: {
16-
interstellar: "password",
18+
interstellar: "password",
1719
},
1820
},
1921
};

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function Start() {
3333
}
3434
}
3535

36-
const port = INConfig.port || 8080;
36+
const port = INConfig.server?.port || 8080;
3737

3838
const app = Fastify({
3939
serverFactory: (handler) =>

randomize.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from "node:fs";
33
import path from "node:path";
44

55
const RenamedFiles: { [key: string]: string } = {};
6-
const PageRoutes: { [key: string]: string } = {};
6+
const PageRoutes: { [key: string]: string } = {};
77

88
export function randomizeName(filePath: string): string {
99
const extname = path.extname(filePath);
@@ -49,9 +49,13 @@ export function RandomizeNames() {
4949
fs.renameSync(oldPath, newPath);
5050

5151
if (file.startsWith(path.join(process.cwd(), "src", "pages"))) {
52-
const oldRoute = oldPath.replace(process.cwd() + "/src/pages", "").replace(/\\/g, "/");
53-
const newRoute = newPath.replace(process.cwd() + "/src/pages", "").replace(/\\/g, "/");
54-
PageRoutes[oldRoute] = newRoute;
52+
const oldRoute = oldPath
53+
.replace(`${process.cwd()}/src/pages`, "")
54+
.replace(/\\/g, "/");
55+
const newRoute = newPath
56+
.replace(`${process.cwd()}/src/pages`, "")
57+
.replace(/\\/g, "/");
58+
PageRoutes[oldRoute] = newRoute;
5559
}
5660
}
5761

@@ -112,7 +116,7 @@ export function updatePageRoutes() {
112116
for (const [oldRoute, newRoute] of Object.entries(PageRoutes)) {
113117
fileContent = fileContent.replace(
114118
new RegExp(`['"]${oldRoute.replace(".astro", "")}['"]`, "g"),
115-
`'${newRoute.replace(".astro", "")}'`
119+
`'${newRoute.replace(".astro", "")}'`,
116120
);
117121
}
118122

@@ -133,7 +137,7 @@ export async function Revert() {
133137
try {
134138
console.log("Reverting Changes.");
135139
execSync("git restore src/", { cwd: process.cwd(), stdio: "inherit" });
136-
execSync("git clean -fdx src/", { cwd: process.cwd(), stdio: "inherit" });
140+
execSync("git clean -fdx src/", { cwd: process.cwd(), stdio: "inherit" });
137141

138142
await new Promise((resolve) => setTimeout(resolve, 2000));
139143
console.log("Revert completed.");

src/types/config.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
// Configuration for the application
12
export interface Config {
3+
// Server configuration
4+
server?: {
5+
// The port to run the HTTP server on
6+
// Default: 8080
7+
port?: number;
8+
};
9+
10+
// Authentication configuration
211
auth?: Auth;
3-
/**
4-
* The port to run the HTTP server on
5-
* @default 8080
6-
*/
7-
port?: number;
812
}
13+
14+
// Authentication settings
915
export interface Auth {
10-
/**
11-
* Enable password protection
12-
* @default false
13-
*/
16+
// Enable password protection
17+
// Default: false
1418
challenge?: boolean;
15-
/**
16-
* Users and their passwords
17-
* @example ```js
18-
{ "interstellarskidder": "superSecretPassword!!!" }
19-
```
20-
*/
19+
20+
// Users and their passwords
21+
// Example: "username": "password",
2122
users?: Record<string, string>;
2223
}

0 commit comments

Comments
 (0)