forked from syntaxbullet/aurorabot
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 { levelingService } from "@shared/modules/leveling/leveling.service";
|
||||||
import { economyService } from "@shared/modules/economy/economy.service";
|
import { economyService } from "@shared/modules/economy/economy.service";
|
||||||
import { userTimers } from "@db/schema";
|
import { userTimers } from "@db/schema";
|
||||||
import type { EffectHandler } from "./types";
|
import type { EffectHandler } from "./effect.types";
|
||||||
import type { LootTableItem } from "@shared/lib/types";
|
import type { LootTableItem } from "@shared/lib/types";
|
||||||
import { inventoryService } from "@shared/modules/inventory/inventory.service";
|
import { inventoryService } from "@shared/modules/inventory/inventory.service";
|
||||||
import { inventory, items } from "@db/schema";
|
import { inventory, items } from "@db/schema";
|
||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
handleTempRole,
|
handleTempRole,
|
||||||
handleColorRole,
|
handleColorRole,
|
||||||
handleLootbox
|
handleLootbox
|
||||||
} from "./handlers";
|
} from "./effect.handlers";
|
||||||
import type { EffectHandler } from "./types";
|
import type { EffectHandler } from "./effect.types";
|
||||||
|
|
||||||
export const effectHandlers: Record<string, EffectHandler> = {
|
export const effectHandlers: Record<string, EffectHandler> = {
|
||||||
'ADD_XP': handleAddXp,
|
'ADD_XP': handleAddXp,
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import type { Transaction } from "@shared/lib/types";
|
import type { Transaction } from "@shared/lib/types";
|
||||||
|
|
||||||
export type EffectHandler = (userId: string, effect: any, txFn: Transaction) => Promise<any>;
|
export type EffectHandler = (userId: string, effect: any, txFn: Transaction) => Promise<any>;
|
||||||
@@ -171,7 +171,7 @@ export const inventoryService = {
|
|||||||
const results: any[] = [];
|
const results: any[] = [];
|
||||||
|
|
||||||
// 2. Apply Effects
|
// 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) {
|
for (const effect of usageData.effects) {
|
||||||
const handler = effectHandlers[effect.type];
|
const handler = effectHandlers[effect.type];
|
||||||
|
|||||||
Reference in New Issue
Block a user