Skip to content

Conversation

@joaogolias
Copy link

No description provided.

Copy link
Author

@joaogolias joaogolias left a comment

Choose a reason for hiding this comment

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

Pessoal, o código de vocês ficou bem legal! Fiquei bem contente de que resolveram vários itens, incluindo os desafios! Continuem crescendo assim! Parabéns!

@@ -1,2 +1,3 @@
node_modules/
build/
.env No newline at end of file
Copy link
Author

Choose a reason for hiding this comment

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

Legal!

"uuid": "^7.0.2"
},
"devDependencies": {
"@types/jsonwebtoken": "^8.3.8"
Copy link
Author

Choose a reason for hiding this comment

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

Normalmente, a gente deixa todos os @types no devDependencies

@@ -0,0 +1,49 @@
export class Recipe {
Copy link
Author

Choose a reason for hiding this comment

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

Muito bom!

@@ -0,0 +1,5 @@
export abstract class BaseError extends Error {
Copy link
Author

Choose a reason for hiding this comment

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

Muito legal!!


export class InvalidParameterError extends BaseError {
constructor(message: string) {
super(401, message);
Copy link
Author

Choose a reason for hiding this comment

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

Só falando, para "Parâmetros" errados, a gente usa normalmente o código de eror 422

Comment on lines +27 to +35
if(user.getPasswordTime()){
const lastChangePassword = user.getPasswordTime()?.getTime() as number
const currentyTime = new Date().getTime()
const actualTimeStamp = (currentyTime - lastChangePassword) / 3600

if(actualTimeStamp < 2){
throw new Error("senha não pode ser alterada antes de 2 horas")
}
}
Copy link
Author

Choose a reason for hiding this comment

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

Muito legal!

}
}

if(!user.getPasswordTime()){
Copy link
Author

Choose a reason for hiding this comment

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

Poderia ser um else para o if de cima não?

Comment on lines +10 to +32
if (!input) {
return undefined
}

if (input.email) {
if (input.email.indexOf("@") === -1) {
throw new Error("Invalid email");
}

await this.userGateway.changeEmail(input.email, input.userId);
}

if (input.name) {
await this.userGateway.changeName(input.name, input.userId);
}

if (input.birthDate) {
await this.userGateway.changeBirthDate(input.birthDate, input.userId);
}

return {
message: "Usuário atualizado com sucesso",
};
Copy link
Author

Choose a reason for hiding this comment

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

Teria sido melhor dar um jeito de fazer uma Query só no banco para atualizar tudo, já que aqui você faz 4 queries no banco "no pior caso"


public async execute(input: GetFeedUCInput): Promise<GetFeedUCOutput[] | undefined> {
try {
const results = await this.recipeGateway.getFeed(input.userId)
Copy link
Author

Choose a reason for hiding this comment

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

A ideia aqui era pegar os posts de todos os usuários que esse usuário está seguindo! Acho que não está fazendo isso aqui, né?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nós fizemos o feed reverso conforme o exemplo em aula do Darvas :)

Comment on lines +34 to +47
// Desafio 1

// a) Com os conhecimentos adquiridos ao longo da semana foi mais tranquilo realizar esse desafio.
// b) Esse endpoint agora também pega as informações de name e data de aniversário

// Desafio 2

// ok

// Desafio 3
// A autenticação não é prejudicada porque no token só esta guardado o id do usuário.

// Dsafio 4
// a) alteramos a entidade de usuário, colocando um passwordTime opcional, e assim que o usuario fosse alterar a senha, caso esse passwordTime fosse nulo ele mudara a senha e adicionara o passwordTime do momento, senão ele verificaria a diferença entre eles e se fosse maior que 2 horas ele iria alterar e salvar o novo dateTime, caso contrario retornaria o erro.
Copy link
Author

Choose a reason for hiding this comment

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

:D

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