feat: backend API NestJS + Prisma + JWT auth + todos los módulos

This commit is contained in:
Lizandro Guarnizo
2026-06-01 21:23:04 -05:00
parent b31f778b3b
commit 3c5d81603a
69 changed files with 35734 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import { Controller, Get, Patch, Param, Body, UseGuards, Req } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { UsersService } from './users.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
@ApiTags('Users')
@Controller('users')
export class UsersController {
constructor(private users: UsersService) {}
@Get()
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
findAll() {
return this.users.findAll();
}
@Get(':id')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
findById(@Param('id') id: string) {
return this.users.findById(id);
}
@Patch('me')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
update(@Req() req, @Body() data: any) {
return this.users.update(req.user.sub, data);
}
@Patch('fcm-token')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
updateFcmToken(@Req() req, @Body() dto: { token: string }) {
return this.users.updateFcmToken(req.user.sub, dto.token);
}
}
+10
View File
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { UsersService } from './users.service';
import { UsersController } from './users.controller';
@Module({
providers: [UsersService],
controllers: [UsersController],
exports: [UsersService],
})
export class UsersModule {}
+29
View File
@@ -0,0 +1,29 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
@Injectable()
export class UsersService {
constructor(private prisma: PrismaService) {}
findAll() {
return this.prisma.users.findMany({ orderBy: { created_at: 'desc' } });
}
findById(id: string) {
return this.prisma.users.findUnique({
where: { id },
include: {
professionals: { include: { schedules: true, specializations: true } },
reputations: true,
},
});
}
update(id: string, data: any) {
return this.prisma.users.update({ where: { id }, data });
}
updateFcmToken(id: string, fcm_token: string) {
return this.prisma.users.update({ where: { id }, data: { fcm_token } });
}
}