Skip to content
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

Preparando revisão do código #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

neaar3
Copy link

@neaar3 neaar3 commented Apr 27, 2022

No description provided.

Copy link
Author

@neaar3 neaar3 left a comment

Choose a reason for hiding this comment

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

Oi Ray! Tudo joia?

Inicialmente parabéns pela entrega!
Esse é o code review do projeto. Fiquei muito feliz pelo seu desempenho. Irei comentar o que achar relevante para tentar te ajudar a elevar ainda mais o seu nivel.

Abraços!

return res.status(422).send(error.message);
break;
}
console.log(error);
Copy link
Author

Choose a reason for hiding this comment

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

cuidado com console.log no código 👀

Comment on lines -87 to -130
function generateUniqueCardNumber() {
return faker.finance.creditCardNumber("mastercard");
}
async function generateCardholderName(employeeId: number) {
const employee = await employeeRepository.findById(employeeId);
const name = employee.fullName;
const names = name.split(" ");
const meio = new Array();

for (let i = 1; i < names.length - 1; i++) {
if (names[i].length >= 3) {
meio.push(name[i][0]);
}
}
const finalName = [names[0], meio, names[names.length - 1]];

return finalName.join(" ").toUpperCase();
}
function defineExpirationDate() {
return dayjs(Date.now()).add(5, "year").format("MM-YY");
}
function generateEncriptedCVC() {
const CVC = faker.finance.creditCardCVV();
return bcrypt.hashSync(CVC, 10);
}
async function generateCardData(employeeId: number, type: TransactionTypes) {
const cardNumber = generateUniqueCardNumber();
const cardHolderName = await generateCardholderName(employeeId);
const expirationDate = defineExpirationDate();
const encryptedCVC = generateEncriptedCVC();
const cardData = {
employeeId,
number: cardNumber,
cardHolderName,
securityCode: encryptedCVC,
expirationDate,
password: null,
isVirtual: true,
originalCardId: null,
isBlocked: true,
type,
};
return cardData;
}
Copy link
Author

Choose a reason for hiding this comment

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

Maior parte dessas funções poderia estar em uma utils de cartão. Deixaria a service mais limpa e focada no que ela precisa atuar.

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.

None yet

1 participant