feat: centralized constants and enums for project-wide use

This commit is contained in:
syntaxbullet
2026-01-06 18:15:52 +01:00
parent c807fd4fd0
commit 34347f0c63
17 changed files with 144 additions and 63 deletions

View File

@@ -3,6 +3,7 @@ import { eq, sql, and } from "drizzle-orm";
import { withTransaction } from "@/lib/db";
import { config } from "@/lib/config";
import type { Transaction } from "@/lib/types";
import { TimerType } from "@/lib/constants";
export const levelingService = {
// Calculate total XP required to REACH a specific level (Cumulative)
@@ -78,7 +79,7 @@ export const levelingService = {
const cooldown = await txFn.query.userTimers.findFirst({
where: and(
eq(userTimers.userId, BigInt(id)),
eq(userTimers.type, 'COOLDOWN'),
eq(userTimers.type, TimerType.COOLDOWN),
eq(userTimers.key, 'chat_xp')
),
});
@@ -95,7 +96,7 @@ export const levelingService = {
const xpBoost = await txFn.query.userTimers.findFirst({
where: and(
eq(userTimers.userId, BigInt(id)),
eq(userTimers.type, 'EFFECT'),
eq(userTimers.type, TimerType.EFFECT),
eq(userTimers.key, 'xp_boost')
)
});
@@ -114,7 +115,7 @@ export const levelingService = {
await txFn.insert(userTimers)
.values({
userId: BigInt(id),
type: 'COOLDOWN',
type: TimerType.COOLDOWN,
key: 'chat_xp',
expiresAt: nextReadyAt,
})