Migrated from Jest to Vitest

Basically the same, except it plays nicer with Typescript and ESM.

I have it mostly working, except for a type error:
`TypeError: Int32Array is not a constructor`

But I'm too damn tired it debug it at the moment.
This commit is contained in:
Refringe 2023-10-27 23:55:34 -04:00 committed by TheSparta
parent 00ac9e190a
commit ad5e0815b6
9 changed files with 498 additions and 498 deletions

View File

@ -9,5 +9,12 @@
"editor.detectIndentation": false,
"editor.tabSize": 4,
"editor.insertSpaces": true
}
}
},
"cSpell.words": [
"Baseclass",
"IIIA",
"medkit",
"Superfors",
"ULACH"
]
}

View File

@ -1,15 +0,0 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { Config } from "jest";
import fs from "fs";
const config: Config = {
testEnvironment: "./tests/CustomEnvironment.ts",
roots: [
"./tests/"
],
transform: {
"^.+\\.ts$": [ "@swc/jest", JSON.parse(fs.readFileSync(`${__dirname}/.swcrc`, "utf-8")) ]
}
};
export default config;

View File

@ -14,8 +14,9 @@
"check:circular": "madge --circular --extensions ts ./src/",
"lint": "rome ci src --formatter-enabled=false --max-diagnostics=200",
"lint:fix": "eslint --fix --ext .ts src/**",
"test": "jest --colors --runInBand",
"test:coverage": "jest --coverage --maxWorkers=1 --no-cache",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"build:release": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:release",
"build:debug": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:debug",
"build:bleeding": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:bleeding",
@ -44,27 +45,22 @@
"devDependencies": {
"@babel/preset-env": "7.23.2",
"@babel/preset-typescript": "7.23.2",
"@jest/environment": "^29.7.0",
"@jest/globals": "29.7.0",
"@pnpm/exe": "8.9.0",
"@swc/cli": "0.1.62",
"@swc/core": "1.3.92",
"@swc/jest": "0.2.29",
"@types/i18n": "0.13.7",
"@types/jest": "29.5.5",
"@types/node": "18.18.4",
"@types/proper-lockfile": "4.1.2",
"@types/semver": "7.5.3",
"@types/ws": "8.5.7",
"@typescript-eslint/eslint-plugin": "6.7.5",
"@typescript-eslint/parser": "6.7.5",
"c8": "^8.0.1",
"cross-env": "7.0.3",
"eslint": "8.51.0",
"gulp": "4.0.2",
"gulp-execa": "5.0.1",
"gulp-rename": "2.0.0",
"jest": "29.7.0",
"jest-environment-node": "^29.7.0",
"madge": "6.1.0",
"pkg": "5.8.1",
"pkg-fetch": "3.5.2",
@ -73,7 +69,8 @@
"ts-node-dev": "2.0.0",
"tsconfig-paths": "4.2.0",
"typedoc": "0.25.2",
"typemoq": "2.1.0"
"typemoq": "2.1.0",
"vitest": "1.0.0-beta.3"
},
"overrides": {
"pkg": {

View File

@ -248,460 +248,454 @@ import { Watermark, WatermarkLocale } from "@spt-aki/utils/Watermark";
import { WinstonMainLogger } from "@spt-aki/utils/logging/WinstonMainLogger";
import { WinstonRequestLogger } from "@spt-aki/utils/logging/WinstonRequestLogger";
// For the Jest Custom Environment.
import NodeEnvironment from "jest-environment-node";
import type { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
// For the Vitest Custom Environment.
import type { Environment } from "vitest";
import { populateGlobal } from "vitest/environments";
// Used for importing the database.
import path from "path";
import { IDatabaseTables } from "@spt-aki/models/spt/server/IDatabaseTables";
export default class CustomEnvironment extends NodeEnvironment
{
private container: DependencyContainer;
// For importing the database.
private importerUtil: ImporterUtil;
private databaseServer: DatabaseServer;
constructor(config: JestEnvironmentConfig, context: EnvironmentContext)
export default <Environment> {
name: "spt-aki-server",
transformMode: "ssr",
async setup()
{
super(config, context);
this.container = this.register(container);
}
async setup(): Promise<void>
{
await super.setup();
// Register all of the things!
register(container);
// Import the database.
await this.importDatabase();
await importDatabase(container);
// Make the container accessible to the tests.
this.global.container = this.container;
// Populate the global scope with all of the things!
populateGlobal(global, { container }, { bindFunctions: true });
// TODO: Create test account/profile
return {
teardown()
{
// Not sure this is required, but it's here just in case.
delete global.container;
// TODO: Delete test account/profile
}
};
}
};
async teardown(): Promise<void>
{
// TODO: Delete test account/profile
// Register all of the things!
function register(container: DependencyContainer): DependencyContainer
{
container.register("ApplicationContext", ApplicationContext, { lifecycle: Lifecycle.Singleton });
await super.teardown();
}
registerUtils(container);
registerRouters(container);
registerGenerators(container);
registerHelpers(container);
registerLoaders(container);
registerCallbacks(container);
registerServers(container);
registerServices(container);
registerControllers(container);
// Register all of the things!
private register(container: DependencyContainer): DependencyContainer
{
container.register("ApplicationContext", ApplicationContext, { lifecycle: Lifecycle.Singleton });
registerListTypes(container);
this.registerUtils(container);
this.registerRouters(container);
this.registerGenerators(container);
this.registerHelpers(container);
this.registerLoaders(container);
this.registerCallbacks(container);
this.registerServers(container);
this.registerServices(container);
this.registerControllers(container);
this.registerListTypes(container);
return container;
}
private registerUtils(container: DependencyContainer): void
{
// Utils
container.register<App>("App", App, { lifecycle: Lifecycle.Singleton });
container.register<DatabaseImporter>("DatabaseImporter", DatabaseImporter, { lifecycle: Lifecycle.Singleton });
container.register<HashUtil>("HashUtil", HashUtil, { lifecycle: Lifecycle.Singleton });
container.register<ImporterUtil>("ImporterUtil", ImporterUtil, { lifecycle: Lifecycle.Singleton });
container.register<HttpResponseUtil>("HttpResponseUtil", HttpResponseUtil);
container.register<EncodingUtil>("EncodingUtil", EncodingUtil, { lifecycle: Lifecycle.Singleton });
container.register<JsonUtil>("JsonUtil", JsonUtil);
container.register<WinstonMainLogger>("WinstonLogger", WinstonMainLogger, { lifecycle: Lifecycle.Singleton });
container.register<WinstonRequestLogger>("RequestsLogger", WinstonRequestLogger, { lifecycle: Lifecycle.Singleton });
container.register<MathUtil>("MathUtil", MathUtil, { lifecycle: Lifecycle.Singleton });
container.register<ObjectId>("ObjectId", ObjectId);
container.register<RandomUtil>("RandomUtil", RandomUtil, { lifecycle: Lifecycle.Singleton });
container.register<TimeUtil>("TimeUtil", TimeUtil, { lifecycle: Lifecycle.Singleton });
container.register<VFS>("VFS", VFS, { lifecycle: Lifecycle.Singleton });
container.register<WatermarkLocale>("WatermarkLocale", WatermarkLocale, { lifecycle: Lifecycle.Singleton });
container.register<Watermark>("Watermark", Watermark, { lifecycle: Lifecycle.Singleton });
container.register<IAsyncQueue>("AsyncQueue", AsyncQueue, { lifecycle: Lifecycle.Singleton });
container.register<IUUidGenerator>("UUidGenerator", UUidGenerator, { lifecycle: Lifecycle.Singleton });
container.register<HttpFileUtil>("HttpFileUtil", HttpFileUtil, { lifecycle: Lifecycle.Singleton });
container.register<ModLoadOrder>("ModLoadOrder", ModLoadOrder, { lifecycle: Lifecycle.Singleton });
container.register<ModTypeCheck>("ModTypeCheck", ModTypeCheck, { lifecycle: Lifecycle.Singleton });
}
private registerRouters(container: DependencyContainer): void
{
// Routers
container.register<HttpRouter>("HttpRouter", HttpRouter, { lifecycle: Lifecycle.Singleton });
container.register<ImageRouter>("ImageRouter", ImageRouter);
container.register<EventOutputHolder>("EventOutputHolder", EventOutputHolder, { lifecycle: Lifecycle.Singleton });
container.register<ItemEventRouter>("ItemEventRouter", ItemEventRouter);
// Dynamic Routes
container.register<BotDynamicRouter>("BotDynamicRouter", { useClass: BotDynamicRouter });
container.register<BundleDynamicRouter>("BundleDynamicRouter", { useClass: BundleDynamicRouter });
container.register<CustomizationDynamicRouter>("CustomizationDynamicRouter", { useClass: CustomizationDynamicRouter });
container.register<DataDynamicRouter>("DataDynamicRouter", { useClass: DataDynamicRouter });
container.register<HttpDynamicRouter>("HttpDynamicRouter", { useClass: HttpDynamicRouter });
container.register<InraidDynamicRouter>("InraidDynamicRouter", { useClass: InraidDynamicRouter });
container.register<LocationDynamicRouter>("LocationDynamicRouter", { useClass: LocationDynamicRouter });
container.register<NotifierDynamicRouter>("NotifierDynamicRouter", { useClass: NotifierDynamicRouter });
container.register<TraderDynamicRouter>("TraderDynamicRouter", { useClass: TraderDynamicRouter });
// Item Event Routes
container.register<CustomizationItemEventRouter>("CustomizationItemEventRouter", { useClass: CustomizationItemEventRouter });
container.register<HealthItemEventRouter>("HealthItemEventRouter", { useClass: HealthItemEventRouter });
container.register<HideoutItemEventRouter>("HideoutItemEventRouter", { useClass: HideoutItemEventRouter });
container.register<InsuranceItemEventRouter>("InsuranceItemEventRouter", { useClass: InsuranceItemEventRouter });
container.register<InventoryItemEventRouter>("InventoryItemEventRouter", { useClass: InventoryItemEventRouter });
container.register<NoteItemEventRouter>("NoteItemEventRouter", { useClass: NoteItemEventRouter });
container.register<PresetBuildItemEventRouter>("PresetBuildItemEventRouter", { useClass: PresetBuildItemEventRouter });
container.register<QuestItemEventRouter>("QuestItemEventRouter", { useClass: QuestItemEventRouter });
container.register<RagfairItemEventRouter>("RagfairItemEventRouter", { useClass: RagfairItemEventRouter });
container.register<RepairItemEventRouter>("RepairItemEventRouter", { useClass: RepairItemEventRouter });
container.register<TradeItemEventRouter>("TradeItemEventRouter", { useClass: TradeItemEventRouter });
container.register<WishlistItemEventRouter>("WishlistItemEventRouter", { useClass: WishlistItemEventRouter });
// Save Load Routes
container.register<HealthSaveLoadRouter>("HealthSaveLoadRouter", { useClass: HealthSaveLoadRouter });
container.register<InraidSaveLoadRouter>("InraidSaveLoadRouter", { useClass: InraidSaveLoadRouter });
container.register<InsuranceSaveLoadRouter>("InsuranceSaveLoadRouter", { useClass: InsuranceSaveLoadRouter });
container.register<ProfileSaveLoadRouter>("ProfileSaveLoadRouter", { useClass: ProfileSaveLoadRouter });
// Route Serializers
container.register<BundleSerializer>("BundleSerializer", { useClass: BundleSerializer });
container.register<ImageSerializer>("ImageSerializer", { useClass: ImageSerializer });
container.register<NotifySerializer>("NotifySerializer", { useClass: NotifySerializer });
// Static Routes
container.register<BotStaticRouter>("BotStaticRouter", { useClass: BotStaticRouter });
container.register<BundleStaticRouter>("BundleStaticRouter", { useClass: BundleStaticRouter });
container.register<ClientLogStaticRouter>("ClientLogStaticRouter", { useClass: ClientLogStaticRouter });
container.register<CustomizationStaticRouter>("CustomizationStaticRouter", { useClass: CustomizationStaticRouter });
container.register<DataStaticRouter>("DataStaticRouter", { useClass: DataStaticRouter });
container.register<DialogStaticRouter>("DialogStaticRouter", { useClass: DialogStaticRouter });
container.register<GameStaticRouter>("GameStaticRouter", { useClass: GameStaticRouter });
container.register<HealthStaticRouter>("HealthStaticRouter", { useClass: HealthStaticRouter });
container.register<InraidStaticRouter>("InraidStaticRouter", { useClass: InraidStaticRouter });
container.register<InsuranceStaticRouter>("InsuranceStaticRouter", { useClass: InsuranceStaticRouter });
container.register<ItemEventStaticRouter>("ItemEventStaticRouter", { useClass: ItemEventStaticRouter });
container.register<LauncherStaticRouter>("LauncherStaticRouter", { useClass: LauncherStaticRouter });
container.register<LocationStaticRouter>("LocationStaticRouter", { useClass: LocationStaticRouter });
container.register<MatchStaticRouter>("MatchStaticRouter", { useClass: MatchStaticRouter });
container.register<NotifierStaticRouter>("NotifierStaticRouter", { useClass: NotifierStaticRouter });
container.register<PresetStaticRouter>("PresetStaticRouter", { useClass: PresetStaticRouter });
container.register<ProfileStaticRouter>("ProfileStaticRouter", { useClass: ProfileStaticRouter });
container.register<QuestStaticRouter>("QuestStaticRouter", { useClass: QuestStaticRouter });
container.register<RagfairStaticRouter>("RagfairStaticRouter", { useClass: RagfairStaticRouter });
container.register<TraderStaticRouter>("TraderStaticRouter", { useClass: TraderStaticRouter });
container.register<WeatherStaticRouter>("WeatherStaticRouter", { useClass: WeatherStaticRouter });
}
private registerGenerators(container: DependencyContainer): void
{
// Generators
container.register<BotGenerator>("BotGenerator", BotGenerator);
container.register<BotWeaponGenerator>("BotWeaponGenerator", BotWeaponGenerator);
container.register<BotLootGenerator>("BotLootGenerator", BotLootGenerator);
container.register<BotInventoryGenerator>("BotInventoryGenerator", BotInventoryGenerator);
container.register<LocationGenerator>("LocationGenerator", { useClass: LocationGenerator });
container.register<PMCLootGenerator>("PMCLootGenerator", PMCLootGenerator, { lifecycle: Lifecycle.Singleton });
container.register<ScavCaseRewardGenerator>("ScavCaseRewardGenerator", ScavCaseRewardGenerator, { lifecycle: Lifecycle.Singleton });
container.register<RagfairAssortGenerator>("RagfairAssortGenerator", { useClass: RagfairAssortGenerator });
container.register<RagfairOfferGenerator>("RagfairOfferGenerator", { useClass: RagfairOfferGenerator });
container.register<WeatherGenerator>("WeatherGenerator", { useClass: WeatherGenerator });
container.register<PlayerScavGenerator>("PlayerScavGenerator", { useClass: PlayerScavGenerator });
container.register<LootGenerator>("LootGenerator", { useClass: LootGenerator });
container.register<FenceBaseAssortGenerator>("FenceBaseAssortGenerator", { useClass: FenceBaseAssortGenerator });
container.register<BotLevelGenerator>("BotLevelGenerator", { useClass: BotLevelGenerator });
container.register<BotEquipmentModGenerator>("BotEquipmentModGenerator", { useClass: BotEquipmentModGenerator });
container.register<RepeatableQuestGenerator>("RepeatableQuestGenerator", { useClass: RepeatableQuestGenerator });
container.register<BarrelInventoryMagGen>("BarrelInventoryMagGen", { useClass: BarrelInventoryMagGen });
container.register<ExternalInventoryMagGen>("ExternalInventoryMagGen", { useClass: ExternalInventoryMagGen });
container.register<InternalMagazineInventoryMagGen>("InternalMagazineInventoryMagGen", { useClass: InternalMagazineInventoryMagGen });
container.register<UbglExternalMagGen>("UbglExternalMagGen", { useClass: UbglExternalMagGen });
container.registerType("InventoryMagGen", "BarrelInventoryMagGen");
container.registerType("InventoryMagGen", "ExternalInventoryMagGen");
container.registerType("InventoryMagGen", "InternalMagazineInventoryMagGen");
container.registerType("InventoryMagGen", "UbglExternalMagGen");
}
private registerHelpers(container: DependencyContainer): void
{
// Helpers
container.register<AssortHelper>("AssortHelper", { useClass: AssortHelper });
container.register<BotHelper>("BotHelper", { useClass: BotHelper });
container.register<BotGeneratorHelper>("BotGeneratorHelper", { useClass: BotGeneratorHelper });
container.register<ContainerHelper>("ContainerHelper", ContainerHelper);
container.register<DialogueHelper>("DialogueHelper", { useClass: DialogueHelper });
container.register<DurabilityLimitsHelper>("DurabilityLimitsHelper", { useClass: DurabilityLimitsHelper });
container.register<GameEventHelper>("GameEventHelper", GameEventHelper);
container.register<HandbookHelper>("HandbookHelper", HandbookHelper, { lifecycle: Lifecycle.Singleton });
container.register<HealthHelper>("HealthHelper", { useClass: HealthHelper });
container.register<HideoutHelper>("HideoutHelper", { useClass: HideoutHelper });
container.register<InRaidHelper>("InRaidHelper", { useClass: InRaidHelper });
container.register<InventoryHelper>("InventoryHelper", { useClass: InventoryHelper });
container.register<PaymentHelper>("PaymentHelper", PaymentHelper);
container.register<ItemHelper>("ItemHelper", { useClass: ItemHelper });
container.register<PresetHelper>("PresetHelper", PresetHelper, { lifecycle: Lifecycle.Singleton });
container.register<ProfileHelper>("ProfileHelper", { useClass: ProfileHelper });
container.register<QuestHelper>("QuestHelper", { useClass: QuestHelper });
container.register<QuestConditionHelper>("QuestConditionHelper", QuestConditionHelper);
container.register<RagfairHelper>("RagfairHelper", { useClass: RagfairHelper });
container.register<RagfairSortHelper>("RagfairSortHelper", { useClass: RagfairSortHelper });
container.register<RagfairSellHelper>("RagfairSellHelper", { useClass: RagfairSellHelper });
container.register<RagfairOfferHelper>("RagfairOfferHelper", { useClass: RagfairOfferHelper });
container.register<RagfairServerHelper>("RagfairServerHelper", { useClass: RagfairServerHelper });
container.register<RepairHelper>("RepairHelper", { useClass: RepairHelper });
container.register<TraderHelper>("TraderHelper", TraderHelper);
container.register<TraderAssortHelper>("TraderAssortHelper", TraderAssortHelper, { lifecycle: Lifecycle.Singleton });
container.register<TradeHelper>("TradeHelper", { useClass: TradeHelper });
container.register<NotifierHelper>("NotifierHelper", { useClass: NotifierHelper });
container.register<UtilityHelper>("UtilityHelper", UtilityHelper);
container.register<WeightedRandomHelper>("WeightedRandomHelper", { useClass: WeightedRandomHelper });
container.register<HttpServerHelper>("HttpServerHelper", { useClass: HttpServerHelper });
container.register<NotificationSendHelper>("NotificationSendHelper", { useClass: NotificationSendHelper });
container.register<SecureContainerHelper>("SecureContainerHelper", { useClass: SecureContainerHelper });
container.register<ProbabilityHelper>("ProbabilityHelper", { useClass: ProbabilityHelper });
container.register<BotWeaponGeneratorHelper>("BotWeaponGeneratorHelper", { useClass: BotWeaponGeneratorHelper });
container.register<BotDifficultyHelper>("BotDifficultyHelper", { useClass: BotDifficultyHelper });
container.register<RepeatableQuestHelper>("RepeatableQuestHelper", { useClass: RepeatableQuestHelper });
}
private registerLoaders(container: DependencyContainer): void
{
// Loaders
container.register<BundleLoader>("BundleLoader", BundleLoader, { lifecycle: Lifecycle.Singleton });
container.register<PreAkiModLoader>("PreAkiModLoader", PreAkiModLoader, { lifecycle: Lifecycle.Singleton });
container.register<PostAkiModLoader>("PostAkiModLoader", PostAkiModLoader, { lifecycle: Lifecycle.Singleton });
}
private registerCallbacks(container: DependencyContainer): void
{
// Callbacks
container.register<BotCallbacks>("BotCallbacks", { useClass: BotCallbacks });
container.register<BundleCallbacks>("BundleCallbacks", { useClass: BundleCallbacks });
container.register<ClientLogCallbacks>("ClientLogCallbacks", { useClass: ClientLogCallbacks });
container.register<CustomizationCallbacks>("CustomizationCallbacks", { useClass: CustomizationCallbacks });
container.register<DataCallbacks>("DataCallbacks", { useClass: DataCallbacks });
container.register<DialogueCallbacks>("DialogueCallbacks", { useClass: DialogueCallbacks });
container.register<GameCallbacks>("GameCallbacks", { useClass: GameCallbacks });
container.register<HandbookCallbacks>("HandbookCallbacks", { useClass: HandbookCallbacks });
container.register<HealthCallbacks>("HealthCallbacks", { useClass: HealthCallbacks });
container.register<HideoutCallbacks>("HideoutCallbacks", { useClass: HideoutCallbacks });
container.register<HttpCallbacks>("HttpCallbacks", { useClass: HttpCallbacks });
container.register<InraidCallbacks>("InraidCallbacks", { useClass: InraidCallbacks });
container.register<InsuranceCallbacks>("InsuranceCallbacks", { useClass: InsuranceCallbacks });
container.register<InventoryCallbacks>("InventoryCallbacks", { useClass: InventoryCallbacks });
container.register<ItemEventCallbacks>("ItemEventCallbacks", { useClass: ItemEventCallbacks });
container.register<LauncherCallbacks>("LauncherCallbacks", { useClass: LauncherCallbacks });
container.register<LocationCallbacks>("LocationCallbacks", { useClass: LocationCallbacks });
container.register<MatchCallbacks>("MatchCallbacks", { useClass: MatchCallbacks });
container.register<ModCallbacks>("ModCallbacks", { useClass: ModCallbacks });
container.register<PostDBModLoader>("PostDBModLoader", { useClass: PostDBModLoader });
container.register<NoteCallbacks>("NoteCallbacks", { useClass: NoteCallbacks });
container.register<NotifierCallbacks>("NotifierCallbacks", { useClass: NotifierCallbacks });
container.register<PresetBuildCallbacks>("PresetBuildCallbacks", { useClass: PresetBuildCallbacks });
container.register<PresetCallbacks>("PresetCallbacks", { useClass: PresetCallbacks });
container.register<ProfileCallbacks>("ProfileCallbacks", { useClass: ProfileCallbacks });
container.register<QuestCallbacks>("QuestCallbacks", { useClass: QuestCallbacks });
container.register<RagfairCallbacks>("RagfairCallbacks", { useClass: RagfairCallbacks });
container.register<RepairCallbacks>("RepairCallbacks", { useClass: RepairCallbacks });
container.register<SaveCallbacks>("SaveCallbacks", { useClass: SaveCallbacks });
container.register<TradeCallbacks>("TradeCallbacks", { useClass: TradeCallbacks });
container.register<TraderCallbacks>("TraderCallbacks", { useClass: TraderCallbacks });
container.register<WeatherCallbacks>("WeatherCallbacks", { useClass: WeatherCallbacks });
container.register<WishlistCallbacks>("WishlistCallbacks", { useClass: WishlistCallbacks });
}
private registerServices(container: DependencyContainer): void
{
// Services
container.register<ImageRouteService>("ImageRouteService", ImageRouteService, { lifecycle: Lifecycle.Singleton });
container.register<FenceService>("FenceService", FenceService, { lifecycle: Lifecycle.Singleton });
container.register<PlayerService>("PlayerService", { useClass: PlayerService });
container.register<PaymentService>("PaymentService", { useClass: PaymentService });
container.register<InsuranceService>("InsuranceService", InsuranceService, { lifecycle: Lifecycle.Singleton });
container.register<TraderAssortService>("TraderAssortService", TraderAssortService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairPriceService>("RagfairPriceService", RagfairPriceService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairCategoriesService>("RagfairCategoriesService", RagfairCategoriesService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairOfferService>("RagfairOfferService", RagfairOfferService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairLinkedItemService>("RagfairLinkedItemService", RagfairLinkedItemService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairRequiredItemsService>("RagfairRequiredItemsService", RagfairRequiredItemsService, { lifecycle: Lifecycle.Singleton });
container.register<NotificationService>("NotificationService", NotificationService, { lifecycle: Lifecycle.Singleton });
container.register<MatchLocationService>("MatchLocationService", MatchLocationService, { lifecycle: Lifecycle.Singleton });
container.register<ModCompilerService>("ModCompilerService", ModCompilerService);
container.register<HashCacheService>("HashCacheService", HashCacheService, { lifecycle: Lifecycle.Singleton });
container.register<LocaleService>("LocaleService", LocaleService, { lifecycle: Lifecycle.Singleton });
container.register<ProfileFixerService>("ProfileFixerService", ProfileFixerService);
container.register<RepairService>("RepairService", RepairService);
container.register<BotLootCacheService>("BotLootCacheService", BotLootCacheService, { lifecycle: Lifecycle.Singleton });
container.register<CustomItemService>("CustomItemService", CustomItemService);
container.register<BotEquipmentFilterService>("BotEquipmentFilterService", BotEquipmentFilterService);
container.register<ProfileSnapshotService>("ProfileSnapshotService", ProfileSnapshotService, { lifecycle: Lifecycle.Singleton });
container.register<ItemFilterService>("ItemFilterService", ItemFilterService, { lifecycle: Lifecycle.Singleton });
container.register<BotGenerationCacheService>("BotGenerationCacheService", BotGenerationCacheService, { lifecycle: Lifecycle.Singleton });
container.register<LocalisationService>("LocalisationService", LocalisationService, { lifecycle: Lifecycle.Singleton });
container.register<CustomLocationWaveService>("CustomLocationWaveService", CustomLocationWaveService, { lifecycle: Lifecycle.Singleton });
container.register<OpenZoneService>("OpenZoneService", OpenZoneService, { lifecycle: Lifecycle.Singleton });
container.register<ItemBaseClassService>("ItemBaseClassService", ItemBaseClassService, { lifecycle: Lifecycle.Singleton });
container.register<BotEquipmentModPoolService>("BotEquipmentModPoolService", BotEquipmentModPoolService, { lifecycle: Lifecycle.Singleton });
container.register<BotWeaponModLimitService>("BotWeaponModLimitService", BotWeaponModLimitService, { lifecycle: Lifecycle.Singleton });
container.register<SeasonalEventService>("SeasonalEventService", SeasonalEventService, { lifecycle: Lifecycle.Singleton });
container.register<MatchBotDetailsCacheService>("MatchBotDetailsCacheService", MatchBotDetailsCacheService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairTaxService>("RagfairTaxService", RagfairTaxService, { lifecycle: Lifecycle.Singleton });
container.register<TraderPurchasePersisterService>("TraderPurchasePersisterService", TraderPurchasePersisterService);
container.register<PmcChatResponseService>("PmcChatResponseService", PmcChatResponseService);
container.register<GiftService>("GiftService", GiftService);
container.register<MailSendService>("MailSendService", MailSendService);
}
private registerServers(container: DependencyContainer): void
{
// Servers
container.register<DatabaseServer>("DatabaseServer", DatabaseServer, { lifecycle: Lifecycle.Singleton });
container.register<HttpServer>("HttpServer", HttpServer, { lifecycle: Lifecycle.Singleton });
container.register<WebSocketServer>("WebSocketServer", WebSocketServer, { lifecycle: Lifecycle.Singleton });
container.register<RagfairServer>("RagfairServer", RagfairServer);
container.register<SaveServer>("SaveServer", SaveServer, { lifecycle: Lifecycle.Singleton });
container.register<ConfigServer>("ConfigServer", ConfigServer, { lifecycle: Lifecycle.Singleton });
container.register<HttpBufferHandler>("HttpBufferHandler", HttpBufferHandler, {lifecycle: Lifecycle.Singleton});
}
private registerControllers(container: DependencyContainer): void
{
// Controllers
container.register<BotController>("BotController", { useClass: BotController });
container.register<ClientLogController>("ClientLogController", { useClass: ClientLogController });
container.register<CustomizationController>("CustomizationController", { useClass: CustomizationController });
container.register<DialogueController>("DialogueController", { useClass: DialogueController });
container.register<GameController>("GameController", { useClass: GameController });
container.register<HandbookController>("HandbookController", { useClass: HandbookController });
container.register<HealthController>("HealthController", { useClass: HealthController });
container.register<HideoutController>("HideoutController", { useClass: HideoutController });
container.register<InraidController>("InraidController", { useClass: InraidController });
container.register<InsuranceController>("InsuranceController", { useClass: InsuranceController });
container.register<InventoryController>("InventoryController", { useClass: InventoryController });
container.register<LauncherController>("LauncherController", { useClass: LauncherController });
container.register<LocationController>("LocationController", { useClass: LocationController });
container.register<MatchController>("MatchController", MatchController);
container.register<NoteController>("NoteController", { useClass: NoteController });
container.register<NotifierController>("NotifierController", { useClass: NotifierController });
container.register<PresetBuildController>("PresetBuildController", { useClass: PresetBuildController });
container.register<PresetController>("PresetController", { useClass: PresetController });
container.register<ProfileController>("ProfileController", { useClass: ProfileController });
container.register<QuestController>("QuestController", { useClass: QuestController });
container.register<RagfairController>("RagfairController", { useClass: RagfairController });
container.register<RepairController>("RepairController", { useClass: RepairController });
container.register<RepeatableQuestController>("RepeatableQuestController", { useClass: RepeatableQuestController });
container.register<TradeController>("TradeController", { useClass: TradeController });
container.register<TraderController>("TraderController", { useClass: TraderController });
container.register<WeatherController>("WeatherController", { useClass: WeatherController });
container.register<WishlistController>("WishlistController", WishlistController);
}
private registerListTypes(container: DependencyContainer): void
{
container.register("OnLoadModService", { useValue: new OnLoadModService(container) });
container.register("HttpListenerModService", { useValue: new HttpListenerModService(container) });
container.register("OnUpdateModService", { useValue: new OnUpdateModService(container) });
container.register("DynamicRouterModService", { useValue: new DynamicRouterModService(container) });
container.register("StaticRouterModService", { useValue: new StaticRouterModService(container) });
container.registerType("OnLoad", "DatabaseImporter");
container.registerType("OnLoad", "PostDBModLoader");
container.registerType("OnLoad", "HandbookCallbacks");
container.registerType("OnLoad", "HttpCallbacks");
container.registerType("OnLoad", "PresetCallbacks");
container.registerType("OnLoad", "SaveCallbacks");
container.registerType("OnLoad", "TraderCallbacks"); // must occur prior to RagfairCallbacks
container.registerType("OnLoad", "RagfairPriceService");
container.registerType("OnLoad", "RagfairCallbacks");
container.registerType("OnLoad", "ModCallbacks");
container.registerType("OnLoad", "GameCallbacks");
container.registerType("OnUpdate", "DialogueCallbacks");
container.registerType("OnUpdate", "HideoutCallbacks");
container.registerType("OnUpdate", "TraderCallbacks");
container.registerType("OnUpdate", "RagfairCallbacks");
container.registerType("OnUpdate", "InsuranceCallbacks");
container.registerType("OnUpdate", "SaveCallbacks");
container.registerType("StaticRoutes", "BotStaticRouter");
container.registerType("StaticRoutes", "ClientLogStaticRouter");
container.registerType("StaticRoutes", "CustomizationStaticRouter");
container.registerType("StaticRoutes", "DataStaticRouter");
container.registerType("StaticRoutes", "DialogStaticRouter");
container.registerType("StaticRoutes", "GameStaticRouter");
container.registerType("StaticRoutes", "HealthStaticRouter");
container.registerType("StaticRoutes", "InraidStaticRouter");
container.registerType("StaticRoutes", "InsuranceStaticRouter");
container.registerType("StaticRoutes", "ItemEventStaticRouter");
container.registerType("StaticRoutes", "LauncherStaticRouter");
container.registerType("StaticRoutes", "LocationStaticRouter");
container.registerType("StaticRoutes", "WeatherStaticRouter");
container.registerType("StaticRoutes", "MatchStaticRouter");
container.registerType("StaticRoutes", "QuestStaticRouter");
container.registerType("StaticRoutes", "RagfairStaticRouter");
container.registerType("StaticRoutes", "PresetStaticRouter");
container.registerType("StaticRoutes", "BundleStaticRouter");
container.registerType("StaticRoutes", "NotifierStaticRouter");
container.registerType("StaticRoutes", "ProfileStaticRouter");
container.registerType("StaticRoutes", "TraderStaticRouter");
container.registerType("DynamicRoutes", "BotDynamicRouter");
container.registerType("DynamicRoutes", "BundleDynamicRouter");
container.registerType("DynamicRoutes", "CustomizationDynamicRouter");
container.registerType("DynamicRoutes", "DataDynamicRouter");
container.registerType("DynamicRoutes", "HttpDynamicRouter");
container.registerType("DynamicRoutes", "InraidDynamicRouter");
container.registerType("DynamicRoutes", "LocationDynamicRouter");
container.registerType("DynamicRoutes", "NotifierDynamicRouter");
container.registerType("DynamicRoutes", "TraderDynamicRouter");
container.registerType("IERouters", "CustomizationItemEventRouter");
container.registerType("IERouters", "HealthItemEventRouter");
container.registerType("IERouters", "HideoutItemEventRouter");
container.registerType("IERouters", "InsuranceItemEventRouter");
container.registerType("IERouters", "InventoryItemEventRouter");
container.registerType("IERouters", "NoteItemEventRouter");
container.registerType("IERouters", "PresetBuildItemEventRouter");
container.registerType("IERouters", "QuestItemEventRouter");
container.registerType("IERouters", "RagfairItemEventRouter");
container.registerType("IERouters", "RepairItemEventRouter");
container.registerType("IERouters", "TradeItemEventRouter");
container.registerType("IERouters", "WishlistItemEventRouter");
container.registerType("Serializer", "ImageSerializer");
container.registerType("Serializer", "BundleSerializer");
container.registerType("Serializer", "NotifySerializer");
// Registering these starts the server...?
container.registerType("SaveLoadRouter", "HealthSaveLoadRouter");
container.registerType("SaveLoadRouter", "InraidSaveLoadRouter");
container.registerType("SaveLoadRouter", "InsuranceSaveLoadRouter");
container.registerType("SaveLoadRouter", "ProfileSaveLoadRouter");
}
private async importDatabase(): Promise<void>
{
this.importerUtil = this.container.resolve<ImporterUtil>("ImporterUtil");
this.databaseServer = this.container.resolve<DatabaseServer>("DatabaseServer");
// Read the data from the JSON files.
const databaseDir = path.resolve("./assets/database");
const dataToImport = await this.importerUtil.loadAsync<IDatabaseTables>(`${databaseDir}/`);
// Save the data to memory.
this.databaseServer.setTables(dataToImport);
}
return container;
}
function registerUtils(container: DependencyContainer): void
{
// Utils
container.register<App>("App", App, { lifecycle: Lifecycle.Singleton });
container.register<DatabaseImporter>("DatabaseImporter", DatabaseImporter, { lifecycle: Lifecycle.Singleton });
container.register<HashUtil>("HashUtil", HashUtil, { lifecycle: Lifecycle.Singleton });
container.register<ImporterUtil>("ImporterUtil", ImporterUtil, { lifecycle: Lifecycle.Singleton });
container.register<HttpResponseUtil>("HttpResponseUtil", HttpResponseUtil);
container.register<EncodingUtil>("EncodingUtil", EncodingUtil, { lifecycle: Lifecycle.Singleton });
container.register<JsonUtil>("JsonUtil", JsonUtil);
container.register<WinstonMainLogger>("WinstonLogger", WinstonMainLogger, { lifecycle: Lifecycle.Singleton });
container.register<WinstonRequestLogger>("RequestsLogger", WinstonRequestLogger, { lifecycle: Lifecycle.Singleton });
container.register<MathUtil>("MathUtil", MathUtil, { lifecycle: Lifecycle.Singleton });
container.register<ObjectId>("ObjectId", ObjectId);
container.register<RandomUtil>("RandomUtil", RandomUtil, { lifecycle: Lifecycle.Singleton });
container.register<TimeUtil>("TimeUtil", TimeUtil, { lifecycle: Lifecycle.Singleton });
container.register<VFS>("VFS", VFS, { lifecycle: Lifecycle.Singleton });
// These two trouble-makers are manually mocked, as the original implementation hijacks our test console.
container.register<WatermarkLocale>("WatermarkLocale", WatermarkLocale, { lifecycle: Lifecycle.Singleton });
container.register<Watermark>("Watermark", Watermark, { lifecycle: Lifecycle.Singleton });
container.register<IAsyncQueue>("AsyncQueue", AsyncQueue, { lifecycle: Lifecycle.Singleton });
container.register<IUUidGenerator>("UUidGenerator", UUidGenerator, { lifecycle: Lifecycle.Singleton });
container.register<HttpFileUtil>("HttpFileUtil", HttpFileUtil, { lifecycle: Lifecycle.Singleton });
container.register<ModLoadOrder>("ModLoadOrder", ModLoadOrder, { lifecycle: Lifecycle.Singleton });
container.register<ModTypeCheck>("ModTypeCheck", ModTypeCheck, { lifecycle: Lifecycle.Singleton });
}
function registerRouters(container: DependencyContainer): void
{
// Routers
container.register<HttpRouter>("HttpRouter", HttpRouter, { lifecycle: Lifecycle.Singleton });
container.register<ImageRouter>("ImageRouter", ImageRouter);
container.register<EventOutputHolder>("EventOutputHolder", EventOutputHolder, { lifecycle: Lifecycle.Singleton });
container.register<ItemEventRouter>("ItemEventRouter", ItemEventRouter);
// Dynamic Routes
container.register<BotDynamicRouter>("BotDynamicRouter", { useClass: BotDynamicRouter });
container.register<BundleDynamicRouter>("BundleDynamicRouter", { useClass: BundleDynamicRouter });
container.register<CustomizationDynamicRouter>("CustomizationDynamicRouter", { useClass: CustomizationDynamicRouter });
container.register<DataDynamicRouter>("DataDynamicRouter", { useClass: DataDynamicRouter });
container.register<HttpDynamicRouter>("HttpDynamicRouter", { useClass: HttpDynamicRouter });
container.register<InraidDynamicRouter>("InraidDynamicRouter", { useClass: InraidDynamicRouter });
container.register<LocationDynamicRouter>("LocationDynamicRouter", { useClass: LocationDynamicRouter });
container.register<NotifierDynamicRouter>("NotifierDynamicRouter", { useClass: NotifierDynamicRouter });
container.register<TraderDynamicRouter>("TraderDynamicRouter", { useClass: TraderDynamicRouter });
// Item Event Routes
container.register<CustomizationItemEventRouter>("CustomizationItemEventRouter", { useClass: CustomizationItemEventRouter });
container.register<HealthItemEventRouter>("HealthItemEventRouter", { useClass: HealthItemEventRouter });
container.register<HideoutItemEventRouter>("HideoutItemEventRouter", { useClass: HideoutItemEventRouter });
container.register<InsuranceItemEventRouter>("InsuranceItemEventRouter", { useClass: InsuranceItemEventRouter });
container.register<InventoryItemEventRouter>("InventoryItemEventRouter", { useClass: InventoryItemEventRouter });
container.register<NoteItemEventRouter>("NoteItemEventRouter", { useClass: NoteItemEventRouter });
container.register<PresetBuildItemEventRouter>("PresetBuildItemEventRouter", { useClass: PresetBuildItemEventRouter });
container.register<QuestItemEventRouter>("QuestItemEventRouter", { useClass: QuestItemEventRouter });
container.register<RagfairItemEventRouter>("RagfairItemEventRouter", { useClass: RagfairItemEventRouter });
container.register<RepairItemEventRouter>("RepairItemEventRouter", { useClass: RepairItemEventRouter });
container.register<TradeItemEventRouter>("TradeItemEventRouter", { useClass: TradeItemEventRouter });
container.register<WishlistItemEventRouter>("WishlistItemEventRouter", { useClass: WishlistItemEventRouter });
// Save Load Routes
container.register<HealthSaveLoadRouter>("HealthSaveLoadRouter", { useClass: HealthSaveLoadRouter });
container.register<InraidSaveLoadRouter>("InraidSaveLoadRouter", { useClass: InraidSaveLoadRouter });
container.register<InsuranceSaveLoadRouter>("InsuranceSaveLoadRouter", { useClass: InsuranceSaveLoadRouter });
container.register<ProfileSaveLoadRouter>("ProfileSaveLoadRouter", { useClass: ProfileSaveLoadRouter });
// Route Serializers
container.register<BundleSerializer>("BundleSerializer", { useClass: BundleSerializer });
container.register<ImageSerializer>("ImageSerializer", { useClass: ImageSerializer });
container.register<NotifySerializer>("NotifySerializer", { useClass: NotifySerializer });
// Static Routes
container.register<BotStaticRouter>("BotStaticRouter", { useClass: BotStaticRouter });
container.register<BundleStaticRouter>("BundleStaticRouter", { useClass: BundleStaticRouter });
container.register<ClientLogStaticRouter>("ClientLogStaticRouter", { useClass: ClientLogStaticRouter });
container.register<CustomizationStaticRouter>("CustomizationStaticRouter", { useClass: CustomizationStaticRouter });
container.register<DataStaticRouter>("DataStaticRouter", { useClass: DataStaticRouter });
container.register<DialogStaticRouter>("DialogStaticRouter", { useClass: DialogStaticRouter });
container.register<GameStaticRouter>("GameStaticRouter", { useClass: GameStaticRouter });
container.register<HealthStaticRouter>("HealthStaticRouter", { useClass: HealthStaticRouter });
container.register<InraidStaticRouter>("InraidStaticRouter", { useClass: InraidStaticRouter });
container.register<InsuranceStaticRouter>("InsuranceStaticRouter", { useClass: InsuranceStaticRouter });
container.register<ItemEventStaticRouter>("ItemEventStaticRouter", { useClass: ItemEventStaticRouter });
container.register<LauncherStaticRouter>("LauncherStaticRouter", { useClass: LauncherStaticRouter });
container.register<LocationStaticRouter>("LocationStaticRouter", { useClass: LocationStaticRouter });
container.register<MatchStaticRouter>("MatchStaticRouter", { useClass: MatchStaticRouter });
container.register<NotifierStaticRouter>("NotifierStaticRouter", { useClass: NotifierStaticRouter });
container.register<PresetStaticRouter>("PresetStaticRouter", { useClass: PresetStaticRouter });
container.register<ProfileStaticRouter>("ProfileStaticRouter", { useClass: ProfileStaticRouter });
container.register<QuestStaticRouter>("QuestStaticRouter", { useClass: QuestStaticRouter });
container.register<RagfairStaticRouter>("RagfairStaticRouter", { useClass: RagfairStaticRouter });
container.register<TraderStaticRouter>("TraderStaticRouter", { useClass: TraderStaticRouter });
container.register<WeatherStaticRouter>("WeatherStaticRouter", { useClass: WeatherStaticRouter });
}
function registerGenerators(container: DependencyContainer): void
{
// Generators
container.register<BotGenerator>("BotGenerator", BotGenerator);
container.register<BotWeaponGenerator>("BotWeaponGenerator", BotWeaponGenerator);
container.register<BotLootGenerator>("BotLootGenerator", BotLootGenerator);
container.register<BotInventoryGenerator>("BotInventoryGenerator", BotInventoryGenerator);
container.register<LocationGenerator>("LocationGenerator", { useClass: LocationGenerator });
container.register<PMCLootGenerator>("PMCLootGenerator", PMCLootGenerator, { lifecycle: Lifecycle.Singleton });
container.register<ScavCaseRewardGenerator>("ScavCaseRewardGenerator", ScavCaseRewardGenerator, { lifecycle: Lifecycle.Singleton });
container.register<RagfairAssortGenerator>("RagfairAssortGenerator", { useClass: RagfairAssortGenerator });
container.register<RagfairOfferGenerator>("RagfairOfferGenerator", { useClass: RagfairOfferGenerator });
container.register<WeatherGenerator>("WeatherGenerator", { useClass: WeatherGenerator });
container.register<PlayerScavGenerator>("PlayerScavGenerator", { useClass: PlayerScavGenerator });
container.register<LootGenerator>("LootGenerator", { useClass: LootGenerator });
container.register<FenceBaseAssortGenerator>("FenceBaseAssortGenerator", { useClass: FenceBaseAssortGenerator });
container.register<BotLevelGenerator>("BotLevelGenerator", { useClass: BotLevelGenerator });
container.register<BotEquipmentModGenerator>("BotEquipmentModGenerator", { useClass: BotEquipmentModGenerator });
container.register<RepeatableQuestGenerator>("RepeatableQuestGenerator", { useClass: RepeatableQuestGenerator });
container.register<BarrelInventoryMagGen>("BarrelInventoryMagGen", { useClass: BarrelInventoryMagGen });
container.register<ExternalInventoryMagGen>("ExternalInventoryMagGen", { useClass: ExternalInventoryMagGen });
container.register<InternalMagazineInventoryMagGen>("InternalMagazineInventoryMagGen", { useClass: InternalMagazineInventoryMagGen });
container.register<UbglExternalMagGen>("UbglExternalMagGen", { useClass: UbglExternalMagGen });
container.registerType("InventoryMagGen", "BarrelInventoryMagGen");
container.registerType("InventoryMagGen", "ExternalInventoryMagGen");
container.registerType("InventoryMagGen", "InternalMagazineInventoryMagGen");
container.registerType("InventoryMagGen", "UbglExternalMagGen");
}
function registerHelpers(container: DependencyContainer): void
{
// Helpers
container.register<AssortHelper>("AssortHelper", { useClass: AssortHelper });
container.register<BotHelper>("BotHelper", { useClass: BotHelper });
container.register<BotGeneratorHelper>("BotGeneratorHelper", { useClass: BotGeneratorHelper });
container.register<ContainerHelper>("ContainerHelper", ContainerHelper);
container.register<DialogueHelper>("DialogueHelper", { useClass: DialogueHelper });
container.register<DurabilityLimitsHelper>("DurabilityLimitsHelper", { useClass: DurabilityLimitsHelper });
container.register<GameEventHelper>("GameEventHelper", GameEventHelper);
container.register<HandbookHelper>("HandbookHelper", HandbookHelper, { lifecycle: Lifecycle.Singleton });
container.register<HealthHelper>("HealthHelper", { useClass: HealthHelper });
container.register<HideoutHelper>("HideoutHelper", { useClass: HideoutHelper });
container.register<InRaidHelper>("InRaidHelper", { useClass: InRaidHelper });
container.register<InventoryHelper>("InventoryHelper", { useClass: InventoryHelper });
container.register<PaymentHelper>("PaymentHelper", PaymentHelper);
container.register<ItemHelper>("ItemHelper", { useClass: ItemHelper });
container.register<PresetHelper>("PresetHelper", PresetHelper, { lifecycle: Lifecycle.Singleton });
container.register<ProfileHelper>("ProfileHelper", { useClass: ProfileHelper });
container.register<QuestHelper>("QuestHelper", { useClass: QuestHelper });
container.register<QuestConditionHelper>("QuestConditionHelper", QuestConditionHelper);
container.register<RagfairHelper>("RagfairHelper", { useClass: RagfairHelper });
container.register<RagfairSortHelper>("RagfairSortHelper", { useClass: RagfairSortHelper });
container.register<RagfairSellHelper>("RagfairSellHelper", { useClass: RagfairSellHelper });
container.register<RagfairOfferHelper>("RagfairOfferHelper", { useClass: RagfairOfferHelper });
container.register<RagfairServerHelper>("RagfairServerHelper", { useClass: RagfairServerHelper });
container.register<RepairHelper>("RepairHelper", { useClass: RepairHelper });
container.register<TraderHelper>("TraderHelper", TraderHelper);
container.register<TraderAssortHelper>("TraderAssortHelper", TraderAssortHelper, { lifecycle: Lifecycle.Singleton });
container.register<TradeHelper>("TradeHelper", { useClass: TradeHelper });
container.register<NotifierHelper>("NotifierHelper", { useClass: NotifierHelper });
container.register<UtilityHelper>("UtilityHelper", UtilityHelper);
container.register<WeightedRandomHelper>("WeightedRandomHelper", { useClass: WeightedRandomHelper });
container.register<HttpServerHelper>("HttpServerHelper", { useClass: HttpServerHelper });
container.register<NotificationSendHelper>("NotificationSendHelper", { useClass: NotificationSendHelper });
container.register<SecureContainerHelper>("SecureContainerHelper", { useClass: SecureContainerHelper });
container.register<ProbabilityHelper>("ProbabilityHelper", { useClass: ProbabilityHelper });
container.register<BotWeaponGeneratorHelper>("BotWeaponGeneratorHelper", { useClass: BotWeaponGeneratorHelper });
container.register<BotDifficultyHelper>("BotDifficultyHelper", { useClass: BotDifficultyHelper });
container.register<RepeatableQuestHelper>("RepeatableQuestHelper", { useClass: RepeatableQuestHelper });
}
function registerLoaders(container: DependencyContainer): void
{
// Loaders
container.register<BundleLoader>("BundleLoader", BundleLoader, { lifecycle: Lifecycle.Singleton });
container.register<PreAkiModLoader>("PreAkiModLoader", PreAkiModLoader, { lifecycle: Lifecycle.Singleton });
container.register<PostAkiModLoader>("PostAkiModLoader", PostAkiModLoader, { lifecycle: Lifecycle.Singleton });
}
function registerCallbacks(container: DependencyContainer): void
{
// Callbacks
container.register<BotCallbacks>("BotCallbacks", { useClass: BotCallbacks });
container.register<BundleCallbacks>("BundleCallbacks", { useClass: BundleCallbacks });
container.register<ClientLogCallbacks>("ClientLogCallbacks", { useClass: ClientLogCallbacks });
container.register<CustomizationCallbacks>("CustomizationCallbacks", { useClass: CustomizationCallbacks });
container.register<DataCallbacks>("DataCallbacks", { useClass: DataCallbacks });
container.register<DialogueCallbacks>("DialogueCallbacks", { useClass: DialogueCallbacks });
container.register<GameCallbacks>("GameCallbacks", { useClass: GameCallbacks });
container.register<HandbookCallbacks>("HandbookCallbacks", { useClass: HandbookCallbacks });
container.register<HealthCallbacks>("HealthCallbacks", { useClass: HealthCallbacks });
container.register<HideoutCallbacks>("HideoutCallbacks", { useClass: HideoutCallbacks });
container.register<HttpCallbacks>("HttpCallbacks", { useClass: HttpCallbacks });
container.register<InraidCallbacks>("InraidCallbacks", { useClass: InraidCallbacks });
container.register<InsuranceCallbacks>("InsuranceCallbacks", { useClass: InsuranceCallbacks });
container.register<InventoryCallbacks>("InventoryCallbacks", { useClass: InventoryCallbacks });
container.register<ItemEventCallbacks>("ItemEventCallbacks", { useClass: ItemEventCallbacks });
container.register<LauncherCallbacks>("LauncherCallbacks", { useClass: LauncherCallbacks });
container.register<LocationCallbacks>("LocationCallbacks", { useClass: LocationCallbacks });
container.register<MatchCallbacks>("MatchCallbacks", { useClass: MatchCallbacks });
container.register<ModCallbacks>("ModCallbacks", { useClass: ModCallbacks });
container.register<PostDBModLoader>("PostDBModLoader", { useClass: PostDBModLoader });
container.register<NoteCallbacks>("NoteCallbacks", { useClass: NoteCallbacks });
container.register<NotifierCallbacks>("NotifierCallbacks", { useClass: NotifierCallbacks });
container.register<PresetBuildCallbacks>("PresetBuildCallbacks", { useClass: PresetBuildCallbacks });
container.register<PresetCallbacks>("PresetCallbacks", { useClass: PresetCallbacks });
container.register<ProfileCallbacks>("ProfileCallbacks", { useClass: ProfileCallbacks });
container.register<QuestCallbacks>("QuestCallbacks", { useClass: QuestCallbacks });
container.register<RagfairCallbacks>("RagfairCallbacks", { useClass: RagfairCallbacks });
container.register<RepairCallbacks>("RepairCallbacks", { useClass: RepairCallbacks });
container.register<SaveCallbacks>("SaveCallbacks", { useClass: SaveCallbacks });
container.register<TradeCallbacks>("TradeCallbacks", { useClass: TradeCallbacks });
container.register<TraderCallbacks>("TraderCallbacks", { useClass: TraderCallbacks });
container.register<WeatherCallbacks>("WeatherCallbacks", { useClass: WeatherCallbacks });
container.register<WishlistCallbacks>("WishlistCallbacks", { useClass: WishlistCallbacks });
}
function registerServices(container: DependencyContainer): void
{
// Services
container.register<ImageRouteService>("ImageRouteService", ImageRouteService, { lifecycle: Lifecycle.Singleton });
container.register<FenceService>("FenceService", FenceService, { lifecycle: Lifecycle.Singleton });
container.register<PlayerService>("PlayerService", { useClass: PlayerService });
container.register<PaymentService>("PaymentService", { useClass: PaymentService });
container.register<InsuranceService>("InsuranceService", InsuranceService, { lifecycle: Lifecycle.Singleton });
container.register<TraderAssortService>("TraderAssortService", TraderAssortService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairPriceService>("RagfairPriceService", RagfairPriceService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairCategoriesService>("RagfairCategoriesService", RagfairCategoriesService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairOfferService>("RagfairOfferService", RagfairOfferService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairLinkedItemService>("RagfairLinkedItemService", RagfairLinkedItemService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairRequiredItemsService>("RagfairRequiredItemsService", RagfairRequiredItemsService, { lifecycle: Lifecycle.Singleton });
container.register<NotificationService>("NotificationService", NotificationService, { lifecycle: Lifecycle.Singleton });
container.register<MatchLocationService>("MatchLocationService", MatchLocationService, { lifecycle: Lifecycle.Singleton });
container.register<ModCompilerService>("ModCompilerService", ModCompilerService);
container.register<HashCacheService>("HashCacheService", HashCacheService, { lifecycle: Lifecycle.Singleton });
container.register<LocaleService>("LocaleService", LocaleService, { lifecycle: Lifecycle.Singleton });
container.register<ProfileFixerService>("ProfileFixerService", ProfileFixerService);
container.register<RepairService>("RepairService", RepairService);
container.register<BotLootCacheService>("BotLootCacheService", BotLootCacheService, { lifecycle: Lifecycle.Singleton });
container.register<CustomItemService>("CustomItemService", CustomItemService);
container.register<BotEquipmentFilterService>("BotEquipmentFilterService", BotEquipmentFilterService);
container.register<ProfileSnapshotService>("ProfileSnapshotService", ProfileSnapshotService, { lifecycle: Lifecycle.Singleton });
container.register<ItemFilterService>("ItemFilterService", ItemFilterService, { lifecycle: Lifecycle.Singleton });
container.register<BotGenerationCacheService>("BotGenerationCacheService", BotGenerationCacheService, { lifecycle: Lifecycle.Singleton });
container.register<LocalisationService>("LocalisationService", LocalisationService, { lifecycle: Lifecycle.Singleton });
container.register<CustomLocationWaveService>("CustomLocationWaveService", CustomLocationWaveService, { lifecycle: Lifecycle.Singleton });
container.register<OpenZoneService>("OpenZoneService", OpenZoneService, { lifecycle: Lifecycle.Singleton });
container.register<ItemBaseClassService>("ItemBaseClassService", ItemBaseClassService, { lifecycle: Lifecycle.Singleton });
container.register<BotEquipmentModPoolService>("BotEquipmentModPoolService", BotEquipmentModPoolService, { lifecycle: Lifecycle.Singleton });
container.register<BotWeaponModLimitService>("BotWeaponModLimitService", BotWeaponModLimitService, { lifecycle: Lifecycle.Singleton });
container.register<SeasonalEventService>("SeasonalEventService", SeasonalEventService, { lifecycle: Lifecycle.Singleton });
container.register<MatchBotDetailsCacheService>("MatchBotDetailsCacheService", MatchBotDetailsCacheService, { lifecycle: Lifecycle.Singleton });
container.register<RagfairTaxService>("RagfairTaxService", RagfairTaxService, { lifecycle: Lifecycle.Singleton });
container.register<TraderPurchasePersisterService>("TraderPurchasePersisterService", TraderPurchasePersisterService);
container.register<PmcChatResponseService>("PmcChatResponseService", PmcChatResponseService);
container.register<GiftService>("GiftService", GiftService);
container.register<MailSendService>("MailSendService", MailSendService);
}
function registerServers(container: DependencyContainer): void
{
// Servers
container.register<DatabaseServer>("DatabaseServer", DatabaseServer, { lifecycle: Lifecycle.Singleton });
container.register<HttpServer>("HttpServer", HttpServer, { lifecycle: Lifecycle.Singleton });
container.register<WebSocketServer>("WebSocketServer", WebSocketServer, { lifecycle: Lifecycle.Singleton });
container.register<RagfairServer>("RagfairServer", RagfairServer);
container.register<SaveServer>("SaveServer", SaveServer, { lifecycle: Lifecycle.Singleton });
container.register<ConfigServer>("ConfigServer", ConfigServer, { lifecycle: Lifecycle.Singleton });
container.register<HttpBufferHandler>("HttpBufferHandler", HttpBufferHandler, {lifecycle: Lifecycle.Singleton});
}
function registerControllers(container: DependencyContainer): void
{
// Controllers
container.register<BotController>("BotController", { useClass: BotController });
container.register<ClientLogController>("ClientLogController", { useClass: ClientLogController });
container.register<CustomizationController>("CustomizationController", { useClass: CustomizationController });
container.register<DialogueController>("DialogueController", { useClass: DialogueController });
container.register<GameController>("GameController", { useClass: GameController });
container.register<HandbookController>("HandbookController", { useClass: HandbookController });
container.register<HealthController>("HealthController", { useClass: HealthController });
container.register<HideoutController>("HideoutController", { useClass: HideoutController });
container.register<InraidController>("InraidController", { useClass: InraidController });
container.register<InsuranceController>("InsuranceController", { useClass: InsuranceController });
container.register<InventoryController>("InventoryController", { useClass: InventoryController });
container.register<LauncherController>("LauncherController", { useClass: LauncherController });
container.register<LocationController>("LocationController", { useClass: LocationController });
container.register<MatchController>("MatchController", MatchController);
container.register<NoteController>("NoteController", { useClass: NoteController });
container.register<NotifierController>("NotifierController", { useClass: NotifierController });
container.register<PresetBuildController>("PresetBuildController", { useClass: PresetBuildController });
container.register<PresetController>("PresetController", { useClass: PresetController });
container.register<ProfileController>("ProfileController", { useClass: ProfileController });
container.register<QuestController>("QuestController", { useClass: QuestController });
container.register<RagfairController>("RagfairController", { useClass: RagfairController });
container.register<RepairController>("RepairController", { useClass: RepairController });
container.register<RepeatableQuestController>("RepeatableQuestController", { useClass: RepeatableQuestController });
container.register<TradeController>("TradeController", { useClass: TradeController });
container.register<TraderController>("TraderController", { useClass: TraderController });
container.register<WeatherController>("WeatherController", { useClass: WeatherController });
container.register<WishlistController>("WishlistController", WishlistController);
}
function registerListTypes(container: DependencyContainer): void
{
container.register("OnLoadModService", { useValue: new OnLoadModService(container) });
container.register("HttpListenerModService", { useValue: new HttpListenerModService(container) });
container.register("OnUpdateModService", { useValue: new OnUpdateModService(container) });
container.register("DynamicRouterModService", { useValue: new DynamicRouterModService(container) });
container.register("StaticRouterModService", { useValue: new StaticRouterModService(container) });
container.registerType("OnLoad", "DatabaseImporter");
container.registerType("OnLoad", "PostDBModLoader");
container.registerType("OnLoad", "HandbookCallbacks");
container.registerType("OnLoad", "HttpCallbacks");
container.registerType("OnLoad", "PresetCallbacks");
container.registerType("OnLoad", "SaveCallbacks");
container.registerType("OnLoad", "TraderCallbacks"); // must occur prior to RagfairCallbacks
container.registerType("OnLoad", "RagfairPriceService");
container.registerType("OnLoad", "RagfairCallbacks");
container.registerType("OnLoad", "ModCallbacks");
container.registerType("OnLoad", "GameCallbacks");
container.registerType("OnUpdate", "DialogueCallbacks");
container.registerType("OnUpdate", "HideoutCallbacks");
container.registerType("OnUpdate", "TraderCallbacks");
container.registerType("OnUpdate", "RagfairCallbacks");
container.registerType("OnUpdate", "InsuranceCallbacks");
container.registerType("OnUpdate", "SaveCallbacks");
container.registerType("StaticRoutes", "BotStaticRouter");
container.registerType("StaticRoutes", "ClientLogStaticRouter");
container.registerType("StaticRoutes", "CustomizationStaticRouter");
container.registerType("StaticRoutes", "DataStaticRouter");
container.registerType("StaticRoutes", "DialogStaticRouter");
container.registerType("StaticRoutes", "GameStaticRouter");
container.registerType("StaticRoutes", "HealthStaticRouter");
container.registerType("StaticRoutes", "InraidStaticRouter");
container.registerType("StaticRoutes", "InsuranceStaticRouter");
container.registerType("StaticRoutes", "ItemEventStaticRouter");
container.registerType("StaticRoutes", "LauncherStaticRouter");
container.registerType("StaticRoutes", "LocationStaticRouter");
container.registerType("StaticRoutes", "WeatherStaticRouter");
container.registerType("StaticRoutes", "MatchStaticRouter");
container.registerType("StaticRoutes", "QuestStaticRouter");
container.registerType("StaticRoutes", "RagfairStaticRouter");
container.registerType("StaticRoutes", "PresetStaticRouter");
container.registerType("StaticRoutes", "BundleStaticRouter");
container.registerType("StaticRoutes", "NotifierStaticRouter");
container.registerType("StaticRoutes", "ProfileStaticRouter");
container.registerType("StaticRoutes", "TraderStaticRouter");
container.registerType("DynamicRoutes", "BotDynamicRouter");
container.registerType("DynamicRoutes", "BundleDynamicRouter");
container.registerType("DynamicRoutes", "CustomizationDynamicRouter");
container.registerType("DynamicRoutes", "DataDynamicRouter");
container.registerType("DynamicRoutes", "HttpDynamicRouter");
container.registerType("DynamicRoutes", "InraidDynamicRouter");
container.registerType("DynamicRoutes", "LocationDynamicRouter");
container.registerType("DynamicRoutes", "NotifierDynamicRouter");
container.registerType("DynamicRoutes", "TraderDynamicRouter");
container.registerType("IERouters", "CustomizationItemEventRouter");
container.registerType("IERouters", "HealthItemEventRouter");
container.registerType("IERouters", "HideoutItemEventRouter");
container.registerType("IERouters", "InsuranceItemEventRouter");
container.registerType("IERouters", "InventoryItemEventRouter");
container.registerType("IERouters", "NoteItemEventRouter");
container.registerType("IERouters", "PresetBuildItemEventRouter");
container.registerType("IERouters", "QuestItemEventRouter");
container.registerType("IERouters", "RagfairItemEventRouter");
container.registerType("IERouters", "RepairItemEventRouter");
container.registerType("IERouters", "TradeItemEventRouter");
container.registerType("IERouters", "WishlistItemEventRouter");
container.registerType("Serializer", "ImageSerializer");
container.registerType("Serializer", "BundleSerializer");
container.registerType("Serializer", "NotifySerializer");
container.registerType("SaveLoadRouter", "HealthSaveLoadRouter");
container.registerType("SaveLoadRouter", "InraidSaveLoadRouter");
container.registerType("SaveLoadRouter", "InsuranceSaveLoadRouter");
container.registerType("SaveLoadRouter", "ProfileSaveLoadRouter");
}
async function importDatabase(container: DependencyContainer): Promise<void>
{
const importerUtil = container.resolve<ImporterUtil>("ImporterUtil");
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
// Read the data from the JSON files.
const databaseDir = path.resolve("./assets/database");
const dataToImport = await importerUtil.loadAsync<IDatabaseTables>(`${databaseDir}/`);
// Save the data to memory.
databaseServer.setTables(dataToImport);
}

View File

@ -1,5 +1,7 @@
import "reflect-metadata";
import { vi, beforeAll, afterEach, describe, expect, it } from "vitest";
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
import { DependencyContainer } from "tsyringe";
import { Item, Repairable } from "@spt-aki/models/eft/common/tables/IItem";
@ -11,22 +13,15 @@ describe("ItemHelper", () =>
let container: DependencyContainer;
let itemHelper: ItemHelper;
// Spies
let handbookHelperGetTemplatePriceSpy: jest.SpyInstance;
let loggerWarningSpy: jest.SpyInstance;
let loggerErrorSpy: jest.SpyInstance;
let databaseServerGetTablesSpy: jest.SpyInstance;
let jsonUtilCloneSpy: jest.SpyInstance;
beforeAll(() =>
{
container = globalThis.container;
container = global.container;
itemHelper = container.resolve<ItemHelper>("ItemHelper");
});
afterEach(() =>
{
jest.restoreAllMocks();
vi.restoreAllMocks();
});
describe("isValidItem", () =>
@ -52,7 +47,7 @@ describe("ItemHelper", () =>
it("should return false when item's price is zero", () =>
{
// Unsure if any item has price of "0", so mock the getItemPrice method to return 0.
jest.spyOn(itemHelper, "getItemPrice").mockReturnValue(0);
vi.spyOn(itemHelper, "getItemPrice").mockReturnValue(0);
const result = itemHelper.isValidItem("5fc64ea372b0dd78d51159dc");
expect(result).toBe(false);
@ -112,7 +107,7 @@ describe("ItemHelper", () =>
const staticPrice = 1;
const tpl = "590c657e86f77412b013051d";
jest.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(staticPrice);
vi.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(staticPrice);
const result = itemHelper.getItemPrice(tpl);
@ -125,8 +120,8 @@ describe("ItemHelper", () =>
const dynamicPrice = 42069;
const tpl = "590c657e86f77412b013051d";
jest.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(staticPrice);
jest.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(dynamicPrice);
vi.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(staticPrice);
vi.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(dynamicPrice);
const result = itemHelper.getItemPrice(tpl);
@ -138,8 +133,8 @@ describe("ItemHelper", () =>
{
const tpl = "590c657e86f77412b013051d";
jest.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(0);
jest.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(0);
vi.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(0);
vi.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(0);
const result = itemHelper.getItemPrice(tpl);
@ -156,8 +151,8 @@ describe("ItemHelper", () =>
const dynamicPrice = 69;
const tpl = "590c657e86f77412b013051d";
jest.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(staticPrice);
jest.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(dynamicPrice);
vi.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(staticPrice);
vi.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(dynamicPrice);
const result = itemHelper.getItemMaxPrice(tpl);
@ -170,8 +165,8 @@ describe("ItemHelper", () =>
const dynamicPrice = 420;
const tpl = "590c657e86f77412b013051d";
jest.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(staticPrice);
jest.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(dynamicPrice);
vi.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(staticPrice);
vi.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(dynamicPrice);
const result = itemHelper.getItemMaxPrice(tpl);
@ -183,8 +178,8 @@ describe("ItemHelper", () =>
const price = 42069;
const tpl = "590c657e86f77412b013051d";
jest.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(price);
jest.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(price);
vi.spyOn(itemHelper, "getStaticItemPrice").mockReturnValue(price);
vi.spyOn(itemHelper, "getDynamicItemPrice").mockReturnValue(price);
const result = itemHelper.getItemMaxPrice(tpl);
@ -209,7 +204,7 @@ describe("ItemHelper", () =>
const price = 42069;
const tpl = "590c657e86f77412b013051d";
handbookHelperGetTemplatePriceSpy = jest.spyOn((itemHelper as any).handbookHelper, "getTemplatePrice");
const handbookHelperGetTemplatePriceSpy = vi.spyOn((itemHelper as any).handbookHelper, "getTemplatePrice");
handbookHelperGetTemplatePriceSpy.mockReturnValue(price);
const result = itemHelper.getStaticItemPrice(tpl);
@ -222,7 +217,7 @@ describe("ItemHelper", () =>
const price = 0;
const tpl = "590c657e86f77412b013051d"; // "Grizzly medical kit"
handbookHelperGetTemplatePriceSpy = jest.spyOn((itemHelper as any).handbookHelper, "getTemplatePrice");
const handbookHelperGetTemplatePriceSpy = vi.spyOn((itemHelper as any).handbookHelper, "getTemplatePrice");
handbookHelperGetTemplatePriceSpy.mockReturnValue(price);
const result = itemHelper.getStaticItemPrice(tpl);
@ -320,7 +315,7 @@ describe("ItemHelper", () =>
const parentId = container.resolve<HashUtil>("HashUtil").generate();
loggerWarningSpy = jest.spyOn((itemHelper as any).logger, "warning");
const loggerWarningSpy = vi.spyOn((itemHelper as any).logger, "warning");
itemHelper.generateItemsFromStackSlot(ammoBox[1], parentId);
@ -332,8 +327,8 @@ describe("ItemHelper", () =>
{
it("should call databaseServer.getTables() and jsonUtil.clone() methods", () =>
{
databaseServerGetTablesSpy = jest.spyOn((itemHelper as any).databaseServer, "getTables");
jsonUtilCloneSpy = jest.spyOn((itemHelper as any).jsonUtil, "clone");
const databaseServerGetTablesSpy = vi.spyOn((itemHelper as any).databaseServer, "getTables");
const jsonUtilCloneSpy = vi.spyOn((itemHelper as any).jsonUtil, "clone");
itemHelper.getItems();
@ -404,7 +399,7 @@ describe("ItemHelper", () =>
it("should call getItem with the provided tpl", () =>
{
const itemHelperSpy = jest.spyOn(itemHelper, "getItem");
const itemHelperSpy = vi.spyOn(itemHelper, "getItem");
const tpl = "590c657e86f77412b013051d"; // "Grizzly medical kit"
@ -717,7 +712,7 @@ describe("ItemHelper", () =>
_tpl: ""
};
loggerErrorSpy = jest.spyOn((itemHelper as any).logger, "error");
const loggerErrorSpy = vi.spyOn((itemHelper as any).logger, "error");
// Cast the method to any to allow access to private/protected method.
(itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item);

View File

@ -1,6 +1,8 @@
import "reflect-metadata";
import { DependencyContainer } from "tsyringe";
import { vi, beforeAll, afterEach, describe, expect, it } from "vitest";
import { DependencyContainer } from "tsyringe";
import { PaymentService } from "@spt-aki/services/PaymentService";
describe("PaymentService", () =>
@ -10,13 +12,13 @@ describe("PaymentService", () =>
beforeAll(() =>
{
container = globalThis.container;
container = global.container;
paymentService = container.resolve<PaymentService>("PaymentService");
});
afterEach(() =>
{
jest.restoreAllMocks();
vi.restoreAllMocks();
});
describe("should be registered", () =>

View File

@ -8,6 +8,9 @@
"paths": {
"@spt-aki/*": [
"src/*"
],
"@tests/*": [
"tests/*"
]
}
},

View File

@ -4,7 +4,8 @@
"outDir": "obj",
"declaration": true,
"sourceMap": true,
"noImplicitAny": false
"noImplicitAny": false,
"types": ["vitest/globals"],
},
"include": [
"./types/**/*",

16
project/vitest.config.ts Normal file
View File

@ -0,0 +1,16 @@
/* eslint-disable @typescript-eslint/naming-convention */
import path from "path";
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
name: "spt-server",
root: "./tests",
environment: "./CustomEnvironment.ts",
globals: true,
alias: {
"@spt-aki": path.resolve(__dirname, "src"),
"@tests": path.resolve(__dirname, "tests")
}
}
});