0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00
server/project/src/callbacks/InraidCallbacks.ts

60 lines
2.3 KiB
TypeScript
Raw Normal View History

BunJS Runtime, Updated Build System, and... (#992) This is a big one. 🔥 **Changes:** - Targets next major release (v4.0.0) - Switch runtimes from NodeJS to BunJS (bun.sh) - Typescript library support moved to `ESNext` - Typescript compile option `verbatimModuleSyntax` enabled - Updated all interfaces to be imported explicitly as types - Strict mode enabled - Reduces the number of tsconfig files - Pins all dep packages to specific patch versions - Includes Bun lock file in repo (doesn't cause issues like the package-lock did) - Replaces Gulp with a new Typescript based build system - Adds `core-js` as a workaround for Bun not playing nice with `reflect-metadata` - Removes `pkg` and `swc` (Yay Bun!) - Updated package scripts and entry point system to be more intuitive - Updated VSCode workspace configurations - Updated `.gitignore` to align with updated project structure - Updated Biome configuration to align with updated project structure - `Program.ts` - Removes call to set encoding on the process - `global.d.ts` - Added underscores to build globals to match other global names - `JsonUtil.ts` - Replaced old `fixJson` package with newer `jsonrepair` package - `HashUtil.ts` - Replaced old `buffer-crc32` package with built-in `node:zlib` package - `DatabaseImporter.ts` - Updates database validation object to be flat, where the keys are the relative path to the file - `BunTimer.ts` - Adds an easy to use timer class that's compatible with nanoseconds. **TODO:** - Look into mod loading. I think we use a TS transpiler for mods and I believe that can be removed now. - Bun includes a number of APIs that can be used in place of Node's packages (built-in or otherwise); HTTP server, WebSocket server, File IO, Hashing, File Globing, Testing... Each of these should be utilized where ever possible. - Update in-repo documentation to reference BunJS instead of NodeJS.
2024-12-21 17:46:39 -05:00
import type { InraidController } from "@spt/controllers/InraidController";
import type { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
import type { INullResponseData } from "@spt/models/eft/httpResponse/INullResponseData";
import type { IRegisterPlayerRequestData } from "@spt/models/eft/inRaid/IRegisterPlayerRequestData";
import type { IScavSaveRequestData } from "@spt/models/eft/inRaid/IScavSaveRequestData";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { inject, injectable } from "tsyringe";
2023-03-03 15:23:46 +00:00
/**
* Handle client requests
*/
@injectable()
export class InraidCallbacks {
2023-03-03 15:23:46 +00:00
constructor(
@inject("InraidController") protected inraidController: InraidController,
2023-11-15 20:35:05 -05:00
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
) {}
2023-03-03 15:23:46 +00:00
/**
* Handle client/location/getLocalloot
2023-07-15 14:49:25 +01:00
* Store active map in profile + applicationContext
2023-11-15 20:35:05 -05:00
* @param url
2023-03-03 15:23:46 +00:00
* @param info register player request
* @param sessionID Session id
* @returns Null http response
*/
public registerPlayer(url: string, info: IRegisterPlayerRequestData, sessionID: string): INullResponseData {
2023-03-03 15:23:46 +00:00
this.inraidController.addPlayer(sessionID, info);
return this.httpResponse.nullResponse();
}
/**
* Handle raid/profile/scavsave
2023-11-15 20:35:05 -05:00
* @param url
2023-03-03 15:23:46 +00:00
* @param info Save progress request
* @param sessionID Session id
* @returns Null http response
*/
public saveProgress(url: string, info: IScavSaveRequestData, sessionID: string): INullResponseData {
this.inraidController.savePostRaidProfileForScav(info, sessionID);
2023-03-03 15:23:46 +00:00
return this.httpResponse.nullResponse();
}
/**
* Handle singleplayer/settings/raid/menu
* @returns JSON as string
*/
public getRaidMenuSettings(): string {
2023-03-03 15:23:46 +00:00
return this.httpResponse.noBody(this.inraidController.getInraidConfig().raidMenuSettings);
}
public getTraitorScavHostileChance(url: string, info: IEmptyRequestData, sessionId: string): string {
return this.httpResponse.noBody(this.inraidController.getTraitorScavHostileChance(url, sessionId));
}
public getBossConvertSettings(url: string, info: IEmptyRequestData, sessionId: string): string {
2024-07-05 19:02:02 +01:00
return this.httpResponse.noBody(this.inraidController.getBossConvertSettings(url, sessionId));
}
2023-11-15 20:35:05 -05:00
}