I can't be bothered to even explain what happene here

This commit is contained in:
2025-02-07 23:18:04 -05:00
parent d982567c7b
commit bc3443b1dc
21 changed files with 994 additions and 177 deletions

View File

@@ -1,6 +1,5 @@
import Logging from "@proxnet/undead-logging";
import * as fs from "node:fs";
import process from "node:process";
const log = new Logging("Config");
@@ -14,13 +13,17 @@ type RedisConfiguration = {
type WebConfiguration = {
port: number,
host: string
host: string,
nameserverHost: string,
secureNameserverHost: boolean
}
type PublicConfiguration = {
serverName: string,
owner: string,
motd: string
motd: string,
levelScale: number,
maxLevels: number
}
type LoggingConfiguration = {
@@ -34,15 +37,20 @@ type DiscordConfiguration = {
guildId: string
}
type GalvanicConfiguration = {
type SecretConfiguration = {
authSecret: string
}
export type GalvanicConfiguration = {
redis: RedisConfiguration,
web: WebConfiguration,
public: PublicConfiguration,
logging: LoggingConfiguration,
discord: DiscordConfiguration
discord: DiscordConfiguration,
secrets: SecretConfiguration
}
const defaultConfig: GalvanicConfiguration = {
export const defaultConfig: GalvanicConfiguration = {
redis: {
host: "127.0.0.1",
port: 6379,
@@ -52,12 +60,16 @@ const defaultConfig: GalvanicConfiguration = {
},
web: {
port: 3000,
host: "127.0.0.1"
host: "127.0.0.1",
nameserverHost: "127.0.0.1:3000",
secureNameserverHost: false
},
public: {
serverName: "Galvanic Corrosion",
owner: "John Doe",
motd: "The narwhal bacons at midnight"
motd: "The narwhal bacons at midnight",
levelScale: 1,
maxLevels: 30
},
logging: {
debug: false,
@@ -67,6 +79,9 @@ const defaultConfig: GalvanicConfiguration = {
token: "replace-me",
guildId: "replace-me",
clientId: "replace-me"
},
secrets: {
authSecret: "CHANGE-ME-PLEASE"
}
}
@@ -77,19 +92,7 @@ try {
config = JSON.parse(fs.readFileSync('./config.json').toString());
} catch (err) {
log.e(`Could not get config: ${err}`);
process.exit(1);
}
/**
* Looks for a certain file in the current directory that shouldn't exist on the first run.
* Returns `false` when GC has ran at least once
*/
export function firstRun() {
if (!fs.existsSync('./firstrun')) return true;
else {
fs.writeFile('./firstrun', "", () => {});
return false;
}
Deno.exit(1);
}
/** Does the configuration file exist on the disk? */