diff --git a/package-lock.json b/package-lock.json index b072d3d6..d1fddf5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "ncp": "^2.0.0", "typescript": "^5.7", "undici": "^7.10.0", - "warframe-public-export-plus": "^0.5.82", + "warframe-public-export-plus": "^0.5.83", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0", @@ -5507,9 +5507,9 @@ } }, "node_modules/warframe-public-export-plus": { - "version": "0.5.82", - "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.82.tgz", - "integrity": "sha512-hZa9KpMDA2wy0Hn03y9Nfyzbjxer1I6Rvb52b363uzrqS0cvDO56rhiDo71JbraeV34qF6yo+Vca1zwFmw2srA==" + "version": "0.5.83", + "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.83.tgz", + "integrity": "sha512-SJgw6NxQaiLgMfnKGML8mRY9lT3wJb3HEABSvuCd/XiKpUqPgqTCp7EwPhbG3D/FMtN+IZjBQgykLD5R7/MSRA==" }, "node_modules/warframe-riven-info": { "version": "0.1.2", diff --git a/package.json b/package.json index 3c2ce7cd..0e55719c 100644 --- a/package.json +++ b/package.json @@ -11,20 +11,22 @@ "build:dev:tsc": "tsc --incremental --sourceMap", "build-and-start": "npm run build && npm run start", "build-and-start:bun": "npm run verify && npm run bun-run", - "dev": "node scripts/dev.js", - "dev:bun": "bun scripts/dev.js", + "dev": "node scripts/dev.cjs", + "dev:bun": "bun scripts/dev.cjs", "verify": "tsgo --noEmit", "verify:tsc": "tsc --noEmit", - "bun-run": "bun src/index.ts", + "raw": "node --experimental-transform-types src/index.ts", + "raw:bun": "bun src/index.ts", "lint": "eslint --ext .ts .", "lint:ci": "eslint --ext .ts --rule \"prettier/prettier: off\" .", "lint:fix": "eslint --fix --ext .ts .", "prettier": "prettier --write .", - "update-translations": "cd scripts && node update-translations.js", - "fix-imports": "cd scripts && node fix-imports.js", + "update-translations": "cd scripts && node update-translations.cjs", + "fix-imports": "cd scripts && node fix-imports.cjs", "fix": "npm run update-translations && npm run fix-imports && npm run prettier" }, "license": "GNU", + "type": "module", "dependencies": { "@types/express": "^5", "@types/morgan": "^1.9.9", @@ -40,7 +42,7 @@ "ncp": "^2.0.0", "typescript": "^5.7", "undici": "^7.10.0", - "warframe-public-export-plus": "^0.5.82", + "warframe-public-export-plus": "^0.5.83", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0", diff --git a/scripts/dev.js b/scripts/dev.cjs similarity index 97% rename from scripts/dev.js rename to scripts/dev.cjs index 542528f1..7931df6b 100644 --- a/scripts/dev.js +++ b/scripts/dev.cjs @@ -39,7 +39,7 @@ function run(changedFile) { buildproc = undefined; if (code === 0) { console.log(`${process.versions.bun ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`); - runproc = spawn("npm", ["run", process.versions.bun ? "bun-run" : "start", "--", ...args], spawnopts); + runproc = spawn("npm", ["run", process.versions.bun ? "raw:bun" : "start", "--", ...args], spawnopts); runproc.on("exit", () => { runproc = undefined; }); diff --git a/scripts/fix-imports.js b/scripts/fix-imports.cjs similarity index 100% rename from scripts/fix-imports.js rename to scripts/fix-imports.cjs diff --git a/scripts/update-translations.js b/scripts/update-translations.cjs similarity index 100% rename from scripts/update-translations.js rename to scripts/update-translations.cjs diff --git a/src/controllers/api/getShipController.ts b/src/controllers/api/getShipController.ts index b411db68..3166655c 100644 --- a/src/controllers/api/getShipController.ts +++ b/src/controllers/api/getShipController.ts @@ -1,6 +1,6 @@ import type { RequestHandler } from "express"; import { config } from "../../services/configService.ts"; -import allShipFeatures from "../../../static/fixed_responses/allShipFeatures.json"; +import allShipFeatures from "../../../static/fixed_responses/allShipFeatures.json" with { type: "json" }; import { getAccountIdForRequest } from "../../services/loginService.ts"; import { createGarden, getPersonalRooms } from "../../services/personalRoomsService.ts"; import type { IGetShipResponse, IPersonalRoomsClient } from "../../types/personalRoomsTypes.ts"; diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index 1dd64fbf..fb935c38 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -3,7 +3,7 @@ import { getAccountForRequest } from "../../services/loginService.ts"; import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts"; import { Inventory } from "../../models/inventoryModels/inventoryModel.ts"; import { config } from "../../services/configService.ts"; -import allDialogue from "../../../static/fixed_responses/allDialogue.json"; +import allDialogue from "../../../static/fixed_responses/allDialogue.json" with { type: "json" }; import type { ILoadoutDatabase } from "../../types/saveLoadoutTypes.ts"; import type { IInventoryClient, IShipInventory } from "../../types/inventoryTypes/inventoryTypes.ts"; import { equipmentKeys } from "../../types/inventoryTypes/inventoryTypes.ts"; diff --git a/src/controllers/api/redeemPromoCodeController.ts b/src/controllers/api/redeemPromoCodeController.ts index 733ded0b..b81177b8 100644 --- a/src/controllers/api/redeemPromoCodeController.ts +++ b/src/controllers/api/redeemPromoCodeController.ts @@ -1,6 +1,6 @@ import { getJSONfromString } from "../../helpers/stringHelpers.ts"; import type { RequestHandler } from "express"; -import glyphCodes from "../../../static/fixed_responses/glyphsCodes.json"; +import glyphCodes from "../../../static/fixed_responses/glyphsCodes.json" with { type: "json" }; import { getAccountIdForRequest } from "../../services/loginService.ts"; import { addItem, getInventory } from "../../services/inventoryService.ts"; diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index 0f24ace9..5c96dfbb 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -21,8 +21,8 @@ import { ExportWarframes, ExportWeapons } from "warframe-public-export-plus"; -import allIncarnons from "../../../static/fixed_responses/allIncarnonList.json"; -import varzia from "../../../static/fixed_responses/worldState/varzia.json"; +import allIncarnons from "../../../static/fixed_responses/allIncarnonList.json" with { type: "json" }; +import varzia from "../../../static/fixed_responses/worldState/varzia.json" with { type: "json" }; interface ListedItem { uniqueName: string; diff --git a/src/controllers/dynamic/aggregateSessionsController.ts b/src/controllers/dynamic/aggregateSessionsController.ts index 64d3258c..2162c731 100644 --- a/src/controllers/dynamic/aggregateSessionsController.ts +++ b/src/controllers/dynamic/aggregateSessionsController.ts @@ -1,5 +1,5 @@ import type { RequestHandler } from "express"; -import aggregateSessions from "../../../static/fixed_responses/aggregateSessions.json"; +import aggregateSessions from "../../../static/fixed_responses/aggregateSessions.json" with { type: "json" }; const aggregateSessionsController: RequestHandler = (_req, res) => { res.json(aggregateSessions); diff --git a/src/controllers/stats/viewController.ts b/src/controllers/stats/viewController.ts index 9cf29134..52d5e97f 100644 --- a/src/controllers/stats/viewController.ts +++ b/src/controllers/stats/viewController.ts @@ -1,7 +1,7 @@ import type { RequestHandler } from "express"; import { getAccountIdForRequest } from "../../services/loginService.ts"; import { config } from "../../services/configService.ts"; -import allScans from "../../../static/fixed_responses/allScans.json"; +import allScans from "../../../static/fixed_responses/allScans.json" with { type: "json" }; import { ExportEnemies } from "warframe-public-export-plus"; import { getInventory } from "../../services/inventoryService.ts"; import { getStats } from "../../services/statsService.ts"; diff --git a/src/helpers/pathHelper.ts b/src/helpers/pathHelper.ts index 37e87dff..69b0c373 100644 --- a/src/helpers/pathHelper.ts +++ b/src/helpers/pathHelper.ts @@ -1,4 +1,4 @@ import path from "path"; -export const rootDir = path.join(__dirname, "../.."); +export const rootDir = path.join(import.meta.dirname, "../.."); export const repoDir = path.basename(rootDir) != "build" ? rootDir : path.join(rootDir, ".."); diff --git a/src/services/configWatcherService.ts b/src/services/configWatcherService.ts index 67a38df9..1788d58a 100644 --- a/src/services/configWatcherService.ts +++ b/src/services/configWatcherService.ts @@ -4,7 +4,7 @@ import { config, configPath, configRemovedOptionsKeys, loadConfig, syncConfigWit import { saveConfig, shouldReloadConfig } from "./configWriterService.ts"; import { getWebPorts, startWebServer, stopWebServer } from "./webService.ts"; import { sendWsBroadcast } from "./wsService.ts"; -import varzia from "../../static/fixed_responses/worldState/varzia.json"; +import varzia from "../../static/fixed_responses/worldState/varzia.json" with { type: "json" }; chokidar.watch(configPath).on("change", () => { if (shouldReloadConfig()) { diff --git a/src/services/guildService.ts b/src/services/guildService.ts index c354717b..630f675a 100644 --- a/src/services/guildService.ts +++ b/src/services/guildService.ts @@ -33,7 +33,7 @@ import { Inbox } from "../models/inboxModel.ts"; import type { IFusionTreasure } from "../types/inventoryTypes/inventoryTypes.ts"; import type { IInventoryChanges } from "../types/purchaseTypes.ts"; import { parallelForeach } from "../utils/async-utils.ts"; -import allDecoRecipes from "../../static/fixed_responses/allDecoRecipes.json"; +import allDecoRecipes from "../../static/fixed_responses/allDecoRecipes.json" with { type: "json" }; import { createMessage } from "./inboxService.ts"; import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "./friendService.ts"; import type { ITypeCount } from "../types/commonTypes.ts"; diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index ecc0a81a..c8e25c1b 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -72,7 +72,7 @@ import { } from "../helpers/inventoryHelpers.ts"; import { addQuestKey, completeQuest } from "./questService.ts"; import { handleBundleAcqusition } from "./purchaseService.ts"; -import libraryDailyTasks from "../../static/fixed_responses/libraryDailyTasks.json"; +import libraryDailyTasks from "../../static/fixed_responses/libraryDailyTasks.json" with { type: "json" }; import { generateRewardSeed, getRandomElement, getRandomInt, getRandomWeightedReward, SRng } from "./rngService.ts"; import type { IMessageCreationTemplate } from "./inboxService.ts"; import { createMessage } from "./inboxService.ts"; diff --git a/src/services/loginRewardService.ts b/src/services/loginRewardService.ts index 21befb10..3ea615fc 100644 --- a/src/services/loginRewardService.ts +++ b/src/services/loginRewardService.ts @@ -1,4 +1,4 @@ -import randomRewards from "../../static/fixed_responses/loginRewards/randomRewards.json"; +import randomRewards from "../../static/fixed_responses/loginRewards/randomRewards.json" with { type: "json" }; import type { IInventoryChanges } from "../types/purchaseTypes.ts"; import type { TAccountDocument } from "./loginService.ts"; import { mixSeeds, SRng } from "./rngService.ts"; diff --git a/src/services/missionInventoryUpdateService.ts b/src/services/missionInventoryUpdateService.ts index c840e5d9..2498c0f6 100644 --- a/src/services/missionInventoryUpdateService.ts +++ b/src/services/missionInventoryUpdateService.ts @@ -53,10 +53,10 @@ import type { IMissionCredits, IMissionReward } from "../types/missionTypes.ts"; import { crackRelic } from "../helpers/relicHelper.ts"; import type { IMessageCreationTemplate } from "./inboxService.ts"; import { createMessage } from "./inboxService.ts"; -import kuriaMessage50 from "../../static/fixed_responses/kuriaMessages/fiftyPercent.json"; -import kuriaMessage75 from "../../static/fixed_responses/kuriaMessages/seventyFivePercent.json"; -import kuriaMessage100 from "../../static/fixed_responses/kuriaMessages/oneHundredPercent.json"; -import conservationAnimals from "../../static/fixed_responses/conservationAnimals.json"; +import kuriaMessage50 from "../../static/fixed_responses/kuriaMessages/fiftyPercent.json" with { type: "json" }; +import kuriaMessage75 from "../../static/fixed_responses/kuriaMessages/seventyFivePercent.json" with { type: "json" }; +import kuriaMessage100 from "../../static/fixed_responses/kuriaMessages/oneHundredPercent.json" with { type: "json" }; +import conservationAnimals from "../../static/fixed_responses/conservationAnimals.json" with { type: "json" }; import { generateNemesisProfile, getInfestedLichItemRewards, @@ -76,7 +76,7 @@ import { pushClassicBounties } from "./worldStateService.ts"; import { config } from "./configService.ts"; -import libraryDailyTasks from "../../static/fixed_responses/libraryDailyTasks.json"; +import libraryDailyTasks from "../../static/fixed_responses/libraryDailyTasks.json" with { type: "json" }; import type { IGoal, ISyndicateMissionInfo } from "../types/worldStateTypes.ts"; import { fromOid } from "../helpers/inventoryHelpers.ts"; import type { TAccountDocument } from "./loginService.ts"; diff --git a/src/services/questService.ts b/src/services/questService.ts index 296e2f56..f79eb131 100644 --- a/src/services/questService.ts +++ b/src/services/questService.ts @@ -10,7 +10,7 @@ import type { Types } from "mongoose"; import { ExportKeys } from "warframe-public-export-plus"; import { addFixedLevelRewards } from "./missionInventoryUpdateService.ts"; import type { IInventoryChanges } from "../types/purchaseTypes.ts"; -import questCompletionItems from "../../static/fixed_responses/questCompletionRewards.json"; +import questCompletionItems from "../../static/fixed_responses/questCompletionRewards.json" with { type: "json" }; import type { ITypeCount } from "../types/commonTypes.ts"; export interface IUpdateQuestRequest { diff --git a/src/services/worldStateService.ts b/src/services/worldStateService.ts index 49f31190..26343116 100644 --- a/src/services/worldStateService.ts +++ b/src/services/worldStateService.ts @@ -1,14 +1,14 @@ -import staticWorldState from "../../static/fixed_responses/worldState/worldState.json"; -import baro from "../../static/fixed_responses/worldState/baro.json"; -import varzia from "../../static/fixed_responses/worldState/varzia.json"; -import fissureMissions from "../../static/fixed_responses/worldState/fissureMissions.json"; -import sortieTilesets from "../../static/fixed_responses/worldState/sortieTilesets.json"; -import sortieTilesetMissions from "../../static/fixed_responses/worldState/sortieTilesetMissions.json"; -import syndicateMissions from "../../static/fixed_responses/worldState/syndicateMissions.json"; -import darvoDeals from "../../static/fixed_responses/worldState/darvoDeals.json"; -import invasionNodes from "../../static/fixed_responses/worldState/invasionNodes.json"; -import invasionRewards from "../../static/fixed_responses/worldState/invasionRewards.json"; -import pvpChallenges from "../../static/fixed_responses/worldState/pvpChallenges.json"; +import staticWorldState from "../../static/fixed_responses/worldState/worldState.json" with { type: "json" }; +import baro from "../../static/fixed_responses/worldState/baro.json" with { type: "json" }; +import varzia from "../../static/fixed_responses/worldState/varzia.json" with { type: "json" }; +import fissureMissions from "../../static/fixed_responses/worldState/fissureMissions.json" with { type: "json" }; +import sortieTilesets from "../../static/fixed_responses/worldState/sortieTilesets.json" with { type: "json" }; +import sortieTilesetMissions from "../../static/fixed_responses/worldState/sortieTilesetMissions.json" with { type: "json" }; +import syndicateMissions from "../../static/fixed_responses/worldState/syndicateMissions.json" with { type: "json" }; +import darvoDeals from "../../static/fixed_responses/worldState/darvoDeals.json" with { type: "json" }; +import invasionNodes from "../../static/fixed_responses/worldState/invasionNodes.json" with { type: "json" }; +import invasionRewards from "../../static/fixed_responses/worldState/invasionRewards.json" with { type: "json" }; +import pvpChallenges from "../../static/fixed_responses/worldState/pvpChallenges.json" with { type: "json" }; import { buildConfig } from "./buildConfigService.ts"; import { unixTimesInMs } from "../constants/timeConstants.ts"; import { config } from "./configService.ts"; diff --git a/src/services/wsService.ts b/src/services/wsService.ts index 8a8cb8c9..b80cd81e 100644 --- a/src/services/wsService.ts +++ b/src/services/wsService.ts @@ -1,22 +1,23 @@ import type http from "http"; import type https from "https"; -import ws from "ws"; +import type { default as ws } from "ws"; +import { WebSocketServer } from "ws"; import { Account } from "../models/loginModel.ts"; import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "./loginService.ts"; import type { IDatabaseAccountJson } from "../types/loginTypes.ts"; import type { HydratedDocument } from "mongoose"; import { logError } from "../utils/logger.ts"; -let wsServer: ws.Server | undefined; -let wssServer: ws.Server | undefined; +let wsServer: WebSocketServer | undefined; +let wssServer: WebSocketServer | undefined; export const startWsServer = (httpServer: http.Server): void => { - wsServer = new ws.Server({ server: httpServer }); + wsServer = new WebSocketServer({ server: httpServer }); wsServer.on("connection", wsOnConnect); }; export const startWssServer = (httpsServer: https.Server): void => { - wssServer = new ws.Server({ server: httpsServer }); + wssServer = new WebSocketServer({ server: httpsServer }); wssServer.on("connection", wsOnConnect); }; diff --git a/tsconfig.json b/tsconfig.json index 4364b46c..6bef1f6b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,7 +25,7 @@ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "node16" /* Specify what module code is generated. */, + "module": "node18" /* Specify what module code is generated. */, // "rootDir": "./", /* Specify the root folder within your source files. */ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */