Skip to content

Preparando review#1

Open
thiagoribb wants to merge 1 commit intoissitarual:mainfrom
thiagoribb:main
Open

Preparando review#1
thiagoribb wants to merge 1 commit intoissitarual:mainfrom
thiagoribb:main

Conversation

@thiagoribb
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Author

@thiagoribb thiagoribb left a comment

Choose a reason for hiding this comment

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

Oi, Laura! Tudo bem? :)
De maneira geral, mostrou domínio dos conceitos apresentados em aula e apresentou um código bem organizado e conciso. A arquitetura da aplicação ficou muito bem implementada e o uso do TypeORM foi excelente! Levantei alguns pontos de atenção relacionados com a necessidade de tipagem quando trabalhamos com TypeScript e também sobre as boas práticas nos testes de integração. Qualquer dúvida é só chamar :)

Comment on lines -4 to -27
async function listProfessors(req: Request, res: Response){
try{
const professor = await allProfessors();
res.send(professor);
}
catch(e){
console.log(e);
res.sendStatus(500);
}
}

async function findProfessorTests(req: Request, res: Response){
const { id } = req.params;
if(!id) return res.sendStatus(404);
try{
const tests = await findTesteByProfessorId(parseInt(id));
if (!tests) return res.sendStatus(400);
else return res.send(tests);
}
catch(e){
console.log(e);
res.sendStatus(500);
}
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

É uma boa pratica tipar os retornos das funções de service e de valores enviados na requisição por query.


async function newTest(req: Request, res: Response){
const { name, url, professorId, typeId, subjectId }: CreateTest = req.body;
if(!name || !url || !professorId || !typeId || !subjectId) return res.sendStatus(404);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

É uma prática atribuir essa lógica implementada na condição do if à uma variável no intuito de deixar o código mais semântico.

Comment on lines -1 to -4
import { getRepository } from "typeorm";
import Professor from "../entities/professor";
import Tests from "../entities/test";

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Esses arquivos na verdade compõem a camada de services e não de repositories.

Comment on lines -34 to -40
async function types(){
const type = await getRepository(Type).find({
select: ["id", "name"]
});

return type;
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

É recomendado definir o nome da função de forma que represente a tarefa que ela vai executar.

@@ -1,4 +0,0 @@
module.exports = {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Teste

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.

1 participant