forked from syntaxbullet/AuroraBot-discord
fix: address security review findings, implement real cache clearing, and fix lifecycle promises
This commit is contained in:
@@ -7,6 +7,7 @@ const envSchema = z.object({
|
||||
DATABASE_URL: z.string().min(1, "Database URL is required"),
|
||||
PORT: z.coerce.number().default(3000),
|
||||
HOST: z.string().default("127.0.0.1"),
|
||||
ADMIN_TOKEN: z.string().min(8, "ADMIN_TOKEN must be at least 8 characters"),
|
||||
});
|
||||
|
||||
const parsedEnv = envSchema.safeParse(process.env);
|
||||
|
||||
@@ -59,6 +59,12 @@ export const ClientStatsSchema = z.object({
|
||||
|
||||
export type ClientStats = z.infer<typeof ClientStatsSchema>;
|
||||
|
||||
// Action Schemas
|
||||
export const MaintenanceModeSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
reason: z.string().optional(),
|
||||
});
|
||||
|
||||
// WebSocket Message Schemas
|
||||
export const WsMessageSchema = z.discriminatedUnion("type", [
|
||||
z.object({ type: z.literal("PING") }),
|
||||
|
||||
@@ -163,6 +163,11 @@ class LootdropService {
|
||||
return { success: false, error: "An error occurred while processing the reward." };
|
||||
}
|
||||
}
|
||||
public async clearCaches() {
|
||||
this.channelActivity.clear();
|
||||
this.channelCooldowns.clear();
|
||||
console.log("[LootdropService] Caches cleared via administrative action.");
|
||||
}
|
||||
}
|
||||
|
||||
export const lootdropService = new LootdropService();
|
||||
|
||||
@@ -196,5 +196,10 @@ export const tradeService = {
|
||||
});
|
||||
|
||||
tradeService.endSession(threadId);
|
||||
},
|
||||
|
||||
clearSessions: () => {
|
||||
sessions.clear();
|
||||
console.log("[TradeService] All active trade sessions cleared.");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user