Embed base images into binary
Include resource directory Ran `deno fmt` with 4 space indent, that changed every file (!!!!!) various changes
This commit is contained in:
@@ -4,58 +4,58 @@ import * as fs from "node:fs";
|
||||
const log = new Logging("Config");
|
||||
|
||||
type RedisConfiguration = {
|
||||
host: string,
|
||||
port: number,
|
||||
username: string,
|
||||
password: string,
|
||||
db: number
|
||||
}
|
||||
host: string;
|
||||
port: number;
|
||||
username: string;
|
||||
password: string;
|
||||
db: number;
|
||||
};
|
||||
|
||||
type WebConfiguration = {
|
||||
port: number,
|
||||
host: string,
|
||||
publichost: string,
|
||||
securepublichost: boolean
|
||||
}
|
||||
port: number;
|
||||
host: string;
|
||||
publichost: string;
|
||||
securepublichost: boolean;
|
||||
};
|
||||
|
||||
type PublicConfiguration = {
|
||||
serverName: string,
|
||||
serverId: string,
|
||||
owner: string,
|
||||
motd: string,
|
||||
levelScale: number,
|
||||
maxLevels: number
|
||||
patches: string[],
|
||||
}
|
||||
serverName: string;
|
||||
serverId: string;
|
||||
owner: string;
|
||||
motd: string;
|
||||
levelScale: number;
|
||||
maxLevels: number;
|
||||
patches: string[];
|
||||
};
|
||||
|
||||
type LoggingConfiguration = {
|
||||
notfound: boolean,
|
||||
debug: boolean,
|
||||
network: boolean
|
||||
}
|
||||
notfound: boolean;
|
||||
debug: boolean;
|
||||
network: boolean;
|
||||
};
|
||||
|
||||
type DiscordConfiguration = {
|
||||
token: string,
|
||||
clientId: string,
|
||||
guildId: string
|
||||
}
|
||||
token: string;
|
||||
clientId: string;
|
||||
guildId: string;
|
||||
};
|
||||
|
||||
type AuthConfiguration = {
|
||||
secret: string,
|
||||
secret: string;
|
||||
/**
|
||||
* In Hours
|
||||
*/
|
||||
timeout: number
|
||||
}
|
||||
timeout: number;
|
||||
};
|
||||
|
||||
export type GalvanicConfiguration = {
|
||||
redis: RedisConfiguration,
|
||||
web: WebConfiguration,
|
||||
public: PublicConfiguration,
|
||||
logging: LoggingConfiguration,
|
||||
discord: DiscordConfiguration | null,
|
||||
auth: AuthConfiguration
|
||||
}
|
||||
redis: RedisConfiguration;
|
||||
web: WebConfiguration;
|
||||
public: PublicConfiguration;
|
||||
logging: LoggingConfiguration;
|
||||
discord: DiscordConfiguration | null;
|
||||
auth: AuthConfiguration;
|
||||
};
|
||||
|
||||
export const defaultConfig: GalvanicConfiguration = {
|
||||
redis: {
|
||||
@@ -63,7 +63,7 @@ export const defaultConfig: GalvanicConfiguration = {
|
||||
port: 6379,
|
||||
username: "",
|
||||
password: "",
|
||||
db: 0
|
||||
db: 0,
|
||||
},
|
||||
web: {
|
||||
port: 3000,
|
||||
@@ -83,20 +83,20 @@ export const defaultConfig: GalvanicConfiguration = {
|
||||
logging: {
|
||||
notfound: false,
|
||||
debug: false,
|
||||
network: false
|
||||
network: false,
|
||||
},
|
||||
discord: null,
|
||||
auth: {
|
||||
secret: "CHANGE-ME-PLEASE",
|
||||
timeout: 48
|
||||
}
|
||||
}
|
||||
timeout: 48,
|
||||
},
|
||||
};
|
||||
|
||||
/** The current configuration. Read and parsed only during startup. */
|
||||
let config: GalvanicConfiguration;
|
||||
try {
|
||||
if (!configurationExists()) generateDefaultConfig();
|
||||
config = JSON.parse(fs.readFileSync('./config.json').toString());
|
||||
config = JSON.parse(fs.readFileSync("./config.json").toString());
|
||||
} catch (err) {
|
||||
log.e(`Could not get config: ${err}`);
|
||||
Deno.exit(1);
|
||||
@@ -104,12 +104,15 @@ try {
|
||||
|
||||
/** Does the configuration file exist on the disk? */
|
||||
export function configurationExists() {
|
||||
return fs.existsSync('./config.json');
|
||||
return fs.existsSync("./config.json");
|
||||
}
|
||||
|
||||
/** Place [or overwrite] the [existing] default configuration in the current directory */
|
||||
export function generateDefaultConfig() {
|
||||
fs.writeFileSync('./config.json', JSON.stringify(defaultConfig, undefined, ' '));
|
||||
fs.writeFileSync(
|
||||
"./config.json",
|
||||
JSON.stringify(defaultConfig, undefined, " "),
|
||||
);
|
||||
}
|
||||
|
||||
/** Get current server configuration */
|
||||
@@ -117,6 +120,6 @@ export function getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
export const devMode = Deno.args.includes('--dev');
|
||||
export const devMode = Deno.args.includes("--dev");
|
||||
|
||||
export * as Config from './config.ts';
|
||||
export * as Config from "./config.ts";
|
||||
|
||||
Reference in New Issue
Block a user