architecture refactoring

This commit is contained in:
Cesar
2026-05-22 19:26:38 -06:00
parent 34dbfd051b
commit c2e53eb21b
20 changed files with 949 additions and 222 deletions

View File

@@ -0,0 +1,45 @@
/**
* auth.repository.impl.ts
* AuthRepositoryImpl: implementación real del AuthRepository.
* Aquí es donde hablamos con la base de datos usando Prisma.
*/
import { AuthRepository } from "../../domain/repositories/auth.repository.js";
import { prisma } from "../postgres/index.js";
export class AuthRepositoryImpl implements AuthRepository {
async findByEmail(email: string) {
return prisma.user.findUnique({
where: { email },
select: {
id: true,
email: true,
password: true,
name: true,
},
});
}
async create(data: { name: string; email: string; password: string }) {
return prisma.user.create({
data,
select: {
id: true,
email: true,
name: true,
},
});
}
async findById(id: number) {
return prisma.user.findUnique({
where: { id },
select: {
id: true,
email: true,
name: true,
role: true,
},
});
}
}