Chat / backend /src /modules /notifications /notifications.controller.ts
kishankrish19's picture
Deploy Stillwave fullstack clean
b0798af
Raw History Blame Contribute Delete
1.07 kB
import { Controller, Get, Patch, Param, UseGuards, Req } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { NotificationsService } from './notifications.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
@ApiTags('In-App Notifications')
@Controller('me/notifications')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
export class NotificationsController {
constructor(private readonly notifService: NotificationsService) {}
@Get()
@ApiOperation({ summary: 'Paginated list of user notifications' })
getNotifications(@Req() req: any) {
return this.notifService.getNotifications(req.user.userId);
}
@Patch('read-all')
@ApiOperation({ summary: 'Mark all notifications as read' })
markAllAsRead(@Req() req: any) {
return this.notifService.markAllAsRead(req.user.userId);
}
@Patch(':id/read')
@ApiOperation({ summary: 'Mark single notification as read' })
markAsRead(@Req() req: any, @Param('id') id: string) {
return this.notifService.markAsRead(req.user.userId, id);
}
}