refactor(inventory): flatten effects directory structure
Move effect handlers from effects/ subdirectory to flat structure: - effects/handlers.ts → effect.handlers.ts - effects/registry.ts → effect.registry.ts - effects/types.ts → effect.types.ts Update import path in inventory.service.ts from '@/modules/inventory/effects/registry' to '@/modules/inventory/effect.registry'. This reduces directory nesting and follows the convention of keeping module files flat unless there are 5+ files.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { levelingService } from "@shared/modules/leveling/leveling.service";
|
||||
import { economyService } from "@shared/modules/economy/economy.service";
|
||||
import { userTimers } from "@db/schema";
|
||||
import type { EffectHandler } from "./types";
|
||||
import type { EffectHandler } from "./effect.types";
|
||||
import type { LootTableItem } from "@shared/lib/types";
|
||||
import { inventoryService } from "@shared/modules/inventory/inventory.service";
|
||||
import { inventory, items } from "@db/schema";
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
handleTempRole,
|
||||
handleColorRole,
|
||||
handleLootbox
|
||||
} from "./handlers";
|
||||
import type { EffectHandler } from "./types";
|
||||
} from "./effect.handlers";
|
||||
import type { EffectHandler } from "./effect.types";
|
||||
|
||||
export const effectHandlers: Record<string, EffectHandler> = {
|
||||
'ADD_XP': handleAddXp,
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import type { Transaction } from "@shared/lib/types";
|
||||
|
||||
export type EffectHandler = (userId: string, effect: any, txFn: Transaction) => Promise<any>;
|
||||
@@ -171,7 +171,7 @@ export const inventoryService = {
|
||||
const results: any[] = [];
|
||||
|
||||
// 2. Apply Effects
|
||||
const { effectHandlers } = await import("@/modules/inventory/effects/registry");
|
||||
const { effectHandlers } = await import("@/modules/inventory/effect.registry");
|
||||
|
||||
for (const effect of usageData.effects) {
|
||||
const handler = effectHandlers[effect.type];
|
||||
|
||||
Reference in New Issue
Block a user