First iteration of async work on callbacks (!311)

Co-authored-by: clodan <clodan@clodan.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/311
Co-authored-by: Alex <clodan@noreply.dev.sp-tarkov.com>
Co-committed-by: Alex <clodan@noreply.dev.sp-tarkov.com>
This commit is contained in:
Alex 2024-04-28 13:45:36 +00:00 committed by chomp
parent 44583f40ac
commit 2172c29640
51 changed files with 1038 additions and 364 deletions

View File

@ -58,13 +58,13 @@ export class BotCallbacks
* Handle client/game/bot/generate * Handle client/game/bot/generate
* @returns IGetBodyResponseData * @returns IGetBodyResponseData
*/ */
public generateBots( public async generateBots(
url: string, url: string,
info: IGenerateBotsRequestData, info: IGenerateBotsRequestData,
sessionID: string, sessionID: string,
): IGetBodyResponseData<IBotBase[]> ): Promise<IGetBodyResponseData<IBotBase[]>>
{ {
return this.httpResponse.getBody(this.botController.generate(sessionID, info)); return this.httpResponse.getBody(await this.botController.generate(sessionID, info));
} }
/** /**

View File

@ -17,13 +17,13 @@ export class ItemEventCallbacks
) )
{} {}
public handleEvents( public async handleEvents(
url: string, url: string,
info: IItemEventRouterRequest, info: IItemEventRouterRequest,
sessionID: string, sessionID: string,
): IGetBodyResponseData<IItemEventRouterResponse> ): Promise<IGetBodyResponseData<IItemEventRouterResponse>>
{ {
const eventResponse = this.itemEventRouter.handleEvents(info, sessionID); const eventResponse = await this.itemEventRouter.handleEvents(info, sessionID);
const result = (this.isCriticalError(eventResponse.warnings)) const result = (this.isCriticalError(eventResponse.warnings))
? this.httpResponse.getBody( ? this.httpResponse.getBody(
eventResponse, eventResponse,

View File

@ -6,7 +6,7 @@ import { BotGenerator } from "@spt-aki/generators/BotGenerator";
import { BotDifficultyHelper } from "@spt-aki/helpers/BotDifficultyHelper"; import { BotDifficultyHelper } from "@spt-aki/helpers/BotDifficultyHelper";
import { BotHelper } from "@spt-aki/helpers/BotHelper"; import { BotHelper } from "@spt-aki/helpers/BotHelper";
import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper";
import { IGenerateBotsRequestData } from "@spt-aki/models/eft/bot/IGenerateBotsRequestData"; import { Condition, IGenerateBotsRequestData } from "@spt-aki/models/eft/bot/IGenerateBotsRequestData";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { IBotBase } from "@spt-aki/models/eft/common/tables/IBotBase"; import { IBotBase } from "@spt-aki/models/eft/common/tables/IBotBase";
import { IBotCore } from "@spt-aki/models/eft/common/tables/IBotCore"; import { IBotCore } from "@spt-aki/models/eft/common/tables/IBotCore";
@ -179,7 +179,7 @@ export class BotController
* @param info bot generation request info * @param info bot generation request info
* @returns IBotBase array * @returns IBotBase array
*/ */
public generate(sessionId: string, info: IGenerateBotsRequestData): IBotBase[] public async generate(sessionId: string, info: IGenerateBotsRequestData): Promise<IBotBase[]>
{ {
const pmcProfile = this.profileHelper.getPmcProfile(sessionId); const pmcProfile = this.profileHelper.getPmcProfile(sessionId);
@ -199,11 +199,11 @@ export class BotController
* @param sessionId Session id * @param sessionId Session id
* @returns * @returns
*/ */
protected generateBotsFirstTime( protected async generateBotsFirstTime(
request: IGenerateBotsRequestData, request: IGenerateBotsRequestData,
pmcProfile: IPmcData, pmcProfile: IPmcData,
sessionId: string, sessionId: string,
): IBotBase[] ): Promise<IBotBase[]>
{ {
// Clear bot cache before any work starts // Clear bot cache before any work starts
this.botGenerationCacheService.clearStoredBots(); this.botGenerationCacheService.clearStoredBots();
@ -211,6 +211,7 @@ export class BotController
const allPmcsHaveSameNameAsPlayer = this.randomUtil.getChance100( const allPmcsHaveSameNameAsPlayer = this.randomUtil.getChance100(
this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance, this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance,
); );
const conditionPromises: Promise<void>[] = [];
for (const condition of request.conditions) for (const condition of request.conditions)
{ {
const botGenerationDetails: BotGenerationDetails = { const botGenerationDetails: BotGenerationDetails = {
@ -227,45 +228,80 @@ export class BotController
allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer, allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer,
}; };
// Event bots need special actions to occur, set data up for them conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId));
const isEventBot = condition.Role.toLowerCase().includes("event"); }
if (isEventBot)
{
// Add eventRole data + reassign role property to be base type
botGenerationDetails.eventRole = condition.Role;
botGenerationDetails.role = this.seasonalEventService.getBaseRoleForEventBot(
botGenerationDetails.eventRole,
);
}
// Custom map waves can have spt roles in them await Promise.all(conditionPromises).then((p) => Promise.all(p));
// Is bot type sptusec/sptbear, set is pmc true and set side
if (this.botHelper.botRoleIsPmc(condition.Role))
{
botGenerationDetails.isPmc = true;
botGenerationDetails.side = this.botHelper.getPmcSideByRole(condition.Role);
}
// Loop over and make x bots for this bot wave return [];
const cacheKey = `${ }
botGenerationDetails.eventRole ?? botGenerationDetails.role
}${botGenerationDetails.botDifficulty}`;
for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++)
{
// Generate and add bot to cache
const detailsClone = this.jsonUtil.clone(botGenerationDetails);
const botToCache = this.botGenerator.prepareAndGenerateBot(sessionId, detailsClone);
this.botGenerationCacheService.storeBots(cacheKey, [botToCache]);
}
/**
* Generate many bots and store then on the cache
* @param condition the condition details to generate the bots with
* @param botGenerationDetails the bot details to generate the bot with
* @param sessionId Session id
* @returns A promise for the bots to be done generating
*/
protected async generateWithBotDetails(
condition: Condition,
botGenerationDetails: BotGenerationDetails,
sessionId: string,
): Promise<void>
{
const isEventBot = condition.Role.toLowerCase().includes("event");
if (isEventBot)
{
// Add eventRole data + reassign role property to be base type
botGenerationDetails.eventRole = condition.Role;
botGenerationDetails.role = this.seasonalEventService.getBaseRoleForEventBot(
botGenerationDetails.eventRole,
);
}
// Custom map waves can have spt roles in them
// Is bot type sptusec/sptbear, set is pmc true and set side
if (this.botHelper.botRoleIsPmc(condition.Role))
{
botGenerationDetails.isPmc = true;
botGenerationDetails.side = this.botHelper.getPmcSideByRole(condition.Role);
}
// Loop over and make x bots for this bot wave
const cacheKey = `${
botGenerationDetails.eventRole ?? botGenerationDetails.role
}${botGenerationDetails.botDifficulty}`;
const botPromises: Promise<void>[] = [];
for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++)
{
const detailsClone = this.jsonUtil.clone(botGenerationDetails);
botPromises.push(this.generateSingleBotAndStoreInCache(detailsClone, sessionId, cacheKey));
}
return Promise.all(botPromises).then(() =>
{
this.logger.debug( this.logger.debug(
`Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${ `Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${
botGenerationDetails.eventRole ?? "" botGenerationDetails.eventRole ?? ""
}) ${botGenerationDetails.botDifficulty} bots`, }) ${botGenerationDetails.botDifficulty} bots`,
); );
} });
}
return []; /**
* Generate a single bot and store it in the cache
* @param botGenerationDetails the bot details to generate the bot with
* @param sessionId Session id
* @param cacheKey the cache key to store the bot with
* @returns A promise for the bot to be stored
*/
protected async generateSingleBotAndStoreInCache(
botGenerationDetails: BotGenerationDetails,
sessionId: string,
cacheKey: string,
): Promise<void>
{
const botToCache = this.botGenerator.prepareAndGenerateBot(sessionId, botGenerationDetails);
this.botGenerationCacheService.storeBots(cacheKey, [botToCache]);
} }
/** /**
@ -274,7 +310,7 @@ export class BotController
* @param request Bot generation request object * @param request Bot generation request object
* @returns Single IBotBase object * @returns Single IBotBase object
*/ */
protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): IBotBase[] protected async returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise<IBotBase[]>
{ {
const pmcProfile = this.profileHelper.getPmcProfile(sessionId); const pmcProfile = this.profileHelper.getPmcProfile(sessionId);
const requestedBot = request.conditions[0]; const requestedBot = request.conditions[0];
@ -334,18 +370,21 @@ export class BotController
// Check cache for bot using above key // Check cache for bot using above key
if (!this.botGenerationCacheService.cacheHasBotOfRole(cacheKey)) if (!this.botGenerationCacheService.cacheHasBotOfRole(cacheKey))
{ {
const botPromises: Promise<void>[] = [];
// No bot in cache, generate new and return one // No bot in cache, generate new and return one
for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++) for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++)
{ {
const botToCache = this.botGenerator.prepareAndGenerateBot(sessionId, botGenerationDetails); botPromises.push(this.generateSingleBotAndStoreInCache(botGenerationDetails, sessionId, cacheKey));
this.botGenerationCacheService.storeBots(cacheKey, [botToCache]);
} }
this.logger.debug( await Promise.all(botPromises).then(() =>
`Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${ {
botGenerationDetails.eventRole ?? "" this.logger.debug(
}) ${botGenerationDetails.botDifficulty} bots`, `Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${
); botGenerationDetails.eventRole ?? ""
}) ${botGenerationDetails.botDifficulty} bots`,
);
});
} }
const desiredBot = this.botGenerationCacheService.getBot(cacheKey); const desiredBot = this.botGenerationCacheService.getBot(cacheKey);

View File

@ -42,7 +42,7 @@ export class StaticRouter extends Router
super(); super();
} }
public handleStatic(url: string, info: any, sessionID: string, output: string): any public async handleStatic(url: string, info: any, sessionID: string, output: string): Promise<any>
{ {
return this.routes.find((route) => route.url === url).action(url, info, sessionID, output); return this.routes.find((route) => route.url === url).action(url, info, sessionID, output);
} }
@ -60,7 +60,7 @@ export class DynamicRouter extends Router
super(); super();
} }
public handleDynamic(url: string, info: any, sessionID: string, output: string): any public async handleDynamic(url: string, info: any, sessionID: string, output: string): Promise<any>
{ {
return this.routes.find((r) => url.includes(r.url)).action(url, info, sessionID, output); return this.routes.find((r) => url.includes(r.url)).action(url, info, sessionID, output);
} }
@ -75,13 +75,13 @@ export class DynamicRouter extends Router
// So instead I added the definition // So instead I added the definition
export class ItemEventRouterDefinition extends Router export class ItemEventRouterDefinition extends Router
{ {
public handleItemEvent( public async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): void ): Promise<any>
{ {
throw new Error("This method needs to be overrode by the router classes"); throw new Error("This method needs to be overrode by the router classes");
} }
@ -103,6 +103,9 @@ export class HandledRoute
export class RouteAction export class RouteAction
{ {
constructor(public url: string, public action: (url: string, info: any, sessionID: string, output: string) => any) constructor(
public url: string,
public action: (url: string, info: any, sessionID: string, output: string) => Promise<any>,
)
{} {}
} }

View File

@ -31,7 +31,7 @@ export class HttpRouter
return map; return map;
} }
public getResponse(req: IncomingMessage, info: any, sessionID: string): string public async getResponse(req: IncomingMessage, info: any, sessionID: string): Promise<string>
{ {
const wrapper: ResponseWrapper = new ResponseWrapper(""); const wrapper: ResponseWrapper = new ResponseWrapper("");
let url = req.url; let url = req.url;
@ -41,10 +41,10 @@ export class HttpRouter
{ {
url = url.split("?retry=")[0]; url = url.split("?retry=")[0];
} }
const handled = this.handleRoute(url, info, sessionID, wrapper, this.staticRouters, false); const handled = await this.handleRoute(url, info, sessionID, wrapper, this.staticRouters, false);
if (!handled) if (!handled)
{ {
this.handleRoute(url, info, sessionID, wrapper, this.dynamicRoutes, true); await this.handleRoute(url, info, sessionID, wrapper, this.dynamicRoutes, true);
} }
// TODO: Temporary hack to change ItemEventRouter response sessionID binding to what client expects // TODO: Temporary hack to change ItemEventRouter response sessionID binding to what client expects
@ -56,14 +56,14 @@ export class HttpRouter
return wrapper.output; return wrapper.output;
} }
protected handleRoute( protected async handleRoute(
url: string, url: string,
info: any, info: any,
sessionID: string, sessionID: string,
wrapper: ResponseWrapper, wrapper: ResponseWrapper,
routers: Router[], routers: Router[],
dynamic: boolean, dynamic: boolean,
): boolean ): Promise<boolean>
{ {
let matched = false; let matched = false;
for (const route of routers) for (const route of routers)
@ -72,11 +72,11 @@ export class HttpRouter
{ {
if (dynamic) if (dynamic)
{ {
wrapper.output = (route as DynamicRouter).handleDynamic(url, info, sessionID, wrapper.output); wrapper.output = await (route as DynamicRouter).handleDynamic(url, info, sessionID, wrapper.output);
} }
else else
{ {
wrapper.output = (route as StaticRouter).handleStatic(url, info, sessionID, wrapper.output); wrapper.output = await (route as StaticRouter).handleStatic(url, info, sessionID, wrapper.output);
} }
matched = true; matched = true;
} }

View File

@ -27,7 +27,7 @@ export class ItemEventRouter
* @param sessionID Session id * @param sessionID Session id
* @returns Item response * @returns Item response
*/ */
public handleEvents(info: IItemEventRouterRequest, sessionID: string): IItemEventRouterResponse public async handleEvents(info: IItemEventRouterRequest, sessionID: string): Promise<IItemEventRouterResponse>
{ {
const output = this.eventOutputHolder.getOutput(sessionID); const output = this.eventOutputHolder.getOutput(sessionID);
@ -39,7 +39,7 @@ export class ItemEventRouter
if (eventRouter) if (eventRouter)
{ {
this.logger.debug(`event: ${body.Action}`); this.logger.debug(`event: ${body.Action}`);
eventRouter.handleItemEvent(body.Action, pmcData, body, sessionID, output); await eventRouter.handleItemEvent(body.Action, pmcData, body, sessionID, output);
if (output.warnings.length > 0) if (output.warnings.length > 0)
{ {
break; break;

View File

@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe";
import { BotCallbacks } from "@spt-aki/callbacks/BotCallbacks"; import { BotCallbacks } from "@spt-aki/callbacks/BotCallbacks";
import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
import { Difficulties } from "@spt-aki/models/eft/common/tables/IBotType";
@injectable() @injectable()
export class BotDynamicRouter extends DynamicRouter export class BotDynamicRouter extends DynamicRouter
@ -11,35 +12,45 @@ export class BotDynamicRouter extends DynamicRouter
super([ super([
new RouteAction( new RouteAction(
"/singleplayer/settings/bot/limit/", "/singleplayer/settings/bot/limit/",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.botCallbacks.getBotLimit(url, info, sessionID); return this.botCallbacks.getBotLimit(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/settings/bot/difficulty/", "/singleplayer/settings/bot/difficulty/",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.botCallbacks.getBotDifficulty(url, info, sessionID); return this.botCallbacks.getBotDifficulty(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
<<<<<<< HEAD
"/singleplayer/settings/bot/difficulties/",
async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<Record<string, Difficulties>> =>
=======
"/singleplayer/settings/bot/difficulties", "/singleplayer/settings/bot/difficulties",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
>>>>>>> 3.9.0-DEV
{ {
return this.botCallbacks.getAllBotDifficulties(url, info, sessionID); return this.botCallbacks.getAllBotDifficulties(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/settings/bot/maxCap", "/singleplayer/settings/bot/maxCap",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.botCallbacks.getBotCap(); return this.botCallbacks.getBotCap();
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/settings/bot/getBotBehaviours/", "/singleplayer/settings/bot/getBotBehaviours/",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.botCallbacks.getBotBehaviours(); return this.botCallbacks.getBotBehaviours();
}, },

View File

@ -9,10 +9,13 @@ export class BundleDynamicRouter extends DynamicRouter
constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks) constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks)
{ {
super([ super([
new RouteAction(".bundle", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ ".bundle",
return this.bundleCallbacks.getBundle(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
}), {
return this.bundleCallbacks.getBundle(url, info, sessionID);
},
),
]); ]);
} }
} }

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { CustomizationCallbacks } from "@spt-aki/callbacks/CustomizationCallbacks"; import { CustomizationCallbacks } from "@spt-aki/callbacks/CustomizationCallbacks";
import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
import { ISuit } from "@spt-aki/models/eft/common/tables/ITrader";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class CustomizationDynamicRouter extends DynamicRouter export class CustomizationDynamicRouter extends DynamicRouter
@ -11,7 +13,12 @@ export class CustomizationDynamicRouter extends DynamicRouter
super([ super([
new RouteAction( new RouteAction(
"/client/trading/customization/", "/client/trading/customization/",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ISuit[]>> =>
{ {
return this.customizationCallbacks.getTraderSuits(url, info, sessionID); return this.customizationCallbacks.getTraderSuits(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { DataCallbacks } from "@spt-aki/callbacks/DataCallbacks"; import { DataCallbacks } from "@spt-aki/callbacks/DataCallbacks";
import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
import { IGetItemPricesResponse } from "@spt-aki/models/eft/game/IGetItemPricesResponse";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class DataDynamicRouter extends DynamicRouter export class DataDynamicRouter extends DynamicRouter
@ -9,18 +11,37 @@ export class DataDynamicRouter extends DynamicRouter
constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks) constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks)
{ {
super([ super([
new RouteAction("/client/menu/locale/", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/menu/locale/",
return this.dataCallbacks.getLocalesMenu(url, info, sessionID); async (
}), url: string,
new RouteAction("/client/locale/", (url: string, info: any, sessionID: string, output: string): any => info: any,
{ sessionID: string,
return this.dataCallbacks.getLocalesGlobal(url, info, sessionID); output: string,
}), ): Promise<IGetBodyResponseData<string>> =>
new RouteAction("/client/items/prices/", (url: string, info: any, sessionID: string, output: string): any => {
{ return this.dataCallbacks.getLocalesMenu(url, info, sessionID);
return this.dataCallbacks.getItemPrices(url, info, sessionID); },
}), ),
new RouteAction(
"/client/locale/",
async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{
return this.dataCallbacks.getLocalesGlobal(url, info, sessionID);
},
),
new RouteAction(
"/client/items/prices/",
async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetItemPricesResponse>> =>
{
return this.dataCallbacks.getItemPrices(url, info, sessionID);
},
),
]); ]);
} }
} }

View File

@ -9,18 +9,27 @@ export class HttpDynamicRouter extends DynamicRouter
constructor(@inject("ImageRouter") protected imageRouter: ImageRouter) constructor(@inject("ImageRouter") protected imageRouter: ImageRouter)
{ {
super([ super([
new RouteAction(".jpg", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ ".jpg",
return this.imageRouter.getImage(); async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
}), {
new RouteAction(".png", (url: string, info: any, sessionID: string, output: string): any => return this.imageRouter.getImage();
{ },
return this.imageRouter.getImage(); ),
}), new RouteAction(
new RouteAction(".ico", (url: string, info: any, sessionID: string, output: string): any => ".png",
{ async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
return this.imageRouter.getImage(); {
}), return this.imageRouter.getImage();
},
),
new RouteAction(
".ico",
async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{
return this.imageRouter.getImage();
},
),
]); ]);
} }
} }

View File

@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe";
import { InraidCallbacks } from "@spt-aki/callbacks/InraidCallbacks"; import { InraidCallbacks } from "@spt-aki/callbacks/InraidCallbacks";
import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
@injectable() @injectable()
export class InraidDynamicRouter extends DynamicRouter export class InraidDynamicRouter extends DynamicRouter
@ -11,14 +12,14 @@ export class InraidDynamicRouter extends DynamicRouter
super([ super([
new RouteAction( new RouteAction(
"/client/location/getLocalloot", "/client/location/getLocalloot",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.inraidCallbacks.registerPlayer(url, info, sessionID); return this.inraidCallbacks.registerPlayer(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/traderServices/getTraderServices/", "/singleplayer/traderServices/getTraderServices/",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.inraidCallbacks.getTraderServices(url, info, sessionID); return this.inraidCallbacks.getTraderServices(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { LocationCallbacks } from "@spt-aki/callbacks/LocationCallbacks"; import { LocationCallbacks } from "@spt-aki/callbacks/LocationCallbacks";
import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
import { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class LocationDynamicRouter extends DynamicRouter export class LocationDynamicRouter extends DynamicRouter
@ -11,7 +13,12 @@ export class LocationDynamicRouter extends DynamicRouter
super([ super([
new RouteAction( new RouteAction(
"/client/location/getLocalloot", "/client/location/getLocalloot",
(url: string, info: any, sessionID: string, _output: string): any => async (
url: string,
info: any,
sessionID: string,
_output: string,
): Promise<IGetBodyResponseData<ILocationBase>> =>
{ {
return this.locationCallbacks.getLocation(url, info, sessionID); return this.locationCallbacks.getLocation(url, info, sessionID);
}, },

View File

@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe";
import { NotifierCallbacks } from "@spt-aki/callbacks/NotifierCallbacks"; import { NotifierCallbacks } from "@spt-aki/callbacks/NotifierCallbacks";
import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class NotifierDynamicRouter extends DynamicRouter export class NotifierDynamicRouter extends DynamicRouter
@ -9,21 +10,40 @@ export class NotifierDynamicRouter extends DynamicRouter
constructor(@inject("NotifierCallbacks") protected notifierCallbacks: NotifierCallbacks) constructor(@inject("NotifierCallbacks") protected notifierCallbacks: NotifierCallbacks)
{ {
super([ super([
new RouteAction("/?last_id", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/?last_id",
return this.notifierCallbacks.notify(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
}), {
new RouteAction("/notifierServer", (url: string, info: any, sessionID: string, output: string): any => return this.notifierCallbacks.notify(url, info, sessionID);
{ },
return this.notifierCallbacks.notify(url, info, sessionID); ),
}), new RouteAction(
new RouteAction("/push/notifier/get/", (url: string, info: any, sessionID: string, output: string): any => "/notifierServer",
{ async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
return this.notifierCallbacks.getNotifier(url, info, sessionID); {
}), return this.notifierCallbacks.notify(url, info, sessionID);
},
),
new RouteAction(
"/push/notifier/get/",
async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{
return this.notifierCallbacks.getNotifier(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/push/notifier/getwebsocket/", "/push/notifier/getwebsocket/",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.notifierCallbacks.getNotifier(url, info, sessionID); return this.notifierCallbacks.getNotifier(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { TraderCallbacks } from "@spt-aki/callbacks/TraderCallbacks"; import { TraderCallbacks } from "@spt-aki/callbacks/TraderCallbacks";
import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
import { ITraderAssort, ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class TraderDynamicRouter extends DynamicRouter export class TraderDynamicRouter extends DynamicRouter
@ -11,14 +13,24 @@ export class TraderDynamicRouter extends DynamicRouter
super([ super([
new RouteAction( new RouteAction(
"/client/trading/api/getTrader/", "/client/trading/api/getTrader/",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ITraderBase>> =>
{ {
return this.traderCallbacks.getTrader(url, info, sessionID); return this.traderCallbacks.getTrader(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/trading/api/getTraderAssort/", "/client/trading/api/getTraderAssort/",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ITraderAssort>> =>
{ {
return this.traderCallbacks.getAssort(url, info, sessionID); return this.traderCallbacks.getAssort(url, info, sessionID);
}, },

View File

@ -20,12 +20,12 @@ export class CustomizationItemEventRouter extends ItemEventRouterDefinition
return [new HandledRoute("CustomizationWear", false), new HandledRoute("CustomizationBuy", false)]; return [new HandledRoute("CustomizationWear", false), new HandledRoute("CustomizationBuy", false)];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -24,12 +24,12 @@ export class HealthItemEventRouter extends ItemEventRouterDefinition
]; ];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -32,13 +32,13 @@ export class HideoutItemEventRouter extends ItemEventRouterDefinition
]; ];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -20,12 +20,12 @@ export class InsuranceItemEventRouter extends ItemEventRouterDefinition
return [new HandledRoute("Insure", false)]; return [new HandledRoute("Insure", false)];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -46,13 +46,13 @@ export class InventoryItemEventRouter extends ItemEventRouterDefinition
]; ];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
output: IItemEventRouterResponse, output: IItemEventRouterResponse,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -25,12 +25,12 @@ export class NoteItemEventRouter extends ItemEventRouterDefinition
]; ];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: INoteActionData, body: INoteActionData,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -27,12 +27,12 @@ export class QuestItemEventRouter extends ItemEventRouterDefinition
]; ];
} }
public override handleItemEvent( public override async handleItemEvent(
eventAction: string, eventAction: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
this.logger.debug(`${eventAction} ${body.qid}`); this.logger.debug(`${eventAction} ${body.qid}`);
switch (eventAction) switch (eventAction)

View File

@ -22,12 +22,12 @@ export class RagfairItemEventRouter extends ItemEventRouterDefinition
]; ];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -18,12 +18,12 @@ export class RepairItemEventRouter extends ItemEventRouterDefinition
return [new HandledRoute("Repair", false), new HandledRoute("TraderRepair", false)]; return [new HandledRoute("Repair", false), new HandledRoute("TraderRepair", false)];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -22,12 +22,12 @@ export class TradeItemEventRouter extends ItemEventRouterDefinition
]; ];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -18,12 +18,12 @@ export class WishlistItemEventRouter extends ItemEventRouterDefinition
return [new HandledRoute("AddToWishList", false), new HandledRoute("RemoveFromWishList", false)]; return [new HandledRoute("AddToWishList", false), new HandledRoute("RemoveFromWishList", false)];
} }
public override handleItemEvent( public override async handleItemEvent(
url: string, url: string,
pmcData: IPmcData, pmcData: IPmcData,
body: any, body: any,
sessionID: string, sessionID: string,
): IItemEventRouterResponse ): Promise<IItemEventRouterResponse>
{ {
switch (url) switch (url)
{ {

View File

@ -2,6 +2,9 @@ import { inject, injectable } from "tsyringe";
import { AchievementCallbacks } from "@spt-aki/callbacks/AchievementCallbacks"; import { AchievementCallbacks } from "@spt-aki/callbacks/AchievementCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { ICompletedAchievementsResponse } from "@spt-aki/models/eft/profile/ICompletedAchievementsResponse";
import { IGetAchievementsResponse } from "@spt-aki/models/eft/profile/IGetAchievementsResponse";
@injectable() @injectable()
export class AchievementStaticRouter extends StaticRouter export class AchievementStaticRouter extends StaticRouter
@ -12,7 +15,12 @@ export class AchievementStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/achievement/list", "/client/achievement/list",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetAchievementsResponse>> =>
{ {
return this.achievementCallbacks.getAchievements(url, info, sessionID); return this.achievementCallbacks.getAchievements(url, info, sessionID);
}, },
@ -21,7 +29,12 @@ export class AchievementStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/achievement/statistic", "/client/achievement/statistic",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ICompletedAchievementsResponse>> =>
{ {
return this.achievementCallbacks.statistic(url, info, sessionID); return this.achievementCallbacks.statistic(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { BotCallbacks } from "@spt-aki/callbacks/BotCallbacks"; import { BotCallbacks } from "@spt-aki/callbacks/BotCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IBotBase } from "@spt-aki/models/eft/common/tables/IBotBase";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class BotStaticRouter extends StaticRouter export class BotStaticRouter extends StaticRouter
@ -11,7 +13,12 @@ export class BotStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/game/bot/generate", "/client/game/bot/generate",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IBotBase[]>> =>
{ {
return this.botCallbacks.generateBots(url, info, sessionID); return this.botCallbacks.generateBots(url, info, sessionID);
}, },

View File

@ -2,6 +2,9 @@ import { inject, injectable } from "tsyringe";
import { BuildsCallbacks } from "@spt-aki/callbacks/BuildsCallbacks"; import { BuildsCallbacks } from "@spt-aki/callbacks/BuildsCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
import { IUserBuilds } from "@spt-aki/models/eft/profile/IAkiProfile";
@injectable() @injectable()
export class BuildsStaticRouter extends StaticRouter export class BuildsStaticRouter extends StaticRouter
@ -12,7 +15,12 @@ export class BuildsStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/builds/list", "/client/builds/list",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IUserBuilds>> =>
{ {
return this.buildsCallbacks.getBuilds(url, info, sessionID); return this.buildsCallbacks.getBuilds(url, info, sessionID);
}, },
@ -20,7 +28,7 @@ export class BuildsStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/builds/magazine/save", "/client/builds/magazine/save",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.buildsCallbacks.createMagazineTemplate(url, info, sessionID); return this.buildsCallbacks.createMagazineTemplate(url, info, sessionID);
}, },
@ -28,7 +36,7 @@ export class BuildsStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/builds/weapon/save", "/client/builds/weapon/save",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.buildsCallbacks.setWeapon(url, info, sessionID); return this.buildsCallbacks.setWeapon(url, info, sessionID);
}, },
@ -36,7 +44,7 @@ export class BuildsStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/builds/equipment/save", "/client/builds/equipment/save",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.buildsCallbacks.setEquipment(url, info, sessionID); return this.buildsCallbacks.setEquipment(url, info, sessionID);
}, },
@ -44,7 +52,7 @@ export class BuildsStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/builds/delete", "/client/builds/delete",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.buildsCallbacks.deleteBuild(url, info, sessionID); return this.buildsCallbacks.deleteBuild(url, info, sessionID);
}, },

View File

@ -9,10 +9,13 @@ export class BundleStaticRouter extends StaticRouter
constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks) constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks)
{ {
super([ super([
new RouteAction("/singleplayer/bundles", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/singleplayer/bundles",
return this.bundleCallbacks.getBundles(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
}), {
return this.bundleCallbacks.getBundles(url, info, sessionID);
},
),
]); ]);
} }
} }

View File

@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe";
import { ClientLogCallbacks } from "@spt-aki/callbacks/ClientLogCallbacks"; import { ClientLogCallbacks } from "@spt-aki/callbacks/ClientLogCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
@injectable() @injectable()
export class ClientLogStaticRouter extends StaticRouter export class ClientLogStaticRouter extends StaticRouter
@ -9,17 +10,23 @@ export class ClientLogStaticRouter extends StaticRouter
constructor(@inject("ClientLogCallbacks") protected clientLogCallbacks: ClientLogCallbacks) constructor(@inject("ClientLogCallbacks") protected clientLogCallbacks: ClientLogCallbacks)
{ {
super([ super([
new RouteAction("/singleplayer/log", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/singleplayer/log",
return this.clientLogCallbacks.clientLog(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
}), {
new RouteAction("/singleplayer/release", (url: string, info: any, sessionID: string, output: string) => return this.clientLogCallbacks.clientLog(url, info, sessionID);
{ },
return this.clientLogCallbacks.releaseNotes(); ),
}), new RouteAction(
"/singleplayer/release",
async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{
return this.clientLogCallbacks.releaseNotes();
},
),
new RouteAction( new RouteAction(
"/singleplayer/enableBSGlogging", "/singleplayer/enableBSGlogging",
(url: string, info: any, sessionID: string, output: string) => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.clientLogCallbacks.bsgLogging(); return this.clientLogCallbacks.bsgLogging();
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { CustomizationCallbacks } from "@spt-aki/callbacks/CustomizationCallbacks"; import { CustomizationCallbacks } from "@spt-aki/callbacks/CustomizationCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetSuitsResponse } from "@spt-aki/models/eft/customization/IGetSuitsResponse";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class CustomizationStaticRouter extends StaticRouter export class CustomizationStaticRouter extends StaticRouter
@ -11,7 +13,12 @@ export class CustomizationStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/trading/customization/storage", "/client/trading/customization/storage",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetSuitsResponse>> =>
{ {
return this.customizationCallbacks.getSuits(url, info, sessionID); return this.customizationCallbacks.getSuits(url, info, sessionID);
}, },

View File

@ -2,6 +2,15 @@ import { inject, injectable } from "tsyringe";
import { DataCallbacks } from "@spt-aki/callbacks/DataCallbacks"; import { DataCallbacks } from "@spt-aki/callbacks/DataCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGlobals } from "@spt-aki/models/eft/common/IGlobals";
import { ICustomizationItem } from "@spt-aki/models/eft/common/tables/ICustomizationItem";
import { IHandbookBase } from "@spt-aki/models/eft/common/tables/IHandbookBase";
import { IHideoutArea } from "@spt-aki/models/eft/hideout/IHideoutArea";
import { IHideoutProduction } from "@spt-aki/models/eft/hideout/IHideoutProduction";
import { IHideoutScavCase } from "@spt-aki/models/eft/hideout/IHideoutScavCase";
import { IHideoutSettingsBase } from "@spt-aki/models/eft/hideout/IHideoutSettingsBase";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { ISettingsBase } from "@spt-aki/models/spt/server/ISettingsBase";
@injectable() @injectable()
export class DataStaticRouter extends StaticRouter export class DataStaticRouter extends StaticRouter
@ -9,68 +18,136 @@ export class DataStaticRouter extends StaticRouter
constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks) constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks)
{ {
super([ super([
new RouteAction("/client/settings", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/settings",
return this.dataCallbacks.getSettings(url, info, sessionID); async (
}), url: string,
new RouteAction("/client/globals", (url: string, info: any, sessionID: string, output: string): any => info: any,
{ sessionID: string,
return this.dataCallbacks.getGlobals(url, info, sessionID); output: string,
}), ): Promise<IGetBodyResponseData<ISettingsBase>> =>
new RouteAction("/client/items", (url: string, info: any, sessionID: string, output: string): any => {
{ return this.dataCallbacks.getSettings(url, info, sessionID);
return this.dataCallbacks.getTemplateItems(url, info, sessionID); },
}), ),
new RouteAction(
"/client/globals",
async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGlobals>> =>
{
return this.dataCallbacks.getGlobals(url, info, sessionID);
},
),
new RouteAction(
"/client/items",
async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{
return this.dataCallbacks.getTemplateItems(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/handbook/templates", "/client/handbook/templates",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IHandbookBase>> =>
{ {
return this.dataCallbacks.getTemplateHandbook(url, info, sessionID); return this.dataCallbacks.getTemplateHandbook(url, info, sessionID);
}, },
), ),
new RouteAction("/client/customization", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/customization",
return this.dataCallbacks.getTemplateSuits(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<Record<string, ICustomizationItem>>> =>
{
return this.dataCallbacks.getTemplateSuits(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/account/customization", "/client/account/customization",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<string[]>> =>
{ {
return this.dataCallbacks.getTemplateCharacter(url, info, sessionID); return this.dataCallbacks.getTemplateCharacter(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/hideout/production/recipes", "/client/hideout/production/recipes",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IHideoutProduction[]>> =>
{ {
return this.dataCallbacks.gethideoutProduction(url, info, sessionID); return this.dataCallbacks.gethideoutProduction(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/hideout/settings", "/client/hideout/settings",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IHideoutSettingsBase>> =>
{ {
return this.dataCallbacks.getHideoutSettings(url, info, sessionID); return this.dataCallbacks.getHideoutSettings(url, info, sessionID);
}, },
), ),
new RouteAction("/client/hideout/areas", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/hideout/areas",
return this.dataCallbacks.getHideoutAreas(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IHideoutArea[]>> =>
{
return this.dataCallbacks.getHideoutAreas(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/hideout/production/scavcase/recipes", "/client/hideout/production/scavcase/recipes",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IHideoutScavCase[]>> =>
{ {
return this.dataCallbacks.getHideoutScavcase(url, info, sessionID); return this.dataCallbacks.getHideoutScavcase(url, info, sessionID);
}, },
), ),
new RouteAction("/client/languages", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/languages",
return this.dataCallbacks.getLocalesLanguages(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<Record<string, string>>> =>
{
return this.dataCallbacks.getLocalesLanguages(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/hideout/qte/list", "/client/hideout/qte/list",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.dataCallbacks.getQteList(url, info, sessionID); return this.dataCallbacks.getQteList(url, info, sessionID);
}, },

View File

@ -2,6 +2,14 @@ import { inject, injectable } from "tsyringe";
import { DialogueCallbacks } from "@spt-aki/callbacks/DialogueCallbacks"; import { DialogueCallbacks } from "@spt-aki/callbacks/DialogueCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IChatServer } from "@spt-aki/models/eft/dialog/IChatServer";
import { IFriendRequestSendResponse } from "@spt-aki/models/eft/dialog/IFriendRequestSendResponse";
import { IGetAllAttachmentsResponse } from "@spt-aki/models/eft/dialog/IGetAllAttachmentsResponse";
import { IGetFriendListDataResponse } from "@spt-aki/models/eft/dialog/IGetFriendListDataResponse";
import { IGetMailDialogViewResponseData } from "@spt-aki/models/eft/dialog/IGetMailDialogViewResponseData";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
import { DialogueInfo } from "@spt-aki/models/eft/profile/IAkiProfile";
@injectable() @injectable()
export class DialogStaticRouter extends StaticRouter export class DialogStaticRouter extends StaticRouter
@ -11,138 +19,237 @@ export class DialogStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/chatServer/list", "/client/chatServer/list",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IChatServer[]>> =>
{ {
return this.dialogueCallbacks.getChatServerList(url, info, sessionID); return this.dialogueCallbacks.getChatServerList(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/list", "/client/mail/dialog/list",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<DialogueInfo[]>> =>
{ {
return this.dialogueCallbacks.getMailDialogList(url, info, sessionID); return this.dialogueCallbacks.getMailDialogList(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/view", "/client/mail/dialog/view",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetMailDialogViewResponseData>> =>
{ {
return this.dialogueCallbacks.getMailDialogView(url, info, sessionID); return this.dialogueCallbacks.getMailDialogView(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/info", "/client/mail/dialog/info",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<DialogueInfo>> =>
{ {
return this.dialogueCallbacks.getMailDialogInfo(url, info, sessionID); return this.dialogueCallbacks.getMailDialogInfo(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/remove", "/client/mail/dialog/remove",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.dialogueCallbacks.removeDialog(url, info, sessionID); return this.dialogueCallbacks.removeDialog(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/pin", "/client/mail/dialog/pin",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.dialogueCallbacks.pinDialog(url, info, sessionID); return this.dialogueCallbacks.pinDialog(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/unpin", "/client/mail/dialog/unpin",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.dialogueCallbacks.unpinDialog(url, info, sessionID); return this.dialogueCallbacks.unpinDialog(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/read", "/client/mail/dialog/read",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.dialogueCallbacks.setRead(url, info, sessionID); return this.dialogueCallbacks.setRead(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/remove", "/client/mail/dialog/remove",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.dialogueCallbacks.removeMail(url, info, sessionID); return this.dialogueCallbacks.removeMail(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/mail/dialog/getAllAttachments", "/client/mail/dialog/getAllAttachments",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetAllAttachmentsResponse>> =>
{ {
return this.dialogueCallbacks.getAllAttachments(url, info, sessionID); return this.dialogueCallbacks.getAllAttachments(url, info, sessionID);
}, },
), ),
new RouteAction("/client/mail/msg/send", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/mail/msg/send",
return this.dialogueCallbacks.sendMessage(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<string>> =>
{
return this.dialogueCallbacks.sendMessage(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/mail/dialog/clear", "/client/mail/dialog/clear",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.dialogueCallbacks.clearMail(url, info, sessionID); return this.dialogueCallbacks.clearMail(url, info, sessionID);
}, },
), ),
new RouteAction("/client/friend/list", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/friend/list",
return this.dialogueCallbacks.getFriendList(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetFriendListDataResponse>> =>
{
return this.dialogueCallbacks.getFriendList(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/friend/request/list/outbox", "/client/friend/request/list/outbox",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.dialogueCallbacks.listOutbox(url, info, sessionID); return this.dialogueCallbacks.listOutbox(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/request/list/inbox", "/client/friend/request/list/inbox",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<any[]>> =>
{ {
return this.dialogueCallbacks.listInbox(url, info, sessionID); return this.dialogueCallbacks.listInbox(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/request/send", "/client/friend/request/send",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IFriendRequestSendResponse>> =>
{ {
return this.dialogueCallbacks.sendFriendRequest(url, info, sessionID); return this.dialogueCallbacks.sendFriendRequest(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/request/accept", "/client/friend/request/accept",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<boolean>> =>
{ {
return this.dialogueCallbacks.acceptFriendRequest(url, info, sessionID); return this.dialogueCallbacks.acceptFriendRequest(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/request/cancel", "/client/friend/request/cancel",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<boolean>> =>
{ {
return this.dialogueCallbacks.cancelFriendRequest(url, info, sessionID); return this.dialogueCallbacks.cancelFriendRequest(url, info, sessionID);
}, },
), ),
new RouteAction("/client/friend/delete", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/friend/delete",
return this.dialogueCallbacks.deleteFriend(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
}), {
return this.dialogueCallbacks.deleteFriend(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/friend/ignore/set", "/client/friend/ignore/set",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.dialogueCallbacks.ignoreFriend(url, info, sessionID); return this.dialogueCallbacks.ignoreFriend(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/ignore/remove", "/client/friend/ignore/remove",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.dialogueCallbacks.unIgnoreFriend(url, info, sessionID); return this.dialogueCallbacks.unIgnoreFriend(url, info, sessionID);
}, },

View File

@ -2,6 +2,17 @@ import { inject, injectable } from "tsyringe";
import { GameCallbacks } from "@spt-aki/callbacks/GameCallbacks"; import { GameCallbacks } from "@spt-aki/callbacks/GameCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { ICheckVersionResponse } from "@spt-aki/models/eft/game/ICheckVersionResponse";
import { ICurrentGroupResponse } from "@spt-aki/models/eft/game/ICurrentGroupResponse";
import { IGameConfigResponse } from "@spt-aki/models/eft/game/IGameConfigResponse";
import { IGameKeepAliveResponse } from "@spt-aki/models/eft/game/IGameKeepAliveResponse";
import { IGameLogoutResponseData } from "@spt-aki/models/eft/game/IGameLogoutResponseData";
import { IGameModeResponse } from "@spt-aki/models/eft/game/IGameModeResponse";
import { IGameStartResponse } from "@spt-aki/models/eft/game/IGameStartResponse";
import { IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeResponse";
import { IServerDetails } from "@spt-aki/models/eft/game/IServerDetails";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
@injectable() @injectable()
export class GameStaticRouter extends StaticRouter export class GameStaticRouter extends StaticRouter
@ -9,61 +20,119 @@ export class GameStaticRouter extends StaticRouter
constructor(@inject("GameCallbacks") protected gameCallbacks: GameCallbacks) constructor(@inject("GameCallbacks") protected gameCallbacks: GameCallbacks)
{ {
super([ super([
new RouteAction("/client/game/config", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/game/config",
return this.gameCallbacks.getGameConfig(url, info, sessionID); async (
}), url: string,
new RouteAction("/client/game/mode", (url: string, info: any, sessionID: string, output: string): any => info: any,
{ sessionID: string,
return this.gameCallbacks.getGameMode(url, info, sessionID); output: string,
}), ): Promise<IGetBodyResponseData<IGameConfigResponse>> =>
new RouteAction("/client/server/list", (url: string, info: any, sessionID: string, output: string): any => {
{ return this.gameCallbacks.getGameConfig(url, info, sessionID);
return this.gameCallbacks.getServer(url, info, sessionID); },
}), ),
new RouteAction(
"/client/game/mode",
async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGameModeResponse>> =>
{
return this.gameCallbacks.getGameMode(url, info, sessionID);
},
),
new RouteAction(
"/client/server/list",
async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IServerDetails[]>> =>
{
return this.gameCallbacks.getServer(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/match/group/current", "/client/match/group/current",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ICurrentGroupResponse>> =>
{ {
return this.gameCallbacks.getCurrentGroup(url, info, sessionID); return this.gameCallbacks.getCurrentGroup(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/version/validate", "/client/game/version/validate",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.gameCallbacks.versionValidate(url, info, sessionID); return this.gameCallbacks.versionValidate(url, info, sessionID);
}, },
), ),
new RouteAction("/client/game/start", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/game/start",
return this.gameCallbacks.gameStart(url, info, sessionID); async (
}), url: string,
new RouteAction("/client/game/logout", (url: string, info: any, sessionID: string, output: string): any => info: any,
{ sessionID: string,
return this.gameCallbacks.gameLogout(url, info, sessionID); output: string,
}), ): Promise<IGetBodyResponseData<IGameStartResponse>> =>
new RouteAction("/client/checkVersion", (url: string, info: any, sessionID: string, output: string): any => {
{ return this.gameCallbacks.gameStart(url, info, sessionID);
return this.gameCallbacks.validateGameVersion(url, info, sessionID); },
}), ),
new RouteAction(
"/client/game/logout",
async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGameLogoutResponseData>> =>
{
return this.gameCallbacks.gameLogout(url, info, sessionID);
},
),
new RouteAction(
"/client/checkVersion",
async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ICheckVersionResponse>> =>
{
return this.gameCallbacks.validateGameVersion(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/game/keepalive", "/client/game/keepalive",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGameKeepAliveResponse>> =>
{ {
return this.gameCallbacks.gameKeepalive(url, info, sessionID); return this.gameCallbacks.gameKeepalive(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/settings/version", "/singleplayer/settings/version",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.gameCallbacks.getVersion(url, info, sessionID); return this.gameCallbacks.getVersion(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/reports/lobby/send", "/client/reports/lobby/send",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.gameCallbacks.reportNickname(url, info, sessionID); return this.gameCallbacks.reportNickname(url, info, sessionID);
}, },
@ -71,7 +140,7 @@ export class GameStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/singleplayer/settings/getRaidTime", "/singleplayer/settings/getRaidTime",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<IGetRaidTimeResponse> =>
{ {
return this.gameCallbacks.getRaidTime(url, info, sessionID); return this.gameCallbacks.getRaidTime(url, info, sessionID);
}, },

View File

@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe";
import { HealthCallbacks } from "@spt-aki/callbacks/HealthCallbacks"; import { HealthCallbacks } from "@spt-aki/callbacks/HealthCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class HealthStaticRouter extends StaticRouter export class HealthStaticRouter extends StaticRouter
@ -9,13 +10,26 @@ export class HealthStaticRouter extends StaticRouter
constructor(@inject("HealthCallbacks") protected healthCallbacks: HealthCallbacks) constructor(@inject("HealthCallbacks") protected healthCallbacks: HealthCallbacks)
{ {
super([ super([
new RouteAction("/player/health/sync", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/player/health/sync",
return this.healthCallbacks.syncHealth(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<string>> =>
{
return this.healthCallbacks.syncHealth(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/hideout/workout", "/client/hideout/workout",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<string>> =>
{ {
return this.healthCallbacks.handleWorkoutEffects(url, info, sessionID); return this.healthCallbacks.handleWorkoutEffects(url, info, sessionID);
}, },

View File

@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe";
import { InraidCallbacks } from "@spt-aki/callbacks/InraidCallbacks"; import { InraidCallbacks } from "@spt-aki/callbacks/InraidCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
@injectable() @injectable()
export class InraidStaticRouter extends StaticRouter export class InraidStaticRouter extends StaticRouter
@ -9,55 +10,58 @@ export class InraidStaticRouter extends StaticRouter
constructor(@inject("InraidCallbacks") protected inraidCallbacks: InraidCallbacks) constructor(@inject("InraidCallbacks") protected inraidCallbacks: InraidCallbacks)
{ {
super([ super([
new RouteAction("/raid/profile/save", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/raid/profile/save",
return this.inraidCallbacks.saveProgress(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
}), {
return this.inraidCallbacks.saveProgress(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/singleplayer/settings/raid/endstate", "/singleplayer/settings/raid/endstate",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.inraidCallbacks.getRaidEndState(); return this.inraidCallbacks.getRaidEndState();
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/settings/raid/menu", "/singleplayer/settings/raid/menu",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.inraidCallbacks.getRaidMenuSettings(); return this.inraidCallbacks.getRaidMenuSettings();
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/airdrop/config", "/singleplayer/airdrop/config",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.inraidCallbacks.getAirdropConfig(); return this.inraidCallbacks.getAirdropConfig();
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/btr/config", "/singleplayer/btr/config",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.inraidCallbacks.getBTRConfig(); return this.inraidCallbacks.getBTRConfig();
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/traderServices/itemDelivery", "/singleplayer/traderServices/itemDelivery",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.inraidCallbacks.itemDelivery(url, info, sessionID); return this.inraidCallbacks.itemDelivery(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/scav/traitorscavhostile", "/singleplayer/scav/traitorscavhostile",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.inraidCallbacks.getTraitorScavHostileChance(url, info, sessionID); return this.inraidCallbacks.getTraitorScavHostileChance(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/singleplayer/sandbox/maxpatrol", "/singleplayer/sandbox/maxpatrol",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.inraidCallbacks.getSandboxMaxPatrolValue(url, info, sessionID); return this.inraidCallbacks.getSandboxMaxPatrolValue(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { InsuranceCallbacks } from "@spt-aki/callbacks/InsuranceCallbacks"; import { InsuranceCallbacks } from "@spt-aki/callbacks/InsuranceCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { IGetInsuranceCostResponseData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostResponseData";
@injectable() @injectable()
export class InsuranceStaticRouter extends StaticRouter export class InsuranceStaticRouter extends StaticRouter
@ -11,7 +13,12 @@ export class InsuranceStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/insurance/items/list/cost", "/client/insurance/items/list/cost",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetInsuranceCostResponseData>> =>
{ {
return this.insuranceCallbacks.getInsuranceCost(url, info, sessionID); return this.insuranceCallbacks.getInsuranceCost(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { ItemEventCallbacks } from "@spt-aki/callbacks/ItemEventCallbacks"; import { ItemEventCallbacks } from "@spt-aki/callbacks/ItemEventCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
@injectable() @injectable()
export class ItemEventStaticRouter extends StaticRouter export class ItemEventStaticRouter extends StaticRouter
@ -11,7 +13,12 @@ export class ItemEventStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/game/profile/items/moving", "/client/game/profile/items/moving",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IItemEventRouterResponse>> =>
{ {
return this.itemEventCallbacks.handleEvents(url, info, sessionID); return this.itemEventCallbacks.handleEvents(url, info, sessionID);
}, },

View File

@ -9,87 +9,93 @@ export class LauncherStaticRouter extends StaticRouter
constructor(@inject("LauncherCallbacks") protected launcherCallbacks: LauncherCallbacks) constructor(@inject("LauncherCallbacks") protected launcherCallbacks: LauncherCallbacks)
{ {
super([ super([
new RouteAction("/launcher/ping", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/launcher/ping",
return this.launcherCallbacks.ping(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
}), {
return this.launcherCallbacks.ping(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/launcher/server/connect", "/launcher/server/connect",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.connect(); return this.launcherCallbacks.connect();
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/login", "/launcher/profile/login",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.login(url, info, sessionID); return this.launcherCallbacks.login(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/register", "/launcher/profile/register",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.register(url, info, sessionID); return this.launcherCallbacks.register(url, info, sessionID);
}, },
), ),
new RouteAction("/launcher/profile/get", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/launcher/profile/get",
return this.launcherCallbacks.get(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
}), {
return this.launcherCallbacks.get(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/launcher/profile/change/username", "/launcher/profile/change/username",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.changeUsername(url, info, sessionID); return this.launcherCallbacks.changeUsername(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/change/password", "/launcher/profile/change/password",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.changePassword(url, info, sessionID); return this.launcherCallbacks.changePassword(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/change/wipe", "/launcher/profile/change/wipe",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.wipe(url, info, sessionID); return this.launcherCallbacks.wipe(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/remove", "/launcher/profile/remove",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.removeProfile(url, info, sessionID); return this.launcherCallbacks.removeProfile(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/compatibleTarkovVersion", "/launcher/profile/compatibleTarkovVersion",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.getCompatibleTarkovVersion(); return this.launcherCallbacks.getCompatibleTarkovVersion();
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/server/version", "/launcher/server/version",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.getServerVersion(); return this.launcherCallbacks.getServerVersion();
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/server/loadedServerMods", "/launcher/server/loadedServerMods",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.getLoadedServerMods(); return this.launcherCallbacks.getLoadedServerMods();
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/server/serverModsUsedByProfile", "/launcher/server/serverModsUsedByProfile",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.launcherCallbacks.getServerModsProfileUsed(url, info, sessionID); return this.launcherCallbacks.getServerModsProfileUsed(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { LocationCallbacks } from "@spt-aki/callbacks/LocationCallbacks"; import { LocationCallbacks } from "@spt-aki/callbacks/LocationCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { ILocationsGenerateAllResponse } from "@spt-aki/models/eft/common/ILocationsSourceDestinationBase";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class LocationStaticRouter extends StaticRouter export class LocationStaticRouter extends StaticRouter
@ -9,13 +11,21 @@ export class LocationStaticRouter extends StaticRouter
constructor(@inject("LocationCallbacks") protected locationCallbacks: LocationCallbacks) constructor(@inject("LocationCallbacks") protected locationCallbacks: LocationCallbacks)
{ {
super([ super([
new RouteAction("/client/locations", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/locations",
return this.locationCallbacks.getLocationData(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ILocationsGenerateAllResponse>> =>
{
return this.locationCallbacks.getLocationData(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/location/getAirdropLoot", "/client/location/getAirdropLoot",
(url: string, info: any, sessionID: string, _output: string): any => async (url: string, info: any, sessionID: string, _output: string): Promise<string> =>
{ {
return this.locationCallbacks.getAirdropLoot(url, info, sessionID); return this.locationCallbacks.getAirdropLoot(url, info, sessionID);
}, },

View File

@ -3,6 +3,11 @@ import { inject, injectable } from "tsyringe";
import { MatchCallbacks } from "@spt-aki/callbacks/MatchCallbacks"; import { MatchCallbacks } from "@spt-aki/callbacks/MatchCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData"; import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
import { IAcceptGroupInviteResponse } from "@spt-aki/models/eft/match/IAcceptGroupInviteResponse";
import { IGetGroupStatusResponse } from "@spt-aki/models/eft/match/IGetGroupStatusResponse";
import { IJoinMatchResult } from "@spt-aki/models/eft/match/IJoinMatchResult";
@injectable() @injectable()
export class MatchStaticRouter extends StaticRouter export class MatchStaticRouter extends StaticRouter
@ -12,138 +17,202 @@ export class MatchStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/match/available", "/client/match/available",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<boolean>> =>
{ {
return this.matchCallbacks.serverAvailable(url, info, sessionID); return this.matchCallbacks.serverAvailable(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/updatePing", "/client/match/updatePing",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.updatePing(url, info, sessionID); return this.matchCallbacks.updatePing(url, info, sessionID);
}, },
), ),
new RouteAction("/client/match/join", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/match/join",
return this.matchCallbacks.joinMatch(url, info, sessionID); async (
}), url: string,
new RouteAction("/client/match/exit", (url: string, info: any, sessionID: string, output: string): any => info: any,
{ sessionID: string,
return this.matchCallbacks.exitMatch(url, info, sessionID); output: string,
}), ): Promise<IGetBodyResponseData<IJoinMatchResult>> =>
{
return this.matchCallbacks.joinMatch(url, info, sessionID);
},
),
new RouteAction(
"/client/match/exit",
async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{
return this.matchCallbacks.exitMatch(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/match/group/delete", "/client/match/group/delete",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.deleteGroup(url, info, sessionID); return this.matchCallbacks.deleteGroup(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/leave", "/client/match/group/leave",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<boolean>> =>
{ {
return this.matchCallbacks.leaveGroup(url, info, sessionID); return this.matchCallbacks.leaveGroup(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/status", "/client/match/group/status",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetGroupStatusResponse>> =>
{ {
return this.matchCallbacks.getGroupStatus(url, info, sessionID); return this.matchCallbacks.getGroupStatus(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/start_game", "/client/match/group/start_game",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IJoinMatchResult>> =>
{ {
return this.matchCallbacks.joinMatch(url, info, sessionID); return this.matchCallbacks.joinMatch(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/exit_from_menu", "/client/match/group/exit_from_menu",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.exitToMenu(url, info, sessionID); return this.matchCallbacks.exitToMenu(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/looking/start", "/client/match/group/looking/start",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.startGroupSearch(url, info, sessionID); return this.matchCallbacks.startGroupSearch(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/looking/stop", "/client/match/group/looking/stop",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.stopGroupSearch(url, info, sessionID); return this.matchCallbacks.stopGroupSearch(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/invite/send", "/client/match/group/invite/send",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<string>> =>
{ {
return this.matchCallbacks.sendGroupInvite(url, info, sessionID); return this.matchCallbacks.sendGroupInvite(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/invite/accept", "/client/match/group/invite/accept",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IAcceptGroupInviteResponse[]>> =>
{ {
return this.matchCallbacks.acceptGroupInvite(url, info, sessionID); return this.matchCallbacks.acceptGroupInvite(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/invite/decline", "/client/match/group/invite/decline",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<IGetBodyResponseData<any>> =>
{ {
return this.matchCallbacks.declineGroupInvite(url, info, sessionID); return this.matchCallbacks.declineGroupInvite(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/invite/cancel", "/client/match/group/invite/cancel",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<boolean>> =>
{ {
return this.matchCallbacks.cancelGroupInvite(url, info, sessionID); return this.matchCallbacks.cancelGroupInvite(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/invite/cancel-all", "/client/match/group/invite/cancel-all",
(url: string, info: IEmptyRequestData, sessionID: string, output: string): any => async (
url: string,
info: IEmptyRequestData,
sessionID: string,
output: string,
): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.cancelAllGroupInvite(url, info, sessionID); return this.matchCallbacks.cancelAllGroupInvite(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/transfer", "/client/match/group/transfer",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<boolean>> =>
{ {
return this.matchCallbacks.transferGroup(url, info, sessionID); return this.matchCallbacks.transferGroup(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/offline/end", "/client/match/offline/end",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.endOfflineRaid(url, info, sessionID); return this.matchCallbacks.endOfflineRaid(url, info, sessionID);
}, },
), ),
new RouteAction("/client/putMetrics", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/putMetrics",
return this.matchCallbacks.putMetrics(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
}), {
return this.matchCallbacks.putMetrics(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/getMetricsConfig", "/client/getMetricsConfig",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<string>> =>
{ {
return this.matchCallbacks.getMetrics(url, info, sessionID); return this.matchCallbacks.getMetrics(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/raid/configuration", "/client/raid/configuration",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.getRaidConfiguration(url, info, sessionID); return this.matchCallbacks.getRaidConfiguration(url, info, sessionID);
}, },
@ -151,14 +220,14 @@ export class MatchStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/raid/configuration-by-profile", "/client/raid/configuration-by-profile",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.getConfigurationByProfile(url, info, sessionID); return this.matchCallbacks.getConfigurationByProfile(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/player/remove", "/client/match/group/player/remove",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.matchCallbacks.removePlayerFromGroup(url, info, sessionID); return this.matchCallbacks.removePlayerFromGroup(url, info, sessionID);
}, },

View File

@ -2,6 +2,9 @@ import { inject, injectable } from "tsyringe";
import { NotifierCallbacks } from "@spt-aki/callbacks/NotifierCallbacks"; import { NotifierCallbacks } from "@spt-aki/callbacks/NotifierCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { INotifierChannel } from "@spt-aki/models/eft/notifier/INotifier";
import { ISelectProfileResponse } from "@spt-aki/models/eft/notifier/ISelectProfileResponse";
@injectable() @injectable()
export class NotifierStaticRouter extends StaticRouter export class NotifierStaticRouter extends StaticRouter
@ -11,14 +14,24 @@ export class NotifierStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/notifier/channel/create", "/client/notifier/channel/create",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<INotifierChannel>> =>
{ {
return this.notifierCallbacks.createNotifierChannel(url, info, sessionID); return this.notifierCallbacks.createNotifierChannel(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/profile/select", "/client/game/profile/select",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ISelectProfileResponse>> =>
{ {
return this.notifierCallbacks.selectProfile(url, info, sessionID); return this.notifierCallbacks.selectProfile(url, info, sessionID);
}, },

View File

@ -2,6 +2,13 @@ import { inject, injectable } from "tsyringe";
import { ProfileCallbacks } from "@spt-aki/callbacks/ProfileCallbacks"; import { ProfileCallbacks } from "@spt-aki/callbacks/ProfileCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
import { GetProfileStatusResponseData } from "@spt-aki/models/eft/profile/GetProfileStatusResponseData";
import { ICreateProfileResponse } from "@spt-aki/models/eft/profile/ICreateProfileResponse";
import { IGetOtherProfileResponse } from "@spt-aki/models/eft/profile/IGetOtherProfileResponse";
import { ISearchFriendResponse } from "@spt-aki/models/eft/profile/ISearchFriendResponse";
@injectable() @injectable()
export class ProfileStaticRouter extends StaticRouter export class ProfileStaticRouter extends StaticRouter
@ -11,56 +18,81 @@ export class ProfileStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/game/profile/create", "/client/game/profile/create",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ICreateProfileResponse>> =>
{ {
return this.profileCallbacks.createProfile(url, info, sessionID); return this.profileCallbacks.createProfile(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/profile/list", "/client/game/profile/list",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IPmcData[]>> =>
{ {
return this.profileCallbacks.getProfileData(url, info, sessionID); return this.profileCallbacks.getProfileData(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/profile/savage/regenerate", "/client/game/profile/savage/regenerate",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IPmcData[]>> =>
{ {
return this.profileCallbacks.regenerateScav(url, info, sessionID); return this.profileCallbacks.regenerateScav(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/profile/voice/change", "/client/game/profile/voice/change",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.profileCallbacks.changeVoice(url, info, sessionID); return this.profileCallbacks.changeVoice(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/profile/nickname/change", "/client/game/profile/nickname/change",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<IGetBodyResponseData<any>> =>
{ {
return this.profileCallbacks.changeNickname(url, info, sessionID); return this.profileCallbacks.changeNickname(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/profile/nickname/validate", "/client/game/profile/nickname/validate",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<IGetBodyResponseData<any>> =>
{ {
return this.profileCallbacks.validateNickname(url, info, sessionID); return this.profileCallbacks.validateNickname(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/profile/nickname/reserved", "/client/game/profile/nickname/reserved",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<string>> =>
{ {
return this.profileCallbacks.getReservedNickname(url, info, sessionID); return this.profileCallbacks.getReservedNickname(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/profile/status", "/client/profile/status",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<GetProfileStatusResponseData>> =>
{ {
return this.profileCallbacks.getProfileStatus(url, info, sessionID); return this.profileCallbacks.getProfileStatus(url, info, sessionID);
}, },
@ -68,36 +100,54 @@ export class ProfileStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/profile/view", "/client/profile/view",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetOtherProfileResponse>> =>
{ {
return this.profileCallbacks.getOtherProfile(url, info, sessionID); return this.profileCallbacks.getOtherProfile(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/profile/settings", "/client/profile/settings",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<string>> =>
{ {
return this.profileCallbacks.getProfileSettings(url, info, sessionID); return this.profileCallbacks.getProfileSettings(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/game/profile/search", "/client/game/profile/search",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ISearchFriendResponse[]>> =>
{ {
return this.profileCallbacks.searchFriend(url, info, sessionID); return this.profileCallbacks.searchFriend(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/info", "/launcher/profile/info",
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
{ {
return this.profileCallbacks.getMiniProfile(url, info, sessionID); return this.profileCallbacks.getMiniProfile(url, info, sessionID);
}, },
), ),
new RouteAction("/launcher/profiles", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/launcher/profiles",
return this.profileCallbacks.getAllMiniProfiles(url, info, sessionID); async (url: string, info: any, sessionID: string, output: string): Promise<string> =>
}), {
return this.profileCallbacks.getAllMiniProfiles(url, info, sessionID);
},
),
]); ]);
} }
} }

View File

@ -2,6 +2,9 @@ import { inject, injectable } from "tsyringe";
import { QuestCallbacks } from "@spt-aki/callbacks/QuestCallbacks"; import { QuestCallbacks } from "@spt-aki/callbacks/QuestCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IQuest } from "@spt-aki/models/eft/common/tables/IQuest";
import { IPmcDataRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class QuestStaticRouter extends StaticRouter export class QuestStaticRouter extends StaticRouter
@ -9,13 +12,26 @@ export class QuestStaticRouter extends StaticRouter
constructor(@inject("QuestCallbacks") protected questCallbacks: QuestCallbacks) constructor(@inject("QuestCallbacks") protected questCallbacks: QuestCallbacks)
{ {
super([ super([
new RouteAction("/client/quest/list", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/quest/list",
return this.questCallbacks.listQuests(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IQuest[]>> =>
{
return this.questCallbacks.listQuests(url, info, sessionID);
},
),
new RouteAction( new RouteAction(
"/client/repeatalbeQuests/activityPeriods", "/client/repeatalbeQuests/activityPeriods",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IPmcDataRepeatableQuest[]>> =>
{ {
return this.questCallbacks.activityPeriods(url, info, sessionID); return this.questCallbacks.activityPeriods(url, info, sessionID);
}, },

View File

@ -2,6 +2,11 @@ import { inject, injectable } from "tsyringe";
import { RagfairCallbacks } from "@spt-aki/callbacks/RagfairCallbacks"; import { RagfairCallbacks } from "@spt-aki/callbacks/RagfairCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
import { IGetItemPriceResult } from "@spt-aki/models/eft/ragfair/IGetItemPriceResult";
import { IGetOffersResult } from "@spt-aki/models/eft/ragfair/IGetOffersResult";
import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer";
@injectable() @injectable()
export class RagfairStaticRouter extends StaticRouter export class RagfairStaticRouter extends StaticRouter
@ -12,7 +17,12 @@ export class RagfairStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/ragfair/search", "/client/ragfair/search",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetOffersResult>> =>
{ {
return this.ragfairCallbacks.search(url, info, sessionID); return this.ragfairCallbacks.search(url, info, sessionID);
}, },
@ -20,7 +30,12 @@ export class RagfairStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/ragfair/find", "/client/ragfair/find",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetOffersResult>> =>
{ {
return this.ragfairCallbacks.search(url, info, sessionID); return this.ragfairCallbacks.search(url, info, sessionID);
}, },
@ -28,7 +43,12 @@ export class RagfairStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/ragfair/itemMarketPrice", "/client/ragfair/itemMarketPrice",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IGetItemPriceResult>> =>
{ {
return this.ragfairCallbacks.getMarketPrice(url, info, sessionID); return this.ragfairCallbacks.getMarketPrice(url, info, sessionID);
}, },
@ -36,7 +56,7 @@ export class RagfairStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/ragfair/offerfees", "/client/ragfair/offerfees",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.ragfairCallbacks.storePlayerOfferTaxAmount(url, info, sessionID); return this.ragfairCallbacks.storePlayerOfferTaxAmount(url, info, sessionID);
}, },
@ -44,7 +64,7 @@ export class RagfairStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/reports/ragfair/send", "/client/reports/ragfair/send",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (url: string, info: any, sessionID: string, output: string): Promise<INullResponseData> =>
{ {
return this.ragfairCallbacks.sendReport(url, info, sessionID); return this.ragfairCallbacks.sendReport(url, info, sessionID);
}, },
@ -52,7 +72,12 @@ export class RagfairStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/items/prices", "/client/items/prices",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<Record<string, number>>> =>
{ {
return this.ragfairCallbacks.getFleaPrices(url, info, sessionID); return this.ragfairCallbacks.getFleaPrices(url, info, sessionID);
}, },
@ -60,7 +85,12 @@ export class RagfairStaticRouter extends StaticRouter
new RouteAction( new RouteAction(
"/client/ragfair/offer/findbyid", "/client/ragfair/offer/findbyid",
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IRagfairOffer>> =>
{ {
return this.ragfairCallbacks.getFleaOfferById(url, info, sessionID); return this.ragfairCallbacks.getFleaOfferById(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { TraderCallbacks } from "@spt-aki/callbacks/TraderCallbacks"; import { TraderCallbacks } from "@spt-aki/callbacks/TraderCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
@injectable() @injectable()
export class TraderStaticRouter extends StaticRouter export class TraderStaticRouter extends StaticRouter
@ -11,7 +13,12 @@ export class TraderStaticRouter extends StaticRouter
super([ super([
new RouteAction( new RouteAction(
"/client/trading/api/traderSettings", "/client/trading/api/traderSettings",
(url: string, info: any, sessionID: string, output: string): any => async (
url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<ITraderBase[]>> =>
{ {
return this.traderCallbacks.getTraderSettings(url, info, sessionID); return this.traderCallbacks.getTraderSettings(url, info, sessionID);
}, },

View File

@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe";
import { WeatherCallbacks } from "@spt-aki/callbacks/WeatherCallbacks"; import { WeatherCallbacks } from "@spt-aki/callbacks/WeatherCallbacks";
import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
import { IWeatherData } from "@spt-aki/models/eft/weather/IWeatherData";
@injectable() @injectable()
export class WeatherStaticRouter extends StaticRouter export class WeatherStaticRouter extends StaticRouter
@ -9,10 +11,18 @@ export class WeatherStaticRouter extends StaticRouter
constructor(@inject("WeatherCallbacks") protected weatherCallbacks: WeatherCallbacks) constructor(@inject("WeatherCallbacks") protected weatherCallbacks: WeatherCallbacks)
{ {
super([ super([
new RouteAction("/client/weather", (url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/weather",
return this.weatherCallbacks.getWeather(url, info, sessionID); async (
}), url: string,
info: any,
sessionID: string,
output: string,
): Promise<IGetBodyResponseData<IWeatherData>> =>
{
return this.weatherCallbacks.getWeather(url, info, sessionID);
},
),
]); ]);
} }
} }

View File

@ -30,13 +30,13 @@ export class AkiHttpListener implements IHttpListener
return ["GET", "PUT", "POST"].includes(req.method); return ["GET", "PUT", "POST"].includes(req.method);
} }
public handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): void public async handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): Promise<void>
{ {
switch (req.method) switch (req.method)
{ {
case "GET": case "GET":
{ {
const response = this.getResponse(sessionId, req, null); const response = await this.getResponse(sessionId, req, null);
this.sendResponse(sessionId, req, resp, null, response); this.sendResponse(sessionId, req, resp, null, response);
break; break;
} }
@ -58,7 +58,7 @@ export class AkiHttpListener implements IHttpListener
written += data.length; written += data.length;
}); });
req.on("end", () => req.on("end", async () =>
{ {
// Contrary to reasonable expectations, the content-encoding is _not_ actually used to // Contrary to reasonable expectations, the content-encoding is _not_ actually used to
// determine if the payload is compressed. All PUT requests are, and POST requests without // determine if the payload is compressed. All PUT requests are, and POST requests without
@ -73,7 +73,7 @@ export class AkiHttpListener implements IHttpListener
this.logger.debug(value.toString(), true); this.logger.debug(value.toString(), true);
} }
const response = this.getResponse(sessionId, req, value); const response = await this.getResponse(sessionId, req, value);
this.sendResponse(sessionId, req, resp, value, response); this.sendResponse(sessionId, req, resp, value, response);
}); });
@ -136,7 +136,7 @@ export class AkiHttpListener implements IHttpListener
} }
} }
public getResponse(sessionID: string, req: IncomingMessage, body: Buffer): string public async getResponse(sessionID: string, req: IncomingMessage, body: Buffer): Promise<string>
{ {
const info = this.getBodyInfo(body, req.url); const info = this.getBodyInfo(body, req.url);
if (globalThis.G_LOG_REQUESTS) if (globalThis.G_LOG_REQUESTS)
@ -148,7 +148,7 @@ export class AkiHttpListener implements IHttpListener
this.requestsLogger.info(`REQUEST=${this.jsonUtil.serialize(log)}`); this.requestsLogger.info(`REQUEST=${this.jsonUtil.serialize(log)}`);
} }
let output = this.httpRouter.getResponse(req, info, sessionID); let output = await this.httpRouter.getResponse(req, info, sessionID);
/* route doesn't exist or response is not properly set up */ /* route doesn't exist or response is not properly set up */
if (!output) if (!output)
{ {

View File

@ -3,5 +3,5 @@ import { IncomingMessage, ServerResponse } from "node:http";
export interface IHttpListener export interface IHttpListener
{ {
canHandle(sessionId: string, req: IncomingMessage): boolean; canHandle(sessionId: string, req: IncomingMessage): boolean;
handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): void; handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): Promise<void>;
} }

View File

@ -16,7 +16,7 @@ export class HttpListenerMod implements IHttpListener
return this.canHandleOverride(sessionId, req); return this.canHandleOverride(sessionId, req);
} }
public handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): void public async handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): Promise<void>
{ {
this.handleOverride(sessionId, req, resp); this.handleOverride(sessionId, req, resp);
} }