Skip to content

Conversation

@jvpalves
Copy link

Corrigindo o projeto.

Copy link
Author

@jvpalves jvpalves left a 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
Copy link
Author

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 {
Copy link
Author

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;
Copy link
Author

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.

Comment on lines +16 to +18
if(!amizadeId) {
throw new Error('Insira um id válido')
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boa Validação!

Comment on lines +21 to +25
const user = await userDataBase.getUserByEmail(amizadeId);

if(!user) {
throw new Error('Usuário não existe')
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outra excelente validação!

Copy link
Author

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.

Comment on lines +9 to +14
const token = req.headers.authorization as string;
const authenticator = new Authenticator();
const authenticationData = authenticator.verify(token);
const userId = authenticationData.id;

const idGenerator = new IdGenerator();
Copy link
Author

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.

Comment on lines +8 to +11




Copy link
Author

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

Comment on lines +15 to +18
app.post('/signup', signup);
app.post('/login', login);
app.post('/post', newPost);

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants