added exception filter and removed controller error handling

This commit is contained in:
unknown
2024-10-06 11:04:25 +03:00
26 changed files with 780 additions and 1345 deletions

View File

@ -2,7 +2,6 @@ import {
Body,
Controller,
Get,
HttpException,
HttpStatus,
Param,
Post,
@ -34,41 +33,27 @@ export class UserNotificationController {
async addUserSubscription(
@Body() userNotificationAddDto: UserNotificationAddDto,
) {
try {
const addDetails = await this.userNotificationService.addUserSubscription(
userNotificationAddDto,
);
return {
statusCode: HttpStatus.CREATED,
message: 'User Notification Added Successfully',
data: addDetails,
};
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
const addDetails = await this.userNotificationService.addUserSubscription(
userNotificationAddDto,
);
return {
statusCode: HttpStatus.CREATED,
message: 'User Notification Added Successfully',
data: addDetails,
};
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get(':userUuid')
async fetchUserSubscriptions(@Param('userUuid') userUuid: string) {
try {
const userDetails =
await this.userNotificationService.fetchUserSubscriptions(userUuid);
return {
statusCode: HttpStatus.OK,
message: 'User Notification fetched Successfully',
data: { ...userDetails },
};
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
const userDetails =
await this.userNotificationService.fetchUserSubscriptions(userUuid);
return {
statusCode: HttpStatus.OK,
message: 'User Notification fetched Successfully',
data: { ...userDetails },
};
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@ -76,19 +61,12 @@ export class UserNotificationController {
async updateUserSubscription(
@Body() userNotificationUpdateDto: UserNotificationUpdateDto,
) {
try {
await this.userNotificationService.updateUserSubscription(
userNotificationUpdateDto,
);
return {
statusCode: HttpStatus.OK,
message: 'User subscription updated Successfully',
};
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
await this.userNotificationService.updateUserSubscription(
userNotificationUpdateDto,
);
return {
statusCode: HttpStatus.OK,
message: 'User subscription updated Successfully',
};
}
}