Closed CassianoJunior closed 1 year ago
Por enquanto não tenho nada a adicionar. Caso lembre de algo falo aqui. Confiram se vocês têm algo a adicionar @assis23 @JoseeAugusto @EduardoRibeiroBR
Também não tenho por enquanto, está bem claro e explicado.
Ok!
Para definir o que será preciso para criar ou atualizar um registro, são usados DTO (Data Transfer Objects).
// src/dtos/user/create-user.dto.ts
type CreateUserDTO = {
fullName: string
email: string
username: string
password: string
}
export { CreateUserDTO }
Eles são as tipagens para o objeto recebido pelo método create
ou update
no repository.
Padrões de código
Fluxo back-end
Arquitetura de 3 camadas:
routes
>controllers
>services
>repositories
>database
Routes: Mapeia qual rota vai chamar qual método do controller
Controllers: são responsáveis por implementar o roteamento do aplicativo e a lógica de tratamento de solicitações, bem como lidar com erros e exceções e implementar a lógica de autenticação e autorização.
Services: Recebem os dados do controlador e realizam toda a regra de negócio da aplicação. Possui um repository como dependência obrigatória.
Repository: São os responsáveis pelo acesso ao banco de dados.
Exemplos
Repositories
Services
Registrando as rotas