feat: backend API NestJS + Prisma + JWT auth + todos los módulos
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import { Controller, Get, Post, Patch, Param, Body, UseGuards, Req } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { ServicesService } from './services.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
|
||||
@ApiTags('Services')
|
||||
@Controller('services')
|
||||
export class ServicesController {
|
||||
constructor(private services: ServicesService) {}
|
||||
|
||||
@Post()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
create(@Req() req, @Body() data: any) {
|
||||
return this.services.create({ ...data, user_id: req.user.sub });
|
||||
}
|
||||
|
||||
@Get('me')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
findByMe(@Req() req) {
|
||||
return this.services.findByUser(req.user.sub);
|
||||
}
|
||||
|
||||
@Get('professional')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
findByProfessional(@Req() req) {
|
||||
return this.services.findByProfessional(req.user.sub);
|
||||
}
|
||||
|
||||
@Get('professional/requests')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
requestsByProfessional(@Req() req) {
|
||||
return this.services.findRequestsByProfessional(req.user.sub);
|
||||
}
|
||||
|
||||
@Get('professional/history')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
historyByProfessional(@Req() req) {
|
||||
return this.services.getHistoryByProfessional(req.user.sub);
|
||||
}
|
||||
|
||||
@Get('me/history')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
historyByUser(@Req() req) {
|
||||
return this.services.getHistoryByUser(req.user.sub);
|
||||
}
|
||||
|
||||
@Get('professional/calendar')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
calendarByProfessional(@Req() req) {
|
||||
return this.services.getCalendarByProfessional(req.user.sub);
|
||||
}
|
||||
|
||||
@Get('public-calendar/:professionalId')
|
||||
getPublicCalendar(@Param('professionalId') id: string) {
|
||||
return this.services.getPublicCalendar(id);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
findById(@Param('id') id: string) {
|
||||
return this.services.findById(id);
|
||||
}
|
||||
|
||||
@Patch(':id/status')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
updateStatus(@Param('id') id: string, @Body() dto: { status: string }) {
|
||||
return this.services.updateStatus(id, dto.status);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user