-
Notifications
You must be signed in to change notification settings - Fork 0
PR de correção #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: correcao-projeto
Are you sure you want to change the base?
Conversation
Branch one
Arquitetura da aplicacao
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Olá, Pedro! Este é o review do seu código. Deixei alguns comentários ao longo do projeto. Você fez um projeto bem sólido, apesar das coisinhas apontadas mais pontualmente. Os principais pontos de atenção são sobre a consistência da arquitetura. Em alguns pontos você usou a camada de business, em outros não, algumas classes estão em arquivos separados, por exemplo. Outro pontinho é o excesso de espaços em branco, que acabam dificultando um pouco a leitura. De resto, muito bom, parabéns!
| public signup = async (name: string, email: string, password: string)=> { | ||
| if(!name || !email || !password) { | ||
| throw new Error('Insira todas as informações necessárias para o cadastro'); | ||
| }//regra de negocio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lembre de remover os comentários!
| import { HashManager } from "../services/HashManager"; | ||
| import { IdGenerator } from "../services/IdGenerator"; | ||
|
|
||
| export class UserloginBusiness { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talvez essa classe possa ser absorvida pela UserBusiness
| export const followUser = async (req: Request, res: Response) => { | ||
| try { | ||
| const token = req.headers.authorization as string; | ||
| const amizadeId = req.body.amizadeId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cuidado ao misturar idiomas nos nomes de variável.
| if(!amizadeId) { | ||
| throw new Error('Insira um id válido') | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boa Validação!
| const user = await userDataBase.getUserByEmail(amizadeId); | ||
|
|
||
| if(!user) { | ||
| throw new Error('Usuário não existe') | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outra excelente validação!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uma outra boa é checar se a amizade já existe antes de criar.
| const token = req.headers.authorization as string; | ||
| const authenticator = new Authenticator(); | ||
| const authenticationData = authenticator.verify(token); | ||
| const userId = authenticationData.id; | ||
|
|
||
| const idGenerator = new IdGenerator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aqui seria interessante manter o padrão das classes de user e jogar as dependências para a classe de business.
|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Atenção aos espaços em branco
| app.post('/signup', signup); | ||
| app.post('/login', login); | ||
| app.post('/post', newPost); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O feed acabou ficando sem endpoint.
Corrigindo o projeto.