feat: backend API NestJS + Prisma + JWT auth + todos los módulos
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { Controller, Get, Post, Patch, Param, Body, UseGuards, Req, Query } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { ProfessionalsService } from './professionals.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
|
||||
@ApiTags('Professionals')
|
||||
@Controller('professionals')
|
||||
export class ProfessionalsController {
|
||||
constructor(private pros: ProfessionalsService) {}
|
||||
|
||||
@Get()
|
||||
findAllActive() {
|
||||
return this.pros.findAllActive();
|
||||
}
|
||||
|
||||
@Get('me')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
findByMe(@Req() req) {
|
||||
return this.pros.findByUserId(req.user.sub);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findById(@Param('id') id: string) {
|
||||
return this.pros.findById(id);
|
||||
}
|
||||
|
||||
@Post('request')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
request(@Req() req, @Body() data: any) {
|
||||
return this.pros.requestProfessional(req.user.sub, data);
|
||||
}
|
||||
|
||||
@Patch('me')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
update(@Req() req, @Body() data: any) {
|
||||
return this.pros.upsert(req.user.sub, data);
|
||||
}
|
||||
|
||||
@Patch('me/schedules')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
updateSchedules(@Req() req, @Body() data: { schedules: any[] }) {
|
||||
return this.pros.updateSchedules(req.user.sub, data.schedules);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user