Files
flyer-crawler.projectium.com/src/services/gamificationService.ts
Torben Sorensen fc8e43437a
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Failing after 56s
test fixes
2026-01-04 02:21:08 -08:00

46 lines
1.5 KiB
TypeScript

// src/services/gamificationService.ts
import { gamificationRepo } from './db/index.db';
import type { Logger } from 'pino';
class GamificationService {
/**
* Awards a specific achievement to a user.
* @param userId The ID of the user to award the achievement.
* @param achievementName The name of the achievement to award.
* @param log The logger instance.
*/
async awardAchievement(userId: string, achievementName: string, log: Logger): Promise<void> {
// The repository layer handles database errors, including logging and throwing specific error types.
// This service method simply orchestrates the call.
return gamificationRepo.awardAchievement(userId, achievementName, log);
}
/**
* Retrieves the master list of all available achievements.
* @param log The logger instance.
*/
async getAllAchievements(log: Logger) {
return gamificationRepo.getAllAchievements(log);
}
/**
* Retrieves the public leaderboard of top users by points.
* @param limit The number of users to fetch.
* @param log The logger instance.
*/
async getLeaderboard(limit: number, log: Logger) {
return gamificationRepo.getLeaderboard(limit, log);
}
/**
* Retrieves all achievements earned by a specific user.
* @param userId The ID of the user.
* @param log The logger instance.
*/
async getUserAchievements(userId: string, log: Logger) {
return gamificationRepo.getUserAchievements(userId, log);
}
}
export const gamificationService = new GamificationService();