-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Conversation
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.
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); |
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.
cuidado com console.log no código 👀
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; | ||
} |
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.
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.
No description provided.