feat: add logging and caching enhancements across core services

Integrate `Logger` for consistent logging in services like `reports`, `categories`, `users`, `contents`, and more. Introduce caching capabilities with `CacheInterceptor` and manual cache clearing logic for categories, users, and contents. Add request throttling to critical auth endpoints for enhanced rate limiting.
This commit is contained in:
Mathis HERRIOT
2026-01-10 16:31:06 +01:00
parent 9654553940
commit 5a22ad7480
12 changed files with 129 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
import {
ConflictException,
Injectable,
Logger,
NotFoundException,
} from "@nestjs/common";
import { and, eq } from "drizzle-orm";
@@ -9,9 +10,12 @@ import { contents, favorites } from "../database/schemas";
@Injectable()
export class FavoritesService {
private readonly logger = new Logger(FavoritesService.name);
constructor(private readonly databaseService: DatabaseService) {}
async addFavorite(userId: string, contentId: string) {
this.logger.log(`Adding favorite: user ${userId}, content ${contentId}`);
// Vérifier si le contenu existe
const content = await this.databaseService.db
.select()
@@ -35,6 +39,7 @@ export class FavoritesService {
}
async removeFavorite(userId: string, contentId: string) {
this.logger.log(`Removing favorite: user ${userId}, content ${contentId}`);
const result = await this.databaseService.db
.delete(favorites)
.where(and(eq(favorites.userId, userId), eq(favorites.contentId, contentId)))