-
Notifications
You must be signed in to change notification settings - Fork 0
PR de Correção #8
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: branch-para-correcao
Are you sure you want to change the base?
Conversation
Atividade 16/03/2020 segunda-feira
Atividade 17/03/2020 Terça-Feira
18/03/2020 - quarta-feira - adc desafio 1 e 2
Alteração do funcionamento do feed - 19/03/2020
Ajustes no código
Correção do feed
Projeto Food4U | entrega final | sexta-ferira 20/03/2020
joaogolias
left a comment
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.
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 | |||
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.
Legal!
| "uuid": "^7.0.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/jsonwebtoken": "^8.3.8" |
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.
Normalmente, a gente deixa todos os @types no devDependencies
| @@ -0,0 +1,49 @@ | |||
| export class Recipe { | |||
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.
Muito bom!
| @@ -0,0 +1,5 @@ | |||
| export abstract class BaseError extends Error { | |||
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.
Muito legal!!
|
|
||
| export class InvalidParameterError extends BaseError { | ||
| constructor(message: string) { | ||
| super(401, message); |
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.
Só falando, para "Parâmetros" errados, a gente usa normalmente o código de eror 422
| 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") | ||
| } | ||
| } |
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.
Muito legal!
| } | ||
| } | ||
|
|
||
| if(!user.getPasswordTime()){ |
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.
Poderia ser um else para o if de cima não?
| 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", | ||
| }; |
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.
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) |
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.
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é?
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.
Nós fizemos o feed reverso conforme o exemplo em aula do Darvas :)
| // 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. |
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.
:D
No description provided.