diff --git a/src/controllers/api/getCreditsController.ts b/src/controllers/api/getCreditsController.ts index 5f86de98..e7be097e 100644 --- a/src/controllers/api/getCreditsController.ts +++ b/src/controllers/api/getCreditsController.ts @@ -1,5 +1,5 @@ import { RequestHandler } from "express"; -import config from "@/config.json"; +import { config } from "@/src/services/configService"; import { getInventory } from "@/src/services/inventoryService"; import { parseString } from "@/src/helpers/general"; diff --git a/src/controllers/api/getShipController.ts b/src/controllers/api/getShipController.ts index cc2794bf..de89bdc1 100644 --- a/src/controllers/api/getShipController.ts +++ b/src/controllers/api/getShipController.ts @@ -1,5 +1,5 @@ import { RequestHandler } from "express"; -import config from "@/config.json"; +import { config } from "@/src/services/configService"; import allShipFeatures from "@/static/fixed_responses/allShipFeatures.json"; import { parseString } from "@/src/helpers/general"; import { getPersonalRooms } from "@/src/services/personalRoomsService"; diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index f3e08fef..d3dddd2a 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -2,7 +2,7 @@ import { toInventoryResponse } from "@/src/helpers/inventoryHelpers"; import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import { Request, RequestHandler, Response } from "express"; -import config from "@/config.json"; +import { config } from "@/src/services/configService"; import allMissions from "@/static/fixed_responses/allMissions.json"; import allQuestKeys from "@/static/fixed_responses/allQuestKeys.json"; import allShipDecorations from "@/static/fixed_responses/allShipDecorations.json"; diff --git a/src/controllers/api/loginController.ts b/src/controllers/api/loginController.ts index 34cb9eed..17481713 100644 --- a/src/controllers/api/loginController.ts +++ b/src/controllers/api/loginController.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { RequestHandler } from "express"; -import config from "@/config.json"; +import { config } from "@/src/services/configService"; import buildConfig from "@/static/data/buildConfig.json"; import { toLoginRequest } from "@/src/helpers/loginHelpers"; diff --git a/src/controllers/stats/viewController.ts b/src/controllers/stats/viewController.ts index c73eac38..374c0d8e 100644 --- a/src/controllers/stats/viewController.ts +++ b/src/controllers/stats/viewController.ts @@ -1,7 +1,7 @@ import { RequestHandler } from "express"; import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import { IStatsView } from "@/src/types/statTypes"; -import config from "@/config.json"; +import { config } from "@/src/services/configService"; import view from "@/static/fixed_responses/view.json"; import allScans from "@/static/fixed_responses/allScans.json"; diff --git a/src/services/configService.ts b/src/services/configService.ts new file mode 100644 index 00000000..54d1e78d --- /dev/null +++ b/src/services/configService.ts @@ -0,0 +1,24 @@ +import rawConfig from "@/config.json"; + +interface IConfig { + mongodbUrl: string; + logger: ILoggerConfig; + myAddress: string; + autoCreateAccount?: boolean; + skipStoryModeChoice?: boolean; + skipTutorial?: boolean; + unlockAllScans?: boolean; + unlockAllMissions?: boolean; + unlockAllQuests?: boolean; + infiniteResources?: boolean; + unlockallShipFeatures?: boolean; + unlockAllShipDecorations?: boolean; + unlockAllFlavourItems?: boolean; +} + +interface ILoggerConfig { + files: boolean; + level: string; // "fatal" | "error" | "warn" | "info" | "http" | "debug" | "trace"; +} + +export const config: IConfig = rawConfig; diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 117891a4..0d685258 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1,6 +1,6 @@ import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import new_inventory from "@/static/fixed_responses/postTutorialInventory.json"; -import config from "@/config.json"; +import { config } from "@/src/services/configService"; import { Types } from "mongoose"; import { ISuitClient } from "@/src/types/inventoryTypes/SuitTypes"; import { SlotNames } from "@/src/types/purchaseTypes"; diff --git a/src/services/mongoService.ts b/src/services/mongoService.ts index 71ca5b65..0c24c3de 100644 --- a/src/services/mongoService.ts +++ b/src/services/mongoService.ts @@ -1,5 +1,5 @@ import { logger } from "@/src/utils/logger"; -import config from "@/config.json"; +import { config } from "@/src/services/configService"; import mongoose from "mongoose"; const url = config.mongodbUrl; diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 246d87a9..03aa2562 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -1,6 +1,6 @@ import { createLogger, format, transports, Logger, LeveledLogMethod, addColors } from "winston"; import "winston-daily-rotate-file"; -import config from "@/config.json"; +import { config } from "@/src/services/configService"; import * as util from "util"; import { isEmptyObject } from "@/src/helpers/general";