diff --git a/project/src/callbacks/BotCallbacks.ts b/project/src/callbacks/BotCallbacks.ts index 966104ac..4ce6f3af 100644 --- a/project/src/callbacks/BotCallbacks.ts +++ b/project/src/callbacks/BotCallbacks.ts @@ -58,13 +58,13 @@ export class BotCallbacks * Handle client/game/bot/generate * @returns IGetBodyResponseData */ - public generateBots( + public async generateBots( url: string, info: IGenerateBotsRequestData, sessionID: string, - ): IGetBodyResponseData + ): Promise> { - return this.httpResponse.getBody(this.botController.generate(sessionID, info)); + return this.httpResponse.getBody(await this.botController.generate(sessionID, info)); } /** diff --git a/project/src/callbacks/ItemEventCallbacks.ts b/project/src/callbacks/ItemEventCallbacks.ts index cd12742a..6878ab95 100644 --- a/project/src/callbacks/ItemEventCallbacks.ts +++ b/project/src/callbacks/ItemEventCallbacks.ts @@ -17,13 +17,13 @@ export class ItemEventCallbacks ) {} - public handleEvents( + public async handleEvents( url: string, info: IItemEventRouterRequest, sessionID: string, - ): IGetBodyResponseData + ): Promise> { - const eventResponse = this.itemEventRouter.handleEvents(info, sessionID); + const eventResponse = await this.itemEventRouter.handleEvents(info, sessionID); const result = (this.isCriticalError(eventResponse.warnings)) ? this.httpResponse.getBody( eventResponse, diff --git a/project/src/controllers/BotController.ts b/project/src/controllers/BotController.ts index b89d64f2..9309ae01 100644 --- a/project/src/controllers/BotController.ts +++ b/project/src/controllers/BotController.ts @@ -6,7 +6,7 @@ import { BotGenerator } from "@spt-aki/generators/BotGenerator"; import { BotDifficultyHelper } from "@spt-aki/helpers/BotDifficultyHelper"; import { BotHelper } from "@spt-aki/helpers/BotHelper"; 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 { IBotBase } from "@spt-aki/models/eft/common/tables/IBotBase"; import { IBotCore } from "@spt-aki/models/eft/common/tables/IBotCore"; @@ -179,7 +179,7 @@ export class BotController * @param info bot generation request info * @returns IBotBase array */ - public generate(sessionId: string, info: IGenerateBotsRequestData): IBotBase[] + public async generate(sessionId: string, info: IGenerateBotsRequestData): Promise { const pmcProfile = this.profileHelper.getPmcProfile(sessionId); @@ -199,11 +199,11 @@ export class BotController * @param sessionId Session id * @returns */ - protected generateBotsFirstTime( + protected async generateBotsFirstTime( request: IGenerateBotsRequestData, pmcProfile: IPmcData, sessionId: string, - ): IBotBase[] + ): Promise { // Clear bot cache before any work starts this.botGenerationCacheService.clearStoredBots(); @@ -211,6 +211,7 @@ export class BotController const allPmcsHaveSameNameAsPlayer = this.randomUtil.getChance100( this.pmcConfig.allPMCsHavePlayerNameWithRandomPrefixChance, ); + const conditionPromises: Promise[] = []; for (const condition of request.conditions) { const botGenerationDetails: BotGenerationDetails = { @@ -227,45 +228,80 @@ export class BotController allPmcsHaveSameNameAsPlayer: allPmcsHaveSameNameAsPlayer, }; - // Event bots need special actions to occur, set data up for them - 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, - ); - } + conditionPromises.push(this.generateWithBotDetails(condition, botGenerationDetails, sessionId)); + } - // 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); - } + await Promise.all(conditionPromises).then((p) => Promise.all(p)); - // Loop over and make x bots for this bot wave - 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]); - } + return []; + } + /** + * 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 + { + 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[] = []; + 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( `Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${ botGenerationDetails.eventRole ?? "" }) ${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 + { + 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 * @returns Single IBotBase object */ - protected returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): IBotBase[] + protected async returnSingleBotFromCache(sessionId: string, request: IGenerateBotsRequestData): Promise { const pmcProfile = this.profileHelper.getPmcProfile(sessionId); const requestedBot = request.conditions[0]; @@ -334,18 +370,21 @@ export class BotController // Check cache for bot using above key if (!this.botGenerationCacheService.cacheHasBotOfRole(cacheKey)) { + const botPromises: Promise[] = []; // No bot in cache, generate new and return one for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++) { - const botToCache = this.botGenerator.prepareAndGenerateBot(sessionId, botGenerationDetails); - this.botGenerationCacheService.storeBots(cacheKey, [botToCache]); + botPromises.push(this.generateSingleBotAndStoreInCache(botGenerationDetails, sessionId, cacheKey)); } - this.logger.debug( - `Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${ - botGenerationDetails.eventRole ?? "" - }) ${botGenerationDetails.botDifficulty} bots`, - ); + await Promise.all(botPromises).then(() => + { + this.logger.debug( + `Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${ + botGenerationDetails.eventRole ?? "" + }) ${botGenerationDetails.botDifficulty} bots`, + ); + }); } const desiredBot = this.botGenerationCacheService.getBot(cacheKey); diff --git a/project/src/di/Router.ts b/project/src/di/Router.ts index 18e5b8c6..1c66e0ae 100644 --- a/project/src/di/Router.ts +++ b/project/src/di/Router.ts @@ -42,7 +42,7 @@ export class StaticRouter extends Router super(); } - public handleStatic(url: string, info: any, sessionID: string, output: string): any + public async handleStatic(url: string, info: any, sessionID: string, output: string): Promise { return this.routes.find((route) => route.url === url).action(url, info, sessionID, output); } @@ -60,7 +60,7 @@ export class DynamicRouter extends Router super(); } - public handleDynamic(url: string, info: any, sessionID: string, output: string): any + public async handleDynamic(url: string, info: any, sessionID: string, output: string): Promise { 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 export class ItemEventRouterDefinition extends Router { - public handleItemEvent( + public async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, output: IItemEventRouterResponse, - ): void + ): Promise { throw new Error("This method needs to be overrode by the router classes"); } @@ -103,6 +103,9 @@ export class HandledRoute 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, + ) {} } diff --git a/project/src/routers/HttpRouter.ts b/project/src/routers/HttpRouter.ts index 108982e7..5259d9be 100644 --- a/project/src/routers/HttpRouter.ts +++ b/project/src/routers/HttpRouter.ts @@ -31,7 +31,7 @@ export class HttpRouter return map; } - public getResponse(req: IncomingMessage, info: any, sessionID: string): string + public async getResponse(req: IncomingMessage, info: any, sessionID: string): Promise { const wrapper: ResponseWrapper = new ResponseWrapper(""); let url = req.url; @@ -41,10 +41,10 @@ export class HttpRouter { 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) { - 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 @@ -56,14 +56,14 @@ export class HttpRouter return wrapper.output; } - protected handleRoute( + protected async handleRoute( url: string, info: any, sessionID: string, wrapper: ResponseWrapper, routers: Router[], dynamic: boolean, - ): boolean + ): Promise { let matched = false; for (const route of routers) @@ -72,11 +72,11 @@ export class HttpRouter { 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 { - 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; } diff --git a/project/src/routers/ItemEventRouter.ts b/project/src/routers/ItemEventRouter.ts index d19899c1..ebad666e 100644 --- a/project/src/routers/ItemEventRouter.ts +++ b/project/src/routers/ItemEventRouter.ts @@ -27,7 +27,7 @@ export class ItemEventRouter * @param sessionID Session id * @returns Item response */ - public handleEvents(info: IItemEventRouterRequest, sessionID: string): IItemEventRouterResponse + public async handleEvents(info: IItemEventRouterRequest, sessionID: string): Promise { const output = this.eventOutputHolder.getOutput(sessionID); @@ -39,7 +39,7 @@ export class ItemEventRouter if (eventRouter) { 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) { break; diff --git a/project/src/routers/dynamic/BotDynamicRouter.ts b/project/src/routers/dynamic/BotDynamicRouter.ts index 53207788..0e975dc4 100644 --- a/project/src/routers/dynamic/BotDynamicRouter.ts +++ b/project/src/routers/dynamic/BotDynamicRouter.ts @@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe"; import { BotCallbacks } from "@spt-aki/callbacks/BotCallbacks"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; +import { Difficulties } from "@spt-aki/models/eft/common/tables/IBotType"; @injectable() export class BotDynamicRouter extends DynamicRouter @@ -11,35 +12,45 @@ export class BotDynamicRouter extends DynamicRouter super([ new RouteAction( "/singleplayer/settings/bot/limit/", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.botCallbacks.getBotLimit(url, info, sessionID); }, ), new RouteAction( "/singleplayer/settings/bot/difficulty/", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.botCallbacks.getBotDifficulty(url, info, sessionID); }, ), new RouteAction( +<<<<<<< HEAD + "/singleplayer/settings/bot/difficulties/", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => +======= "/singleplayer/settings/bot/difficulties", (url: string, info: any, sessionID: string, output: string): any => +>>>>>>> 3.9.0-DEV { return this.botCallbacks.getAllBotDifficulties(url, info, sessionID); }, ), new RouteAction( "/singleplayer/settings/bot/maxCap", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.botCallbacks.getBotCap(); }, ), new RouteAction( "/singleplayer/settings/bot/getBotBehaviours/", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.botCallbacks.getBotBehaviours(); }, diff --git a/project/src/routers/dynamic/BundleDynamicRouter.ts b/project/src/routers/dynamic/BundleDynamicRouter.ts index 929eba50..a3605901 100644 --- a/project/src/routers/dynamic/BundleDynamicRouter.ts +++ b/project/src/routers/dynamic/BundleDynamicRouter.ts @@ -9,10 +9,13 @@ export class BundleDynamicRouter extends DynamicRouter constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks) { super([ - new RouteAction(".bundle", (url: string, info: any, sessionID: string, output: string): any => - { - return this.bundleCallbacks.getBundle(url, info, sessionID); - }), + new RouteAction( + ".bundle", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.bundleCallbacks.getBundle(url, info, sessionID); + }, + ), ]); } } diff --git a/project/src/routers/dynamic/CustomizationDynamicRouter.ts b/project/src/routers/dynamic/CustomizationDynamicRouter.ts index 1a146349..62946364 100644 --- a/project/src/routers/dynamic/CustomizationDynamicRouter.ts +++ b/project/src/routers/dynamic/CustomizationDynamicRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { CustomizationCallbacks } from "@spt-aki/callbacks/CustomizationCallbacks"; 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() export class CustomizationDynamicRouter extends DynamicRouter @@ -11,7 +13,12 @@ export class CustomizationDynamicRouter extends DynamicRouter super([ new RouteAction( "/client/trading/customization/", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.customizationCallbacks.getTraderSuits(url, info, sessionID); }, diff --git a/project/src/routers/dynamic/DataDynamicRouter.ts b/project/src/routers/dynamic/DataDynamicRouter.ts index 82ab4860..ff7c7ac7 100644 --- a/project/src/routers/dynamic/DataDynamicRouter.ts +++ b/project/src/routers/dynamic/DataDynamicRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { DataCallbacks } from "@spt-aki/callbacks/DataCallbacks"; 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() export class DataDynamicRouter extends DynamicRouter @@ -9,18 +11,37 @@ export class DataDynamicRouter extends DynamicRouter constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks) { super([ - new RouteAction("/client/menu/locale/", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getLocalesMenu(url, info, sessionID); - }), - new RouteAction("/client/locale/", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getLocalesGlobal(url, info, sessionID); - }), - new RouteAction("/client/items/prices/", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getItemPrices(url, info, sessionID); - }), + new RouteAction( + "/client/menu/locale/", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.dataCallbacks.getLocalesMenu(url, info, sessionID); + }, + ), + new RouteAction( + "/client/locale/", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.dataCallbacks.getLocalesGlobal(url, info, sessionID); + }, + ), + new RouteAction( + "/client/items/prices/", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.dataCallbacks.getItemPrices(url, info, sessionID); + }, + ), ]); } } diff --git a/project/src/routers/dynamic/HttpDynamicRouter.ts b/project/src/routers/dynamic/HttpDynamicRouter.ts index c7e677ec..0f07e089 100644 --- a/project/src/routers/dynamic/HttpDynamicRouter.ts +++ b/project/src/routers/dynamic/HttpDynamicRouter.ts @@ -9,18 +9,27 @@ export class HttpDynamicRouter extends DynamicRouter constructor(@inject("ImageRouter") protected imageRouter: ImageRouter) { super([ - new RouteAction(".jpg", (url: string, info: any, sessionID: string, output: string): any => - { - return this.imageRouter.getImage(); - }), - new RouteAction(".png", (url: string, info: any, sessionID: string, output: string): any => - { - return this.imageRouter.getImage(); - }), - new RouteAction(".ico", (url: string, info: any, sessionID: string, output: string): any => - { - return this.imageRouter.getImage(); - }), + new RouteAction( + ".jpg", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.imageRouter.getImage(); + }, + ), + new RouteAction( + ".png", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.imageRouter.getImage(); + }, + ), + new RouteAction( + ".ico", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.imageRouter.getImage(); + }, + ), ]); } } diff --git a/project/src/routers/dynamic/InraidDynamicRouter.ts b/project/src/routers/dynamic/InraidDynamicRouter.ts index 26e89f72..6b943645 100644 --- a/project/src/routers/dynamic/InraidDynamicRouter.ts +++ b/project/src/routers/dynamic/InraidDynamicRouter.ts @@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe"; import { InraidCallbacks } from "@spt-aki/callbacks/InraidCallbacks"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; +import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData"; @injectable() export class InraidDynamicRouter extends DynamicRouter @@ -11,14 +12,14 @@ export class InraidDynamicRouter extends DynamicRouter super([ new RouteAction( "/client/location/getLocalloot", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.registerPlayer(url, info, sessionID); }, ), new RouteAction( "/singleplayer/traderServices/getTraderServices/", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.getTraderServices(url, info, sessionID); }, diff --git a/project/src/routers/dynamic/LocationDynamicRouter.ts b/project/src/routers/dynamic/LocationDynamicRouter.ts index 76eaa6ba..aa2d6bbf 100644 --- a/project/src/routers/dynamic/LocationDynamicRouter.ts +++ b/project/src/routers/dynamic/LocationDynamicRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { LocationCallbacks } from "@spt-aki/callbacks/LocationCallbacks"; 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() export class LocationDynamicRouter extends DynamicRouter @@ -11,7 +13,12 @@ export class LocationDynamicRouter extends DynamicRouter super([ new RouteAction( "/client/location/getLocalloot", - (url: string, info: any, sessionID: string, _output: string): any => + async ( + url: string, + info: any, + sessionID: string, + _output: string, + ): Promise> => { return this.locationCallbacks.getLocation(url, info, sessionID); }, diff --git a/project/src/routers/dynamic/NotifierDynamicRouter.ts b/project/src/routers/dynamic/NotifierDynamicRouter.ts index cf8c86b8..b91c4c70 100644 --- a/project/src/routers/dynamic/NotifierDynamicRouter.ts +++ b/project/src/routers/dynamic/NotifierDynamicRouter.ts @@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe"; import { NotifierCallbacks } from "@spt-aki/callbacks/NotifierCallbacks"; import { DynamicRouter, RouteAction } from "@spt-aki/di/Router"; +import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData"; @injectable() export class NotifierDynamicRouter extends DynamicRouter @@ -9,21 +10,40 @@ export class NotifierDynamicRouter extends DynamicRouter constructor(@inject("NotifierCallbacks") protected notifierCallbacks: NotifierCallbacks) { super([ - new RouteAction("/?last_id", (url: string, info: any, sessionID: string, output: string): any => - { - return this.notifierCallbacks.notify(url, info, sessionID); - }), - new RouteAction("/notifierServer", (url: string, info: any, sessionID: string, output: string): any => - { - return this.notifierCallbacks.notify(url, info, sessionID); - }), - new RouteAction("/push/notifier/get/", (url: string, info: any, sessionID: string, output: string): any => - { - return this.notifierCallbacks.getNotifier(url, info, sessionID); - }), + new RouteAction( + "/?last_id", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.notifierCallbacks.notify(url, info, sessionID); + }, + ), + new RouteAction( + "/notifierServer", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.notifierCallbacks.notify(url, info, sessionID); + }, + ), + new RouteAction( + "/push/notifier/get/", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.notifierCallbacks.getNotifier(url, info, sessionID); + }, + ), new RouteAction( "/push/notifier/getwebsocket/", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.notifierCallbacks.getNotifier(url, info, sessionID); }, diff --git a/project/src/routers/dynamic/TraderDynamicRouter.ts b/project/src/routers/dynamic/TraderDynamicRouter.ts index b5c92eed..61b68d22 100644 --- a/project/src/routers/dynamic/TraderDynamicRouter.ts +++ b/project/src/routers/dynamic/TraderDynamicRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { TraderCallbacks } from "@spt-aki/callbacks/TraderCallbacks"; 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() export class TraderDynamicRouter extends DynamicRouter @@ -11,14 +13,24 @@ export class TraderDynamicRouter extends DynamicRouter super([ new RouteAction( "/client/trading/api/getTrader/", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.traderCallbacks.getTrader(url, info, sessionID); }, ), new RouteAction( "/client/trading/api/getTraderAssort/", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.traderCallbacks.getAssort(url, info, sessionID); }, diff --git a/project/src/routers/item_events/CustomizationItemEventRouter.ts b/project/src/routers/item_events/CustomizationItemEventRouter.ts index f944fed4..8ace1743 100644 --- a/project/src/routers/item_events/CustomizationItemEventRouter.ts +++ b/project/src/routers/item_events/CustomizationItemEventRouter.ts @@ -20,12 +20,12 @@ export class CustomizationItemEventRouter extends ItemEventRouterDefinition return [new HandledRoute("CustomizationWear", false), new HandledRoute("CustomizationBuy", false)]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/HealthItemEventRouter.ts b/project/src/routers/item_events/HealthItemEventRouter.ts index 807e9877..b0c5cb1b 100644 --- a/project/src/routers/item_events/HealthItemEventRouter.ts +++ b/project/src/routers/item_events/HealthItemEventRouter.ts @@ -24,12 +24,12 @@ export class HealthItemEventRouter extends ItemEventRouterDefinition ]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/HideoutItemEventRouter.ts b/project/src/routers/item_events/HideoutItemEventRouter.ts index 73dbd451..6424097f 100644 --- a/project/src/routers/item_events/HideoutItemEventRouter.ts +++ b/project/src/routers/item_events/HideoutItemEventRouter.ts @@ -32,13 +32,13 @@ export class HideoutItemEventRouter extends ItemEventRouterDefinition ]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, output: IItemEventRouterResponse, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/InsuranceItemEventRouter.ts b/project/src/routers/item_events/InsuranceItemEventRouter.ts index 087d8145..8a598c97 100644 --- a/project/src/routers/item_events/InsuranceItemEventRouter.ts +++ b/project/src/routers/item_events/InsuranceItemEventRouter.ts @@ -20,12 +20,12 @@ export class InsuranceItemEventRouter extends ItemEventRouterDefinition return [new HandledRoute("Insure", false)]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/InventoryItemEventRouter.ts b/project/src/routers/item_events/InventoryItemEventRouter.ts index 1e502f39..d27e7324 100644 --- a/project/src/routers/item_events/InventoryItemEventRouter.ts +++ b/project/src/routers/item_events/InventoryItemEventRouter.ts @@ -46,13 +46,13 @@ export class InventoryItemEventRouter extends ItemEventRouterDefinition ]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, output: IItemEventRouterResponse, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/NoteItemEventRouter.ts b/project/src/routers/item_events/NoteItemEventRouter.ts index ce0b79de..06de379e 100644 --- a/project/src/routers/item_events/NoteItemEventRouter.ts +++ b/project/src/routers/item_events/NoteItemEventRouter.ts @@ -25,12 +25,12 @@ export class NoteItemEventRouter extends ItemEventRouterDefinition ]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: INoteActionData, sessionID: string, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/QuestItemEventRouter.ts b/project/src/routers/item_events/QuestItemEventRouter.ts index 7138e81b..23664eb4 100644 --- a/project/src/routers/item_events/QuestItemEventRouter.ts +++ b/project/src/routers/item_events/QuestItemEventRouter.ts @@ -27,12 +27,12 @@ export class QuestItemEventRouter extends ItemEventRouterDefinition ]; } - public override handleItemEvent( + public override async handleItemEvent( eventAction: string, pmcData: IPmcData, body: any, sessionID: string, - ): IItemEventRouterResponse + ): Promise { this.logger.debug(`${eventAction} ${body.qid}`); switch (eventAction) diff --git a/project/src/routers/item_events/RagfairItemEventRouter.ts b/project/src/routers/item_events/RagfairItemEventRouter.ts index ae65e463..229cb908 100644 --- a/project/src/routers/item_events/RagfairItemEventRouter.ts +++ b/project/src/routers/item_events/RagfairItemEventRouter.ts @@ -22,12 +22,12 @@ export class RagfairItemEventRouter extends ItemEventRouterDefinition ]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/RepairItemEventRouter.ts b/project/src/routers/item_events/RepairItemEventRouter.ts index af906ef2..769a399c 100644 --- a/project/src/routers/item_events/RepairItemEventRouter.ts +++ b/project/src/routers/item_events/RepairItemEventRouter.ts @@ -18,12 +18,12 @@ export class RepairItemEventRouter extends ItemEventRouterDefinition return [new HandledRoute("Repair", false), new HandledRoute("TraderRepair", false)]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/TradeItemEventRouter.ts b/project/src/routers/item_events/TradeItemEventRouter.ts index c36ba60f..4e164dcf 100644 --- a/project/src/routers/item_events/TradeItemEventRouter.ts +++ b/project/src/routers/item_events/TradeItemEventRouter.ts @@ -22,12 +22,12 @@ export class TradeItemEventRouter extends ItemEventRouterDefinition ]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/item_events/WishlistItemEventRouter.ts b/project/src/routers/item_events/WishlistItemEventRouter.ts index dd15eae4..5744e4b1 100644 --- a/project/src/routers/item_events/WishlistItemEventRouter.ts +++ b/project/src/routers/item_events/WishlistItemEventRouter.ts @@ -18,12 +18,12 @@ export class WishlistItemEventRouter extends ItemEventRouterDefinition return [new HandledRoute("AddToWishList", false), new HandledRoute("RemoveFromWishList", false)]; } - public override handleItemEvent( + public override async handleItemEvent( url: string, pmcData: IPmcData, body: any, sessionID: string, - ): IItemEventRouterResponse + ): Promise { switch (url) { diff --git a/project/src/routers/static/AchievementStaticRouter.ts b/project/src/routers/static/AchievementStaticRouter.ts index 54ae8de3..bed39502 100644 --- a/project/src/routers/static/AchievementStaticRouter.ts +++ b/project/src/routers/static/AchievementStaticRouter.ts @@ -2,6 +2,9 @@ import { inject, injectable } from "tsyringe"; import { AchievementCallbacks } from "@spt-aki/callbacks/AchievementCallbacks"; 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() export class AchievementStaticRouter extends StaticRouter @@ -12,7 +15,12 @@ export class AchievementStaticRouter extends StaticRouter new RouteAction( "/client/achievement/list", // 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> => { return this.achievementCallbacks.getAchievements(url, info, sessionID); }, @@ -21,7 +29,12 @@ export class AchievementStaticRouter extends StaticRouter new RouteAction( "/client/achievement/statistic", // 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> => { return this.achievementCallbacks.statistic(url, info, sessionID); }, diff --git a/project/src/routers/static/BotStaticRouter.ts b/project/src/routers/static/BotStaticRouter.ts index 4a1968e5..1f6f42b0 100644 --- a/project/src/routers/static/BotStaticRouter.ts +++ b/project/src/routers/static/BotStaticRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { BotCallbacks } from "@spt-aki/callbacks/BotCallbacks"; 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() export class BotStaticRouter extends StaticRouter @@ -11,7 +13,12 @@ export class BotStaticRouter extends StaticRouter super([ new RouteAction( "/client/game/bot/generate", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.botCallbacks.generateBots(url, info, sessionID); }, diff --git a/project/src/routers/static/BuildStaticRouter.ts b/project/src/routers/static/BuildStaticRouter.ts index 9df72665..52585c9a 100644 --- a/project/src/routers/static/BuildStaticRouter.ts +++ b/project/src/routers/static/BuildStaticRouter.ts @@ -2,6 +2,9 @@ import { inject, injectable } from "tsyringe"; import { BuildsCallbacks } from "@spt-aki/callbacks/BuildsCallbacks"; 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() export class BuildsStaticRouter extends StaticRouter @@ -12,7 +15,12 @@ export class BuildsStaticRouter extends StaticRouter new RouteAction( "/client/builds/list", // 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> => { return this.buildsCallbacks.getBuilds(url, info, sessionID); }, @@ -20,7 +28,7 @@ export class BuildsStaticRouter extends StaticRouter new RouteAction( "/client/builds/magazine/save", // 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 => { return this.buildsCallbacks.createMagazineTemplate(url, info, sessionID); }, @@ -28,7 +36,7 @@ export class BuildsStaticRouter extends StaticRouter new RouteAction( "/client/builds/weapon/save", // 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 => { return this.buildsCallbacks.setWeapon(url, info, sessionID); }, @@ -36,7 +44,7 @@ export class BuildsStaticRouter extends StaticRouter new RouteAction( "/client/builds/equipment/save", // 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 => { return this.buildsCallbacks.setEquipment(url, info, sessionID); }, @@ -44,7 +52,7 @@ export class BuildsStaticRouter extends StaticRouter new RouteAction( "/client/builds/delete", // 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 => { return this.buildsCallbacks.deleteBuild(url, info, sessionID); }, diff --git a/project/src/routers/static/BundleStaticRouter.ts b/project/src/routers/static/BundleStaticRouter.ts index a982835c..d2cb8426 100644 --- a/project/src/routers/static/BundleStaticRouter.ts +++ b/project/src/routers/static/BundleStaticRouter.ts @@ -9,10 +9,13 @@ export class BundleStaticRouter extends StaticRouter constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks) { super([ - new RouteAction("/singleplayer/bundles", (url: string, info: any, sessionID: string, output: string): any => - { - return this.bundleCallbacks.getBundles(url, info, sessionID); - }), + new RouteAction( + "/singleplayer/bundles", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.bundleCallbacks.getBundles(url, info, sessionID); + }, + ), ]); } } diff --git a/project/src/routers/static/ClientLogStaticRouter.ts b/project/src/routers/static/ClientLogStaticRouter.ts index 5472199b..c4de8db3 100644 --- a/project/src/routers/static/ClientLogStaticRouter.ts +++ b/project/src/routers/static/ClientLogStaticRouter.ts @@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe"; import { ClientLogCallbacks } from "@spt-aki/callbacks/ClientLogCallbacks"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; +import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData"; @injectable() export class ClientLogStaticRouter extends StaticRouter @@ -9,17 +10,23 @@ export class ClientLogStaticRouter extends StaticRouter constructor(@inject("ClientLogCallbacks") protected clientLogCallbacks: ClientLogCallbacks) { super([ - new RouteAction("/singleplayer/log", (url: string, info: any, sessionID: string, output: string): any => - { - return this.clientLogCallbacks.clientLog(url, info, sessionID); - }), - new RouteAction("/singleplayer/release", (url: string, info: any, sessionID: string, output: string) => - { - return this.clientLogCallbacks.releaseNotes(); - }), + new RouteAction( + "/singleplayer/log", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.clientLogCallbacks.clientLog(url, info, sessionID); + }, + ), + new RouteAction( + "/singleplayer/release", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.clientLogCallbacks.releaseNotes(); + }, + ), new RouteAction( "/singleplayer/enableBSGlogging", - (url: string, info: any, sessionID: string, output: string) => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.clientLogCallbacks.bsgLogging(); }, diff --git a/project/src/routers/static/CustomizationStaticRouter.ts b/project/src/routers/static/CustomizationStaticRouter.ts index c2fe4b29..1bb414ae 100644 --- a/project/src/routers/static/CustomizationStaticRouter.ts +++ b/project/src/routers/static/CustomizationStaticRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { CustomizationCallbacks } from "@spt-aki/callbacks/CustomizationCallbacks"; 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() export class CustomizationStaticRouter extends StaticRouter @@ -11,7 +13,12 @@ export class CustomizationStaticRouter extends StaticRouter super([ new RouteAction( "/client/trading/customization/storage", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.customizationCallbacks.getSuits(url, info, sessionID); }, diff --git a/project/src/routers/static/DataStaticRouter.ts b/project/src/routers/static/DataStaticRouter.ts index cbb7e7a0..4a0ef961 100644 --- a/project/src/routers/static/DataStaticRouter.ts +++ b/project/src/routers/static/DataStaticRouter.ts @@ -2,6 +2,15 @@ import { inject, injectable } from "tsyringe"; import { DataCallbacks } from "@spt-aki/callbacks/DataCallbacks"; 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() export class DataStaticRouter extends StaticRouter @@ -9,68 +18,136 @@ export class DataStaticRouter extends StaticRouter constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks) { super([ - new RouteAction("/client/settings", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getSettings(url, info, sessionID); - }), - new RouteAction("/client/globals", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getGlobals(url, info, sessionID); - }), - new RouteAction("/client/items", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getTemplateItems(url, info, sessionID); - }), + new RouteAction( + "/client/settings", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.dataCallbacks.getSettings(url, info, sessionID); + }, + ), + new RouteAction( + "/client/globals", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.dataCallbacks.getGlobals(url, info, sessionID); + }, + ), + new RouteAction( + "/client/items", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.dataCallbacks.getTemplateItems(url, info, sessionID); + }, + ), new RouteAction( "/client/handbook/templates", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dataCallbacks.getTemplateHandbook(url, info, sessionID); }, ), - new RouteAction("/client/customization", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getTemplateSuits(url, info, sessionID); - }), + new RouteAction( + "/client/customization", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise>> => + { + return this.dataCallbacks.getTemplateSuits(url, info, sessionID); + }, + ), new RouteAction( "/client/account/customization", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dataCallbacks.getTemplateCharacter(url, info, sessionID); }, ), new RouteAction( "/client/hideout/production/recipes", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dataCallbacks.gethideoutProduction(url, info, sessionID); }, ), new RouteAction( "/client/hideout/settings", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dataCallbacks.getHideoutSettings(url, info, sessionID); }, ), - new RouteAction("/client/hideout/areas", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getHideoutAreas(url, info, sessionID); - }), + new RouteAction( + "/client/hideout/areas", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.dataCallbacks.getHideoutAreas(url, info, sessionID); + }, + ), new RouteAction( "/client/hideout/production/scavcase/recipes", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dataCallbacks.getHideoutScavcase(url, info, sessionID); }, ), - new RouteAction("/client/languages", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dataCallbacks.getLocalesLanguages(url, info, sessionID); - }), + new RouteAction( + "/client/languages", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise>> => + { + return this.dataCallbacks.getLocalesLanguages(url, info, sessionID); + }, + ), new RouteAction( "/client/hideout/qte/list", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.dataCallbacks.getQteList(url, info, sessionID); }, diff --git a/project/src/routers/static/DialogStaticRouter.ts b/project/src/routers/static/DialogStaticRouter.ts index a22acc6d..fd417552 100644 --- a/project/src/routers/static/DialogStaticRouter.ts +++ b/project/src/routers/static/DialogStaticRouter.ts @@ -2,6 +2,14 @@ import { inject, injectable } from "tsyringe"; import { DialogueCallbacks } from "@spt-aki/callbacks/DialogueCallbacks"; 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() export class DialogStaticRouter extends StaticRouter @@ -11,138 +19,237 @@ export class DialogStaticRouter extends StaticRouter super([ new RouteAction( "/client/chatServer/list", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.getChatServerList(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/list", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.getMailDialogList(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/view", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.getMailDialogView(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/info", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.getMailDialogInfo(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/remove", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.removeDialog(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/pin", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.pinDialog(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/unpin", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.unpinDialog(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/read", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.setRead(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/remove", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.removeMail(url, info, sessionID); }, ), new RouteAction( "/client/mail/dialog/getAllAttachments", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.getAllAttachments(url, info, sessionID); }, ), - new RouteAction("/client/mail/msg/send", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dialogueCallbacks.sendMessage(url, info, sessionID); - }), + new RouteAction( + "/client/mail/msg/send", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.dialogueCallbacks.sendMessage(url, info, sessionID); + }, + ), new RouteAction( "/client/mail/dialog/clear", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.clearMail(url, info, sessionID); }, ), - new RouteAction("/client/friend/list", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dialogueCallbacks.getFriendList(url, info, sessionID); - }), + new RouteAction( + "/client/friend/list", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.dialogueCallbacks.getFriendList(url, info, sessionID); + }, + ), new RouteAction( "/client/friend/request/list/outbox", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.listOutbox(url, info, sessionID); }, ), new RouteAction( "/client/friend/request/list/inbox", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.listInbox(url, info, sessionID); }, ), new RouteAction( "/client/friend/request/send", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.sendFriendRequest(url, info, sessionID); }, ), new RouteAction( "/client/friend/request/accept", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.acceptFriendRequest(url, info, sessionID); }, ), new RouteAction( "/client/friend/request/cancel", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.dialogueCallbacks.cancelFriendRequest(url, info, sessionID); }, ), - new RouteAction("/client/friend/delete", (url: string, info: any, sessionID: string, output: string): any => - { - return this.dialogueCallbacks.deleteFriend(url, info, sessionID); - }), + new RouteAction( + "/client/friend/delete", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.dialogueCallbacks.deleteFriend(url, info, sessionID); + }, + ), new RouteAction( "/client/friend/ignore/set", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.dialogueCallbacks.ignoreFriend(url, info, sessionID); }, ), new RouteAction( "/client/friend/ignore/remove", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.dialogueCallbacks.unIgnoreFriend(url, info, sessionID); }, diff --git a/project/src/routers/static/GameStaticRouter.ts b/project/src/routers/static/GameStaticRouter.ts index 224d0ffc..329cab8e 100644 --- a/project/src/routers/static/GameStaticRouter.ts +++ b/project/src/routers/static/GameStaticRouter.ts @@ -2,6 +2,17 @@ import { inject, injectable } from "tsyringe"; import { GameCallbacks } from "@spt-aki/callbacks/GameCallbacks"; 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() export class GameStaticRouter extends StaticRouter @@ -9,61 +20,119 @@ export class GameStaticRouter extends StaticRouter constructor(@inject("GameCallbacks") protected gameCallbacks: GameCallbacks) { super([ - new RouteAction("/client/game/config", (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.getGameConfig(url, info, sessionID); - }), - new RouteAction("/client/game/mode", (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.getGameMode(url, info, sessionID); - }), - new RouteAction("/client/server/list", (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.getServer(url, info, sessionID); - }), + new RouteAction( + "/client/game/config", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.gameCallbacks.getGameConfig(url, info, sessionID); + }, + ), + new RouteAction( + "/client/game/mode", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.gameCallbacks.getGameMode(url, info, sessionID); + }, + ), + new RouteAction( + "/client/server/list", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.gameCallbacks.getServer(url, info, sessionID); + }, + ), new RouteAction( "/client/match/group/current", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.gameCallbacks.getCurrentGroup(url, info, sessionID); }, ), new RouteAction( "/client/game/version/validate", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.gameCallbacks.versionValidate(url, info, sessionID); }, ), - new RouteAction("/client/game/start", (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.gameStart(url, info, sessionID); - }), - new RouteAction("/client/game/logout", (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.gameLogout(url, info, sessionID); - }), - new RouteAction("/client/checkVersion", (url: string, info: any, sessionID: string, output: string): any => - { - return this.gameCallbacks.validateGameVersion(url, info, sessionID); - }), + new RouteAction( + "/client/game/start", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.gameCallbacks.gameStart(url, info, sessionID); + }, + ), + new RouteAction( + "/client/game/logout", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.gameCallbacks.gameLogout(url, info, sessionID); + }, + ), + new RouteAction( + "/client/checkVersion", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.gameCallbacks.validateGameVersion(url, info, sessionID); + }, + ), new RouteAction( "/client/game/keepalive", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.gameCallbacks.gameKeepalive(url, info, sessionID); }, ), new RouteAction( "/singleplayer/settings/version", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.gameCallbacks.getVersion(url, info, sessionID); }, ), new RouteAction( "/client/reports/lobby/send", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.gameCallbacks.reportNickname(url, info, sessionID); }, @@ -71,7 +140,7 @@ export class GameStaticRouter extends StaticRouter new RouteAction( "/singleplayer/settings/getRaidTime", // 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 => { return this.gameCallbacks.getRaidTime(url, info, sessionID); }, diff --git a/project/src/routers/static/HealthStaticRouter.ts b/project/src/routers/static/HealthStaticRouter.ts index f20da993..0e804f3d 100644 --- a/project/src/routers/static/HealthStaticRouter.ts +++ b/project/src/routers/static/HealthStaticRouter.ts @@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe"; import { HealthCallbacks } from "@spt-aki/callbacks/HealthCallbacks"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; +import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData"; @injectable() export class HealthStaticRouter extends StaticRouter @@ -9,13 +10,26 @@ export class HealthStaticRouter extends StaticRouter constructor(@inject("HealthCallbacks") protected healthCallbacks: HealthCallbacks) { super([ - new RouteAction("/player/health/sync", (url: string, info: any, sessionID: string, output: string): any => - { - return this.healthCallbacks.syncHealth(url, info, sessionID); - }), + new RouteAction( + "/player/health/sync", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.healthCallbacks.syncHealth(url, info, sessionID); + }, + ), new RouteAction( "/client/hideout/workout", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.healthCallbacks.handleWorkoutEffects(url, info, sessionID); }, diff --git a/project/src/routers/static/InraidStaticRouter.ts b/project/src/routers/static/InraidStaticRouter.ts index a0f77653..8a97439e 100644 --- a/project/src/routers/static/InraidStaticRouter.ts +++ b/project/src/routers/static/InraidStaticRouter.ts @@ -2,6 +2,7 @@ import { inject, injectable } from "tsyringe"; import { InraidCallbacks } from "@spt-aki/callbacks/InraidCallbacks"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; +import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData"; @injectable() export class InraidStaticRouter extends StaticRouter @@ -9,55 +10,58 @@ export class InraidStaticRouter extends StaticRouter constructor(@inject("InraidCallbacks") protected inraidCallbacks: InraidCallbacks) { super([ - new RouteAction("/raid/profile/save", (url: string, info: any, sessionID: string, output: string): any => - { - return this.inraidCallbacks.saveProgress(url, info, sessionID); - }), + new RouteAction( + "/raid/profile/save", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.inraidCallbacks.saveProgress(url, info, sessionID); + }, + ), new RouteAction( "/singleplayer/settings/raid/endstate", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.getRaidEndState(); }, ), new RouteAction( "/singleplayer/settings/raid/menu", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.getRaidMenuSettings(); }, ), new RouteAction( "/singleplayer/airdrop/config", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.getAirdropConfig(); }, ), new RouteAction( "/singleplayer/btr/config", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.getBTRConfig(); }, ), new RouteAction( "/singleplayer/traderServices/itemDelivery", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.itemDelivery(url, info, sessionID); }, ), new RouteAction( "/singleplayer/scav/traitorscavhostile", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.getTraitorScavHostileChance(url, info, sessionID); }, ), new RouteAction( "/singleplayer/sandbox/maxpatrol", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.inraidCallbacks.getSandboxMaxPatrolValue(url, info, sessionID); }, diff --git a/project/src/routers/static/InsuranceStaticRouter.ts b/project/src/routers/static/InsuranceStaticRouter.ts index dcb333ea..0bf83738 100644 --- a/project/src/routers/static/InsuranceStaticRouter.ts +++ b/project/src/routers/static/InsuranceStaticRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { InsuranceCallbacks } from "@spt-aki/callbacks/InsuranceCallbacks"; 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() export class InsuranceStaticRouter extends StaticRouter @@ -11,7 +13,12 @@ export class InsuranceStaticRouter extends StaticRouter super([ new RouteAction( "/client/insurance/items/list/cost", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.insuranceCallbacks.getInsuranceCost(url, info, sessionID); }, diff --git a/project/src/routers/static/ItemEventStaticRouter.ts b/project/src/routers/static/ItemEventStaticRouter.ts index 54d668f2..4c7d9ef2 100644 --- a/project/src/routers/static/ItemEventStaticRouter.ts +++ b/project/src/routers/static/ItemEventStaticRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { ItemEventCallbacks } from "@spt-aki/callbacks/ItemEventCallbacks"; 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() export class ItemEventStaticRouter extends StaticRouter @@ -11,7 +13,12 @@ export class ItemEventStaticRouter extends StaticRouter super([ new RouteAction( "/client/game/profile/items/moving", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.itemEventCallbacks.handleEvents(url, info, sessionID); }, diff --git a/project/src/routers/static/LauncherStaticRouter.ts b/project/src/routers/static/LauncherStaticRouter.ts index 0cdae88c..2bd353cf 100644 --- a/project/src/routers/static/LauncherStaticRouter.ts +++ b/project/src/routers/static/LauncherStaticRouter.ts @@ -9,87 +9,93 @@ export class LauncherStaticRouter extends StaticRouter constructor(@inject("LauncherCallbacks") protected launcherCallbacks: LauncherCallbacks) { super([ - new RouteAction("/launcher/ping", (url: string, info: any, sessionID: string, output: string): any => - { - return this.launcherCallbacks.ping(url, info, sessionID); - }), + new RouteAction( + "/launcher/ping", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.launcherCallbacks.ping(url, info, sessionID); + }, + ), new RouteAction( "/launcher/server/connect", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.connect(); }, ), new RouteAction( "/launcher/profile/login", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.login(url, info, sessionID); }, ), new RouteAction( "/launcher/profile/register", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.register(url, info, sessionID); }, ), - new RouteAction("/launcher/profile/get", (url: string, info: any, sessionID: string, output: string): any => - { - return this.launcherCallbacks.get(url, info, sessionID); - }), + new RouteAction( + "/launcher/profile/get", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.launcherCallbacks.get(url, info, sessionID); + }, + ), new RouteAction( "/launcher/profile/change/username", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.changeUsername(url, info, sessionID); }, ), new RouteAction( "/launcher/profile/change/password", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.changePassword(url, info, sessionID); }, ), new RouteAction( "/launcher/profile/change/wipe", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.wipe(url, info, sessionID); }, ), new RouteAction( "/launcher/profile/remove", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.removeProfile(url, info, sessionID); }, ), new RouteAction( "/launcher/profile/compatibleTarkovVersion", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.getCompatibleTarkovVersion(); }, ), new RouteAction( "/launcher/server/version", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.getServerVersion(); }, ), new RouteAction( "/launcher/server/loadedServerMods", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.getLoadedServerMods(); }, ), new RouteAction( "/launcher/server/serverModsUsedByProfile", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.launcherCallbacks.getServerModsProfileUsed(url, info, sessionID); }, diff --git a/project/src/routers/static/LocationStaticRouter.ts b/project/src/routers/static/LocationStaticRouter.ts index a2bff938..a3b98f7c 100644 --- a/project/src/routers/static/LocationStaticRouter.ts +++ b/project/src/routers/static/LocationStaticRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { LocationCallbacks } from "@spt-aki/callbacks/LocationCallbacks"; 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() export class LocationStaticRouter extends StaticRouter @@ -9,13 +11,21 @@ export class LocationStaticRouter extends StaticRouter constructor(@inject("LocationCallbacks") protected locationCallbacks: LocationCallbacks) { super([ - new RouteAction("/client/locations", (url: string, info: any, sessionID: string, output: string): any => - { - return this.locationCallbacks.getLocationData(url, info, sessionID); - }), + new RouteAction( + "/client/locations", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.locationCallbacks.getLocationData(url, info, sessionID); + }, + ), new RouteAction( "/client/location/getAirdropLoot", - (url: string, info: any, sessionID: string, _output: string): any => + async (url: string, info: any, sessionID: string, _output: string): Promise => { return this.locationCallbacks.getAirdropLoot(url, info, sessionID); }, diff --git a/project/src/routers/static/MatchStaticRouter.ts b/project/src/routers/static/MatchStaticRouter.ts index b27b1897..d0629498 100644 --- a/project/src/routers/static/MatchStaticRouter.ts +++ b/project/src/routers/static/MatchStaticRouter.ts @@ -3,6 +3,11 @@ import { inject, injectable } from "tsyringe"; import { MatchCallbacks } from "@spt-aki/callbacks/MatchCallbacks"; import { RouteAction, StaticRouter } from "@spt-aki/di/Router"; 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() export class MatchStaticRouter extends StaticRouter @@ -12,138 +17,202 @@ export class MatchStaticRouter extends StaticRouter super([ new RouteAction( "/client/match/available", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.serverAvailable(url, info, sessionID); }, ), new RouteAction( "/client/match/updatePing", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.matchCallbacks.updatePing(url, info, sessionID); }, ), - new RouteAction("/client/match/join", (url: string, info: any, sessionID: string, output: string): any => - { - return this.matchCallbacks.joinMatch(url, info, sessionID); - }), - new RouteAction("/client/match/exit", (url: string, info: any, sessionID: string, output: string): any => - { - return this.matchCallbacks.exitMatch(url, info, sessionID); - }), + new RouteAction( + "/client/match/join", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.matchCallbacks.joinMatch(url, info, sessionID); + }, + ), + new RouteAction( + "/client/match/exit", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.matchCallbacks.exitMatch(url, info, sessionID); + }, + ), new RouteAction( "/client/match/group/delete", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.matchCallbacks.deleteGroup(url, info, sessionID); }, ), new RouteAction( "/client/match/group/leave", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.leaveGroup(url, info, sessionID); }, ), new RouteAction( "/client/match/group/status", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.getGroupStatus(url, info, sessionID); }, ), new RouteAction( "/client/match/group/start_game", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.joinMatch(url, info, sessionID); }, ), new RouteAction( "/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 => { return this.matchCallbacks.exitToMenu(url, info, sessionID); }, ), new RouteAction( "/client/match/group/looking/start", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.matchCallbacks.startGroupSearch(url, info, sessionID); }, ), new RouteAction( "/client/match/group/looking/stop", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.matchCallbacks.stopGroupSearch(url, info, sessionID); }, ), new RouteAction( "/client/match/group/invite/send", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.sendGroupInvite(url, info, sessionID); }, ), new RouteAction( "/client/match/group/invite/accept", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.acceptGroupInvite(url, info, sessionID); }, ), new RouteAction( "/client/match/group/invite/decline", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise> => { return this.matchCallbacks.declineGroupInvite(url, info, sessionID); }, ), new RouteAction( "/client/match/group/invite/cancel", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.cancelGroupInvite(url, info, sessionID); }, ), new RouteAction( "/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 => { return this.matchCallbacks.cancelAllGroupInvite(url, info, sessionID); }, ), new RouteAction( "/client/match/group/transfer", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.transferGroup(url, info, sessionID); }, ), new RouteAction( "/client/match/offline/end", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.matchCallbacks.endOfflineRaid(url, info, sessionID); }, ), - new RouteAction("/client/putMetrics", (url: string, info: any, sessionID: string, output: string): any => - { - return this.matchCallbacks.putMetrics(url, info, sessionID); - }), + new RouteAction( + "/client/putMetrics", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.matchCallbacks.putMetrics(url, info, sessionID); + }, + ), new RouteAction( "/client/getMetricsConfig", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.matchCallbacks.getMetrics(url, info, sessionID); }, ), new RouteAction( "/client/raid/configuration", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.matchCallbacks.getRaidConfiguration(url, info, sessionID); }, @@ -151,14 +220,14 @@ export class MatchStaticRouter extends StaticRouter new RouteAction( "/client/raid/configuration-by-profile", // 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 => { return this.matchCallbacks.getConfigurationByProfile(url, info, sessionID); }, ), new RouteAction( "/client/match/group/player/remove", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.matchCallbacks.removePlayerFromGroup(url, info, sessionID); }, diff --git a/project/src/routers/static/NotifierStaticRouter.ts b/project/src/routers/static/NotifierStaticRouter.ts index 19cfbd08..7003a582 100644 --- a/project/src/routers/static/NotifierStaticRouter.ts +++ b/project/src/routers/static/NotifierStaticRouter.ts @@ -2,6 +2,9 @@ import { inject, injectable } from "tsyringe"; import { NotifierCallbacks } from "@spt-aki/callbacks/NotifierCallbacks"; 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() export class NotifierStaticRouter extends StaticRouter @@ -11,14 +14,24 @@ export class NotifierStaticRouter extends StaticRouter super([ new RouteAction( "/client/notifier/channel/create", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.notifierCallbacks.createNotifierChannel(url, info, sessionID); }, ), new RouteAction( "/client/game/profile/select", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.notifierCallbacks.selectProfile(url, info, sessionID); }, diff --git a/project/src/routers/static/ProfileStaticRouter.ts b/project/src/routers/static/ProfileStaticRouter.ts index 0ade4373..f83dfaa1 100644 --- a/project/src/routers/static/ProfileStaticRouter.ts +++ b/project/src/routers/static/ProfileStaticRouter.ts @@ -2,6 +2,13 @@ import { inject, injectable } from "tsyringe"; import { ProfileCallbacks } from "@spt-aki/callbacks/ProfileCallbacks"; 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() export class ProfileStaticRouter extends StaticRouter @@ -11,56 +18,81 @@ export class ProfileStaticRouter extends StaticRouter super([ new RouteAction( "/client/game/profile/create", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.profileCallbacks.createProfile(url, info, sessionID); }, ), new RouteAction( "/client/game/profile/list", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.profileCallbacks.getProfileData(url, info, sessionID); }, ), new RouteAction( "/client/game/profile/savage/regenerate", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.profileCallbacks.regenerateScav(url, info, sessionID); }, ), new RouteAction( "/client/game/profile/voice/change", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.profileCallbacks.changeVoice(url, info, sessionID); }, ), new RouteAction( "/client/game/profile/nickname/change", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise> => { return this.profileCallbacks.changeNickname(url, info, sessionID); }, ), new RouteAction( "/client/game/profile/nickname/validate", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise> => { return this.profileCallbacks.validateNickname(url, info, sessionID); }, ), new RouteAction( "/client/game/profile/nickname/reserved", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.profileCallbacks.getReservedNickname(url, info, sessionID); }, ), new RouteAction( "/client/profile/status", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.profileCallbacks.getProfileStatus(url, info, sessionID); }, @@ -68,36 +100,54 @@ export class ProfileStaticRouter extends StaticRouter new RouteAction( "/client/profile/view", // 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> => { return this.profileCallbacks.getOtherProfile(url, info, sessionID); }, ), new RouteAction( "/client/profile/settings", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.profileCallbacks.getProfileSettings(url, info, sessionID); }, ), new RouteAction( "/client/game/profile/search", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.profileCallbacks.searchFriend(url, info, sessionID); }, ), new RouteAction( "/launcher/profile/info", - (url: string, info: any, sessionID: string, output: string): any => + async (url: string, info: any, sessionID: string, output: string): Promise => { return this.profileCallbacks.getMiniProfile(url, info, sessionID); }, ), - new RouteAction("/launcher/profiles", (url: string, info: any, sessionID: string, output: string): any => - { - return this.profileCallbacks.getAllMiniProfiles(url, info, sessionID); - }), + new RouteAction( + "/launcher/profiles", + async (url: string, info: any, sessionID: string, output: string): Promise => + { + return this.profileCallbacks.getAllMiniProfiles(url, info, sessionID); + }, + ), ]); } } diff --git a/project/src/routers/static/QuestStaticRouter.ts b/project/src/routers/static/QuestStaticRouter.ts index e56f51ac..ad2b7868 100644 --- a/project/src/routers/static/QuestStaticRouter.ts +++ b/project/src/routers/static/QuestStaticRouter.ts @@ -2,6 +2,9 @@ import { inject, injectable } from "tsyringe"; import { QuestCallbacks } from "@spt-aki/callbacks/QuestCallbacks"; 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() export class QuestStaticRouter extends StaticRouter @@ -9,13 +12,26 @@ export class QuestStaticRouter extends StaticRouter constructor(@inject("QuestCallbacks") protected questCallbacks: QuestCallbacks) { super([ - new RouteAction("/client/quest/list", (url: string, info: any, sessionID: string, output: string): any => - { - return this.questCallbacks.listQuests(url, info, sessionID); - }), + new RouteAction( + "/client/quest/list", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.questCallbacks.listQuests(url, info, sessionID); + }, + ), new RouteAction( "/client/repeatalbeQuests/activityPeriods", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.questCallbacks.activityPeriods(url, info, sessionID); }, diff --git a/project/src/routers/static/RagfairStaticRouter.ts b/project/src/routers/static/RagfairStaticRouter.ts index 5a727270..87577853 100644 --- a/project/src/routers/static/RagfairStaticRouter.ts +++ b/project/src/routers/static/RagfairStaticRouter.ts @@ -2,6 +2,11 @@ import { inject, injectable } from "tsyringe"; import { RagfairCallbacks } from "@spt-aki/callbacks/RagfairCallbacks"; 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() export class RagfairStaticRouter extends StaticRouter @@ -12,7 +17,12 @@ export class RagfairStaticRouter extends StaticRouter new RouteAction( "/client/ragfair/search", // 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> => { return this.ragfairCallbacks.search(url, info, sessionID); }, @@ -20,7 +30,12 @@ export class RagfairStaticRouter extends StaticRouter new RouteAction( "/client/ragfair/find", // 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> => { return this.ragfairCallbacks.search(url, info, sessionID); }, @@ -28,7 +43,12 @@ export class RagfairStaticRouter extends StaticRouter new RouteAction( "/client/ragfair/itemMarketPrice", // 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> => { return this.ragfairCallbacks.getMarketPrice(url, info, sessionID); }, @@ -36,7 +56,7 @@ export class RagfairStaticRouter extends StaticRouter new RouteAction( "/client/ragfair/offerfees", // 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 => { return this.ragfairCallbacks.storePlayerOfferTaxAmount(url, info, sessionID); }, @@ -44,7 +64,7 @@ export class RagfairStaticRouter extends StaticRouter new RouteAction( "/client/reports/ragfair/send", // 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 => { return this.ragfairCallbacks.sendReport(url, info, sessionID); }, @@ -52,7 +72,12 @@ export class RagfairStaticRouter extends StaticRouter new RouteAction( "/client/items/prices", // 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>> => { return this.ragfairCallbacks.getFleaPrices(url, info, sessionID); }, @@ -60,7 +85,12 @@ export class RagfairStaticRouter extends StaticRouter new RouteAction( "/client/ragfair/offer/findbyid", // 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> => { return this.ragfairCallbacks.getFleaOfferById(url, info, sessionID); }, diff --git a/project/src/routers/static/TraderStaticRouter.ts b/project/src/routers/static/TraderStaticRouter.ts index 2903f9be..69864a4e 100644 --- a/project/src/routers/static/TraderStaticRouter.ts +++ b/project/src/routers/static/TraderStaticRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { TraderCallbacks } from "@spt-aki/callbacks/TraderCallbacks"; 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() export class TraderStaticRouter extends StaticRouter @@ -11,7 +13,12 @@ export class TraderStaticRouter extends StaticRouter super([ new RouteAction( "/client/trading/api/traderSettings", - (url: string, info: any, sessionID: string, output: string): any => + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.traderCallbacks.getTraderSettings(url, info, sessionID); }, diff --git a/project/src/routers/static/WeatherStaticRouter.ts b/project/src/routers/static/WeatherStaticRouter.ts index 28504cc1..8ed17478 100644 --- a/project/src/routers/static/WeatherStaticRouter.ts +++ b/project/src/routers/static/WeatherStaticRouter.ts @@ -2,6 +2,8 @@ import { inject, injectable } from "tsyringe"; import { WeatherCallbacks } from "@spt-aki/callbacks/WeatherCallbacks"; 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() export class WeatherStaticRouter extends StaticRouter @@ -9,10 +11,18 @@ export class WeatherStaticRouter extends StaticRouter constructor(@inject("WeatherCallbacks") protected weatherCallbacks: WeatherCallbacks) { super([ - new RouteAction("/client/weather", (url: string, info: any, sessionID: string, output: string): any => - { - return this.weatherCallbacks.getWeather(url, info, sessionID); - }), + new RouteAction( + "/client/weather", + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => + { + return this.weatherCallbacks.getWeather(url, info, sessionID); + }, + ), ]); } } diff --git a/project/src/servers/http/AkiHttpListener.ts b/project/src/servers/http/AkiHttpListener.ts index 8ff17214..e99b29b2 100644 --- a/project/src/servers/http/AkiHttpListener.ts +++ b/project/src/servers/http/AkiHttpListener.ts @@ -30,13 +30,13 @@ export class AkiHttpListener implements IHttpListener 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 { switch (req.method) { case "GET": { - const response = this.getResponse(sessionId, req, null); + const response = await this.getResponse(sessionId, req, null); this.sendResponse(sessionId, req, resp, null, response); break; } @@ -58,7 +58,7 @@ export class AkiHttpListener implements IHttpListener written += data.length; }); - req.on("end", () => + req.on("end", async () => { // 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 @@ -73,7 +73,7 @@ export class AkiHttpListener implements IHttpListener 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); }); @@ -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 { const info = this.getBodyInfo(body, req.url); if (globalThis.G_LOG_REQUESTS) @@ -148,7 +148,7 @@ export class AkiHttpListener implements IHttpListener 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 */ if (!output) { diff --git a/project/src/servers/http/IHttpListener.ts b/project/src/servers/http/IHttpListener.ts index 9d746768..27b0093f 100644 --- a/project/src/servers/http/IHttpListener.ts +++ b/project/src/servers/http/IHttpListener.ts @@ -3,5 +3,5 @@ import { IncomingMessage, ServerResponse } from "node:http"; export interface IHttpListener { canHandle(sessionId: string, req: IncomingMessage): boolean; - handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): void; + handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): Promise; } diff --git a/project/src/services/mod/httpListener/HttpListenerMod.ts b/project/src/services/mod/httpListener/HttpListenerMod.ts index 760cc14a..fd0456df 100644 --- a/project/src/services/mod/httpListener/HttpListenerMod.ts +++ b/project/src/services/mod/httpListener/HttpListenerMod.ts @@ -16,7 +16,7 @@ export class HttpListenerMod implements IHttpListener return this.canHandleOverride(sessionId, req); } - public handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): void + public async handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): Promise { this.handleOverride(sessionId, req, resp); }