Skip to content

Hw06 email#4

Open
AgaP151 wants to merge 5 commits into
masterfrom
hw06-email
Open

Hw06 email#4
AgaP151 wants to merge 5 commits into
masterfrom
hw06-email

Conversation

@AgaP151
Copy link
Copy Markdown
Owner

@AgaP151 AgaP151 commented Mar 9, 2024

No description provided.

Copy link
Copy Markdown

@KamilMr KamilMr left a comment

Choose a reason for hiding this comment

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

Hej,
Zadanie zatwierdzam. Zobacz sobie jeszce obsługę błędów w express i uzywanie bloków try catch w zapytaniach synchronicznych i asynchronicznych.
Powodzenia w dalszych etapach.

avatarURL,
verificationToken,
});
const verifyEmail = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
const verifyEmail = {
const msgOpt = {

Zmieniłbym to np na msgOpt lub opt.

const { email } = req.body;
const user = await User.findOne({ email });
if (!user) {
throw HttpError(404, "User not found");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Zamiast throw w tych najwyższych ścieżkach trzeba zwrócić błąd użytkownikowi. Bo zastanawiam się co przechwyci ten throw? Jeśli robisz tutaj throw to znaczy że gdzieś wyżej, czyli w miejscu gdzie jest użyta funkcja resendVerifyEmail jest blok catch. Jeśli tego bloku nie ma, to aplikacja przestanie działać.

I to się tyczy wielu miejsc.

html: `<a target="_blank" href="http://localhost:3000/api/user/verify/${user.verificationToken}">Click verify email</a>`,
};

await sendEmail(verifyEmail);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Te najwyższe funkcje async powinny być otoczone w jakimś try catch statement aby obsługiwać błędy które pojawiają się w kodzie.

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.

2 participants