chore: switch to esm, support raw running via node #2696

Merged
Sainan merged 3 commits from esm into main 2025-08-26 04:29:07 -07:00
21 changed files with 49 additions and 46 deletions

8
package-lock.json generated
View File

@ -23,7 +23,7 @@
"ncp": "^2.0.0", "ncp": "^2.0.0",
"typescript": "^5.7", "typescript": "^5.7",
"undici": "^7.10.0", "undici": "^7.10.0",
"warframe-public-export-plus": "^0.5.82", "warframe-public-export-plus": "^0.5.83",
"warframe-riven-info": "^0.1.2", "warframe-riven-info": "^0.1.2",
"winston": "^3.17.0", "winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0", "winston-daily-rotate-file": "^5.0.0",
@ -5507,9 +5507,9 @@
} }
}, },
"node_modules/warframe-public-export-plus": { "node_modules/warframe-public-export-plus": {
"version": "0.5.82", "version": "0.5.83",
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.82.tgz", "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.83.tgz",
"integrity": "sha512-hZa9KpMDA2wy0Hn03y9Nfyzbjxer1I6Rvb52b363uzrqS0cvDO56rhiDo71JbraeV34qF6yo+Vca1zwFmw2srA==" "integrity": "sha512-SJgw6NxQaiLgMfnKGML8mRY9lT3wJb3HEABSvuCd/XiKpUqPgqTCp7EwPhbG3D/FMtN+IZjBQgykLD5R7/MSRA=="
}, },
"node_modules/warframe-riven-info": { "node_modules/warframe-riven-info": {
"version": "0.1.2", "version": "0.1.2",

View File

@ -11,20 +11,22 @@
"build:dev:tsc": "tsc --incremental --sourceMap", "build:dev:tsc": "tsc --incremental --sourceMap",
"build-and-start": "npm run build && npm run start", "build-and-start": "npm run build && npm run start",
"build-and-start:bun": "npm run verify && npm run bun-run", "build-and-start:bun": "npm run verify && npm run bun-run",
"dev": "node scripts/dev.js", "dev": "node scripts/dev.cjs",
"dev:bun": "bun scripts/dev.js", "dev:bun": "bun scripts/dev.cjs",
"verify": "tsgo --noEmit", "verify": "tsgo --noEmit",
"verify:tsc": "tsc --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": "eslint --ext .ts .",
"lint:ci": "eslint --ext .ts --rule \"prettier/prettier: off\" .", "lint:ci": "eslint --ext .ts --rule \"prettier/prettier: off\" .",
"lint:fix": "eslint --fix --ext .ts .", "lint:fix": "eslint --fix --ext .ts .",
"prettier": "prettier --write .", "prettier": "prettier --write .",
"update-translations": "cd scripts && node update-translations.js", "update-translations": "cd scripts && node update-translations.cjs",
"fix-imports": "cd scripts && node fix-imports.js", "fix-imports": "cd scripts && node fix-imports.cjs",
"fix": "npm run update-translations && npm run fix-imports && npm run prettier" "fix": "npm run update-translations && npm run fix-imports && npm run prettier"
}, },
"license": "GNU", "license": "GNU",
"type": "module",
"dependencies": { "dependencies": {
"@types/express": "^5", "@types/express": "^5",
"@types/morgan": "^1.9.9", "@types/morgan": "^1.9.9",
@ -40,7 +42,7 @@
"ncp": "^2.0.0", "ncp": "^2.0.0",
"typescript": "^5.7", "typescript": "^5.7",
"undici": "^7.10.0", "undici": "^7.10.0",
"warframe-public-export-plus": "^0.5.82", "warframe-public-export-plus": "^0.5.83",
"warframe-riven-info": "^0.1.2", "warframe-riven-info": "^0.1.2",
"winston": "^3.17.0", "winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0", "winston-daily-rotate-file": "^5.0.0",

View File

@ -39,7 +39,7 @@ function run(changedFile) {
buildproc = undefined; buildproc = undefined;
if (code === 0) { if (code === 0) {
console.log(`${process.versions.bun ? "Verified" : "Built"} in ${Date.now() - thisbuildstart} ms`); 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.on("exit", () => {
runproc = undefined; runproc = undefined;
}); });

View File

@ -1,6 +1,6 @@
import type { RequestHandler } from "express"; import type { RequestHandler } from "express";
import { config } from "../../services/configService.ts"; 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 { getAccountIdForRequest } from "../../services/loginService.ts";
import { createGarden, getPersonalRooms } from "../../services/personalRoomsService.ts"; import { createGarden, getPersonalRooms } from "../../services/personalRoomsService.ts";
import type { IGetShipResponse, IPersonalRoomsClient } from "../../types/personalRoomsTypes.ts"; import type { IGetShipResponse, IPersonalRoomsClient } from "../../types/personalRoomsTypes.ts";

View File

@ -3,7 +3,7 @@ import { getAccountForRequest } from "../../services/loginService.ts";
import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts"; import type { TInventoryDatabaseDocument } from "../../models/inventoryModels/inventoryModel.ts";
import { Inventory } from "../../models/inventoryModels/inventoryModel.ts"; import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
import { config } from "../../services/configService.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 { ILoadoutDatabase } from "../../types/saveLoadoutTypes.ts";
import type { IInventoryClient, IShipInventory } from "../../types/inventoryTypes/inventoryTypes.ts"; import type { IInventoryClient, IShipInventory } from "../../types/inventoryTypes/inventoryTypes.ts";
import { equipmentKeys } from "../../types/inventoryTypes/inventoryTypes.ts"; import { equipmentKeys } from "../../types/inventoryTypes/inventoryTypes.ts";

View File

@ -1,6 +1,6 @@
import { getJSONfromString } from "../../helpers/stringHelpers.ts"; import { getJSONfromString } from "../../helpers/stringHelpers.ts";
import type { RequestHandler } from "express"; 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 { getAccountIdForRequest } from "../../services/loginService.ts";
import { addItem, getInventory } from "../../services/inventoryService.ts"; import { addItem, getInventory } from "../../services/inventoryService.ts";

View File

@ -21,8 +21,8 @@ import {
ExportWarframes, ExportWarframes,
ExportWeapons ExportWeapons
} from "warframe-public-export-plus"; } from "warframe-public-export-plus";
import allIncarnons from "../../../static/fixed_responses/allIncarnonList.json"; import allIncarnons from "../../../static/fixed_responses/allIncarnonList.json" with { type: "json" };
import varzia from "../../../static/fixed_responses/worldState/varzia.json"; import varzia from "../../../static/fixed_responses/worldState/varzia.json" with { type: "json" };
interface ListedItem { interface ListedItem {
uniqueName: string; uniqueName: string;

View File

@ -1,5 +1,5 @@
import type { RequestHandler } from "express"; 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) => { const aggregateSessionsController: RequestHandler = (_req, res) => {
res.json(aggregateSessions); res.json(aggregateSessions);

View File

@ -1,7 +1,7 @@
import type { RequestHandler } from "express"; import type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts"; import { getAccountIdForRequest } from "../../services/loginService.ts";
import { config } from "../../services/configService.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 { ExportEnemies } from "warframe-public-export-plus";
import { getInventory } from "../../services/inventoryService.ts"; import { getInventory } from "../../services/inventoryService.ts";
import { getStats } from "../../services/statsService.ts"; import { getStats } from "../../services/statsService.ts";

View File

@ -1,4 +1,4 @@
import path from "path"; 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, ".."); export const repoDir = path.basename(rootDir) != "build" ? rootDir : path.join(rootDir, "..");

View File

@ -4,7 +4,7 @@ import { config, configPath, configRemovedOptionsKeys, loadConfig, syncConfigWit
import { saveConfig, shouldReloadConfig } from "./configWriterService.ts"; import { saveConfig, shouldReloadConfig } from "./configWriterService.ts";
import { getWebPorts, startWebServer, stopWebServer } from "./webService.ts"; import { getWebPorts, startWebServer, stopWebServer } from "./webService.ts";
import { sendWsBroadcast } from "./wsService.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", () => { chokidar.watch(configPath).on("change", () => {
if (shouldReloadConfig()) { if (shouldReloadConfig()) {

View File

@ -33,7 +33,7 @@ import { Inbox } from "../models/inboxModel.ts";
import type { IFusionTreasure } from "../types/inventoryTypes/inventoryTypes.ts"; import type { IFusionTreasure } from "../types/inventoryTypes/inventoryTypes.ts";
import type { IInventoryChanges } from "../types/purchaseTypes.ts"; import type { IInventoryChanges } from "../types/purchaseTypes.ts";
import { parallelForeach } from "../utils/async-utils.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 { createMessage } from "./inboxService.ts";
import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "./friendService.ts"; import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "./friendService.ts";
import type { ITypeCount } from "../types/commonTypes.ts"; import type { ITypeCount } from "../types/commonTypes.ts";

View File

@ -72,7 +72,7 @@ import {
} from "../helpers/inventoryHelpers.ts"; } from "../helpers/inventoryHelpers.ts";
import { addQuestKey, completeQuest } from "./questService.ts"; import { addQuestKey, completeQuest } from "./questService.ts";
import { handleBundleAcqusition } from "./purchaseService.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 { generateRewardSeed, getRandomElement, getRandomInt, getRandomWeightedReward, SRng } from "./rngService.ts";
import type { IMessageCreationTemplate } from "./inboxService.ts"; import type { IMessageCreationTemplate } from "./inboxService.ts";
import { createMessage } from "./inboxService.ts"; import { createMessage } from "./inboxService.ts";

View File

@ -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 { IInventoryChanges } from "../types/purchaseTypes.ts";
import type { TAccountDocument } from "./loginService.ts"; import type { TAccountDocument } from "./loginService.ts";
import { mixSeeds, SRng } from "./rngService.ts"; import { mixSeeds, SRng } from "./rngService.ts";

View File

@ -53,10 +53,10 @@ import type { IMissionCredits, IMissionReward } from "../types/missionTypes.ts";
import { crackRelic } from "../helpers/relicHelper.ts"; import { crackRelic } from "../helpers/relicHelper.ts";
import type { IMessageCreationTemplate } from "./inboxService.ts"; import type { IMessageCreationTemplate } from "./inboxService.ts";
import { createMessage } from "./inboxService.ts"; import { createMessage } from "./inboxService.ts";
import kuriaMessage50 from "../../static/fixed_responses/kuriaMessages/fiftyPercent.json"; import kuriaMessage50 from "../../static/fixed_responses/kuriaMessages/fiftyPercent.json" with { type: "json" };
import kuriaMessage75 from "../../static/fixed_responses/kuriaMessages/seventyFivePercent.json"; import kuriaMessage75 from "../../static/fixed_responses/kuriaMessages/seventyFivePercent.json" with { type: "json" };
import kuriaMessage100 from "../../static/fixed_responses/kuriaMessages/oneHundredPercent.json"; import kuriaMessage100 from "../../static/fixed_responses/kuriaMessages/oneHundredPercent.json" with { type: "json" };
import conservationAnimals from "../../static/fixed_responses/conservationAnimals.json"; import conservationAnimals from "../../static/fixed_responses/conservationAnimals.json" with { type: "json" };
import { import {
generateNemesisProfile, generateNemesisProfile,
getInfestedLichItemRewards, getInfestedLichItemRewards,
@ -76,7 +76,7 @@ import {
pushClassicBounties pushClassicBounties
} from "./worldStateService.ts"; } from "./worldStateService.ts";
import { config } from "./configService.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 type { IGoal, ISyndicateMissionInfo } from "../types/worldStateTypes.ts";
import { fromOid } from "../helpers/inventoryHelpers.ts"; import { fromOid } from "../helpers/inventoryHelpers.ts";
import type { TAccountDocument } from "./loginService.ts"; import type { TAccountDocument } from "./loginService.ts";

View File

@ -10,7 +10,7 @@ import type { Types } from "mongoose";
import { ExportKeys } from "warframe-public-export-plus"; import { ExportKeys } from "warframe-public-export-plus";
import { addFixedLevelRewards } from "./missionInventoryUpdateService.ts"; import { addFixedLevelRewards } from "./missionInventoryUpdateService.ts";
import type { IInventoryChanges } from "../types/purchaseTypes.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"; import type { ITypeCount } from "../types/commonTypes.ts";
export interface IUpdateQuestRequest { export interface IUpdateQuestRequest {

View File

@ -1,14 +1,14 @@
import staticWorldState from "../../static/fixed_responses/worldState/worldState.json"; import staticWorldState from "../../static/fixed_responses/worldState/worldState.json" with { type: "json" };
import baro from "../../static/fixed_responses/worldState/baro.json"; import baro from "../../static/fixed_responses/worldState/baro.json" with { type: "json" };
import varzia from "../../static/fixed_responses/worldState/varzia.json"; import varzia from "../../static/fixed_responses/worldState/varzia.json" with { type: "json" };
import fissureMissions from "../../static/fixed_responses/worldState/fissureMissions.json"; import fissureMissions from "../../static/fixed_responses/worldState/fissureMissions.json" with { type: "json" };
import sortieTilesets from "../../static/fixed_responses/worldState/sortieTilesets.json"; import sortieTilesets from "../../static/fixed_responses/worldState/sortieTilesets.json" with { type: "json" };
import sortieTilesetMissions from "../../static/fixed_responses/worldState/sortieTilesetMissions.json"; import sortieTilesetMissions from "../../static/fixed_responses/worldState/sortieTilesetMissions.json" with { type: "json" };
import syndicateMissions from "../../static/fixed_responses/worldState/syndicateMissions.json"; import syndicateMissions from "../../static/fixed_responses/worldState/syndicateMissions.json" with { type: "json" };
import darvoDeals from "../../static/fixed_responses/worldState/darvoDeals.json"; import darvoDeals from "../../static/fixed_responses/worldState/darvoDeals.json" with { type: "json" };
import invasionNodes from "../../static/fixed_responses/worldState/invasionNodes.json"; import invasionNodes from "../../static/fixed_responses/worldState/invasionNodes.json" with { type: "json" };
import invasionRewards from "../../static/fixed_responses/worldState/invasionRewards.json"; import invasionRewards from "../../static/fixed_responses/worldState/invasionRewards.json" with { type: "json" };
import pvpChallenges from "../../static/fixed_responses/worldState/pvpChallenges.json"; import pvpChallenges from "../../static/fixed_responses/worldState/pvpChallenges.json" with { type: "json" };
import { buildConfig } from "./buildConfigService.ts"; import { buildConfig } from "./buildConfigService.ts";
import { unixTimesInMs } from "../constants/timeConstants.ts"; import { unixTimesInMs } from "../constants/timeConstants.ts";
import { config } from "./configService.ts"; import { config } from "./configService.ts";

View File

@ -1,22 +1,23 @@
import type http from "http"; import type http from "http";
import type https from "https"; 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 { Account } from "../models/loginModel.ts";
import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "./loginService.ts"; import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "./loginService.ts";
import type { IDatabaseAccountJson } from "../types/loginTypes.ts"; import type { IDatabaseAccountJson } from "../types/loginTypes.ts";
import type { HydratedDocument } from "mongoose"; import type { HydratedDocument } from "mongoose";
import { logError } from "../utils/logger.ts"; import { logError } from "../utils/logger.ts";
let wsServer: ws.Server | undefined; let wsServer: WebSocketServer | undefined;
let wssServer: ws.Server | undefined; let wssServer: WebSocketServer | undefined;
export const startWsServer = (httpServer: http.Server): void => { export const startWsServer = (httpServer: http.Server): void => {
wsServer = new ws.Server({ server: httpServer }); wsServer = new WebSocketServer({ server: httpServer });
wsServer.on("connection", wsOnConnect); wsServer.on("connection", wsOnConnect);
}; };
export const startWssServer = (httpsServer: https.Server): void => { export const startWssServer = (httpsServer: https.Server): void => {
wssServer = new ws.Server({ server: httpsServer }); wssServer = new WebSocketServer({ server: httpsServer });
wssServer.on("connection", wsOnConnect); wssServer.on("connection", wsOnConnect);
}; };

View File

@ -25,7 +25,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */ /* 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. */ // "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ // "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. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */