Esxpose two endpoints for launcher to get mod-related data

This commit is contained in:
Dev 2023-08-10 14:29:09 +01:00
parent e591ea9e8f
commit 91ec0144ed
5 changed files with 50 additions and 2 deletions

View File

@ -88,6 +88,17 @@ class LauncherCallbacks
{
return this.httpResponse.noBody(this.launcherController.getCompatibleTarkovVersion());
}
public getLoadedServerMods(): string
{
return this.httpResponse.noBody(this.launcherController.getLoadedServerMods());
}
public getServerModsProfileUsed(url: string, info: IEmptyRequestData, sessionId: string): string
{
return this.httpResponse.noBody(this.launcherController.getServerModsProfileUsed(sessionId));
}
}
export { LauncherCallbacks };

View File

@ -1,13 +1,16 @@
import { inject, injectable } from "tsyringe";
import { HttpServerHelper } from "../helpers/HttpServerHelper";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { PreAkiModLoader } from "../loaders/PreAkiModLoader";
import { IChangeRequestData } from "../models/eft/launcher/IChangeRequestData";
import { ILoginRequestData } from "../models/eft/launcher/ILoginRequestData";
import { IRegisterData } from "../models/eft/launcher/IRegisterData";
import { Info } from "../models/eft/profile/IAkiProfile";
import { Info, ModDetails } from "../models/eft/profile/IAkiProfile";
import { IConnectResponse } from "../models/eft/profile/IConnectResponse";
import { ConfigTypes } from "../models/enums/ConfigTypes";
import { ICoreConfig } from "../models/spt/config/ICoreConfig";
import { IPackageJsonData } from "../models/spt/mod/IPackageJsonData";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { SaveServer } from "../servers/SaveServer";
@ -23,8 +26,10 @@ export class LauncherController
@inject("HashUtil") protected hashUtil: HashUtil,
@inject("SaveServer") protected saveServer: SaveServer,
@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper,
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
@inject("LocalisationService") protected localisationService: LocalisationService,
@inject("PreAkiModLoader") protected preAkiModLoader: PreAkiModLoader,
@inject("ConfigServer") protected configServer: ConfigServer
)
{
@ -160,4 +165,15 @@ export class LauncherController
{
return this.coreConfig.compatibleTarkovVersion;
}
public getLoadedServerMods(): Record<string, IPackageJsonData>
{
return this.preAkiModLoader.getImportedModDetails();
}
public getServerModsProfileUsed(sessionId: string): ModDetails[]
{
const profile = this.profileHelper.getFullProfile(sessionId);
return profile?.aki?.mods;
}
}

View File

@ -52,7 +52,7 @@ export class InRaidHelper
}
/**
* Check an array of items and add an upd object to money items with a stack count of 1
* Check items array and add an upd object to money with a stack count of 1
* Single stack money items have no upd object and thus no StackObjectsCount, causing issues
* @param items Items array to check
*/

View File

@ -99,6 +99,22 @@ export class LauncherStaticRouter extends StaticRouter
{
return this.launcherCallbacks.getServerVersion();
}
),
new RouteAction(
"/launcher/server/loadedServerMods",
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.launcherCallbacks.getLoadedServerMods();
}
),
new RouteAction(
"/launcher/server/serverModsUsedByProfile",
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.launcherCallbacks.getServerModsProfileUsed(url, info, sessionID);
}
)
]
);

View File

@ -27,6 +27,11 @@ export class HttpResponseUtil
.replace(/[\\]/g, "");
}
/**
* Return passed in data as JSON string
* @param data
* @returns
*/
public noBody(data: any): any
{
return this.clearString(this.jsonUtil.serialize(data));