forked from OpenWF/SpaceNinjaServer
chore: switch to esm, support raw running via node (#2696)
Using ESM so the `import` syntax we use is actually valid without compilation. Now, Node can run the TypeScript code directly, albeit without typechecking and requiring use of an experimental feature. Reviewed-on: OpenWF/SpaceNinjaServer#2696 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
c97c22b434
commit
1ead04ddc1
8
package-lock.json
generated
8
package-lock.json
generated
@ -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",
|
||||
|
||||
14
package.json
14
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",
|
||||
|
||||
@ -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;
|
||||
});
|
||||
@ -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";
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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";
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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, "..");
|
||||
|
||||
@ -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()) {
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
@ -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. */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user