SpaceNinjaServer/src/services/configService.ts

84 lines
2.6 KiB
TypeScript
Raw Normal View History

import fs from "fs";
import path from "path";
import { repoDir } from "@/src/helpers/pathHelper";
2024-05-15 21:55:59 +02:00
interface IConfig {
mongodbUrl: string;
logger: {
files: boolean;
level: string; // "fatal" | "error" | "warn" | "info" | "http" | "debug" | "trace";
};
2024-05-15 21:55:59 +02:00
myAddress: string;
httpPort?: number;
httpsPort?: number;
myIrcAddresses?: string[];
2025-02-21 08:29:42 +01:00
NRS?: string[];
administratorNames?: string[];
2024-05-15 21:55:59 +02:00
autoCreateAccount?: boolean;
skipTutorial?: boolean;
skipAllDialogue?: boolean;
2024-05-15 21:55:59 +02:00
unlockAllScans?: boolean;
unlockAllMissions?: boolean;
infiniteCredits?: boolean;
infinitePlatinum?: boolean;
infiniteEndo?: boolean;
infiniteRegalAya?: boolean;
infiniteHelminthMaterials?: boolean;
dontSubtractConsumables?: boolean;
2024-06-11 12:56:51 +02:00
unlockAllShipFeatures?: boolean;
2024-05-15 21:55:59 +02:00
unlockAllShipDecorations?: boolean;
unlockAllFlavourItems?: boolean;
2024-05-29 22:08:41 +02:00
unlockAllSkins?: boolean;
2024-12-29 21:11:36 +01:00
unlockAllCapturaScenes?: boolean;
unlockAllDecoRecipes?: boolean;
universalPolarityEverywhere?: boolean;
unlockDoubleCapacityPotatoesEverywhere?: boolean;
unlockExilusEverywhere?: boolean;
unlockArcanesEverywhere?: boolean;
noDailyStandingLimits?: boolean;
noDailyFocusLimit?: boolean;
noArgonCrystalDecay?: boolean;
noMasteryRankUpCooldown?: boolean;
noVendorPurchaseLimits?: boolean;
noDeathMarks?: boolean;
noKimCooldowns?: boolean;
instantResourceExtractorDrones?: boolean;
noResourceExtractorDronesDamage?: boolean;
skipClanKeyCrafting?: boolean;
noDojoRoomBuildStage?: boolean;
noDojoDecoBuildStage?: boolean;
fastDojoRoomDestruction?: boolean;
noDojoResearchCosts?: boolean;
noDojoResearchTime?: boolean;
fastClanAscension?: boolean;
spoofMasteryRank?: number;
worldState?: {
creditBoost?: boolean;
affinityBoost?: boolean;
resourceBoost?: boolean;
starDays?: boolean;
lockTime?: number;
};
2024-05-15 21:55:59 +02:00
}
export const configPath = path.join(repoDir, "config.json");
2024-05-15 21:55:59 +02:00
export const config: IConfig = {
mongodbUrl: "mongodb://127.0.0.1:27017/openWF",
logger: {
files: true,
level: "trace"
},
myAddress: "localhost"
};
export const loadConfig = (): void => {
// Set all values to undefined now so if the new config.json omits some fields that were previously present, it's correct in-memory.
for (const key of Object.keys(config)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
(config as any)[key] = undefined;
}
Object.assign(config, JSON.parse(fs.readFileSync(configPath, "utf-8")));
};