docs: add JSDoc to service public methods

One-line JSDoc on 82 methods across 11 service files for quick
scanning without reading full implementations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
syntaxbullet
2026-04-02 11:36:18 +02:00
parent 5f8819bb46
commit 5bd390b4ee
11 changed files with 82 additions and 10 deletions

View File

@@ -29,6 +29,7 @@ let cacheTimestamp = 0;
const CACHE_TTL_MS = 30000;
export const gameSettingsService = {
/** Retrieve game settings, using a 30-second TTL cache by default. */
getSettings: async (useCache = true): Promise<GameSettingsData | null> => {
if (useCache && cachedSettings && Date.now() - cacheTimestamp < CACHE_TTL_MS) {
return cachedSettings;
@@ -56,6 +57,7 @@ export const gameSettingsService = {
return cachedSettings;
},
/** Create or update game settings, merging with existing values and invalidating cache. */
upsertSettings: async (data: Partial<GameSettingsData>) => {
const existing = await gameSettingsService.getSettings(false);
@@ -86,6 +88,7 @@ export const gameSettingsService = {
return result;
},
/** Update a single configuration section (e.g., "leveling", "economy") and invalidate cache. */
updateSection: async <K extends keyof GameSettingsData>(
section: K,
value: GameSettingsData[K]
@@ -102,6 +105,7 @@ export const gameSettingsService = {
gameSettingsService.invalidateCache();
},
/** Enable or disable a specific command in the game settings. */
toggleCommand: async (commandName: string, enabled: boolean) => {
const settings = await gameSettingsService.getSettings(false);
@@ -117,11 +121,13 @@ export const gameSettingsService = {
await gameSettingsService.updateSection("commands", commands);
},
/** Invalidate the in-memory settings cache, forcing a fresh DB read on next access. */
invalidateCache: () => {
cachedSettings = null;
cacheTimestamp = 0;
},
/** Return default leveling configuration values. */
getDefaultLeveling: (): LevelingConfig => ({
base: 100,
exponent: 1.5,
@@ -132,6 +138,7 @@ export const gameSettingsService = {
},
}),
/** Return default economy configuration values. */
getDefaultEconomy: (): EconomyConfig => ({
daily: {
amount: "100",
@@ -149,11 +156,13 @@ export const gameSettingsService = {
},
}),
/** Return default inventory configuration values. */
getDefaultInventory: (): InventoryConfig => ({
maxStackSize: "99",
maxSlots: 20,
}),
/** Return default lootdrop configuration values. */
getDefaultLootdrop: (): LootdropConfig => ({
activityWindowMs: 300000,
minMessages: 5,
@@ -166,6 +175,7 @@ export const gameSettingsService = {
},
}),
/** Return default trivia configuration values. */
getDefaultTrivia: (): TriviaConfig => ({
entryFee: "50",
rewardMultiplier: 1.8,
@@ -175,6 +185,7 @@ export const gameSettingsService = {
difficulty: "random",
}),
/** Return default moderation configuration values. */
getDefaultModeration: (): ModerationConfig => ({
prune: {
maxAmount: 100,
@@ -184,10 +195,12 @@ export const gameSettingsService = {
},
}),
/** Return default quest configuration values. */
getDefaultQuest: (): QuestConfig => ({
maxActiveQuests: 3,
}),
/** Return the complete set of default game settings across all sections. */
getDefaults: (): GameSettingsData => ({
leveling: gameSettingsService.getDefaultLeveling(),
economy: gameSettingsService.getDefaultEconomy(),