feat: Add token-based authorization to category deletion and enhance user registration with error handling and audit logging.
This commit is contained in:
parent
45941fbe6c
commit
af14610442
16 changed files with 1003 additions and 236 deletions
|
|
@ -5,6 +5,8 @@ import { logger } from '../config/logger';
|
|||
import { listCourseResponse, getCourseResponse, ListCoursesInput } from '../types/courses.types';
|
||||
import { UnauthorizedError, ValidationError, ForbiddenError } from '../middleware/errorHandler';
|
||||
import { getPresignedUrl } from '../config/minio';
|
||||
import { auditService } from './audit.service';
|
||||
import { AuditAction } from '@prisma/client';
|
||||
|
||||
export class CoursesService {
|
||||
async ListCourses(input: ListCoursesInput): Promise<listCourseResponse> {
|
||||
|
|
@ -82,6 +84,16 @@ export class CoursesService {
|
|||
};
|
||||
} catch (error) {
|
||||
logger.error('Failed to fetch courses', { error });
|
||||
await auditService.logSync({
|
||||
userId: 0,
|
||||
action: AuditAction.ERROR,
|
||||
entityType: 'Course',
|
||||
entityId: 0,
|
||||
metadata: {
|
||||
operation: 'list_courses',
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
}
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
@ -122,6 +134,16 @@ export class CoursesService {
|
|||
};
|
||||
} catch (error) {
|
||||
logger.error('Failed to fetch course', { error });
|
||||
await auditService.logSync({
|
||||
userId: 0,
|
||||
action: AuditAction.ERROR,
|
||||
entityType: 'Course',
|
||||
entityId: id,
|
||||
metadata: {
|
||||
operation: 'get_course',
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
}
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue