feat: backend API NestJS + Prisma + JWT auth + todos los módulos
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { Controller, Get, Post, Param, Body, UseGuards, Req } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { ChatService } from './chat.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
|
||||
@ApiTags('Chat')
|
||||
@Controller('chat')
|
||||
export class ChatController {
|
||||
constructor(private chat: ChatService) {}
|
||||
|
||||
@Post('start/:professionalId')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
start(@Req() req, @Param('professionalId') professionalId: string) {
|
||||
return this.chat.getOrCreateChat(req.user.sub, professionalId);
|
||||
}
|
||||
|
||||
@Post(':chatId/message')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
sendMessage(@Req() req, @Param('chatId') chatId: string, @Body() dto: { content: string }) {
|
||||
return this.chat.sendMessage(chatId, req.user.sub, dto.content);
|
||||
}
|
||||
|
||||
@Get('my')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
myChats(@Req() req) {
|
||||
return this.chat.getUserChats(req.user.sub);
|
||||
}
|
||||
|
||||
@Get(':chatId/messages')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
messages(@Param('chatId') chatId: string) {
|
||||
return this.chat.getChatMessages(chatId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user