Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 9x 9x 9x 9x 9x 9x 9x 9x 2x 2x 9x 3x 3x | import { Controller, Get, Put, Query, Req, UseGuards } from '@nestjs/common';
import { NotificationService } from './notification.service';
import { AuthGuard } from '../auth/auth.guard';
import { ApiRequest } from '../auth/types/api-request';
import {
ApiBearerAuth,
ApiOperation,
ApiQuery,
ApiTags,
} from '@nestjs/swagger';
import { NotificationDto } from './dto/notification.dto';
@ApiTags('Notifications')
@ApiBearerAuth()
@Controller('notifications')
@UseGuards(AuthGuard)
export class NotificationController {
constructor(private readonly notificationsService: NotificationService) {}
@Get()
@ApiOperation({ summary: 'Get notifications for the user' })
async getNotifications(@Req() req: ApiRequest): Promise<NotificationDto[]> {
const userId = req.user.userId;
return this.notificationsService.getNotificationsForUser(userId);
}
@Put('read')
@ApiOperation({ summary: 'Mark a notification as read' })
@ApiQuery({
name: 'id',
type: String,
description: 'ID of the notification to mark as read',
})
async markNotificationAsRead(
@Req() req: ApiRequest,
@Query('id') id: string,
): Promise<void> {
const userId = req.user.userId;
await this.notificationsService.markNotificationAsRead(userId, id);
}
}
|