In the part of error handling you can extract the name and code of the erro const {name,code}=error This will help in writing better custom error messages
When you throw an error you should not send a 200 statuscode to the client so if there's any scenario where res.status is 200 during an error, it will default it to 500
@@internetexplorer7880by your logic this line doesn’t make sense if the status code is 201 it will send 201 and 3** will send 3** which it used for redirects and so on.
Brother i think there is a issue with your Mic i can't watch your video full because it hurts my ear the Mic sound sounds just like scratching in board with nails. I do want to watch the video but my ears just can't handle the mic sound
Zod is a great choice if you're looking for a simple and performant validation library that can handle basic validation scenarios. Joi is a good choice if you need a highly customizable validation library that can handle complex validation scenarios
Thanks for valuable insights into server security !!!
These tips can be applied in general, not just Express. Thanks for your time.
Honorable mention to Flask.
Good one but I don't see a link to the CORS video. It would be helpful for future watchers if you add it to the description.
i want to ask, about the error handling, if its a async function, how to handle it? because the middleware seems cant handle that with throw
In the part of error handling you can extract the name and code of the erro
const {name,code}=error
This will help in writing better custom error messages
error.message also works fine
Which theme do you use in vscode ?
Valuable stuff 🎉❤
thx, concise but pretty informative.
clear and valuable !! thanks a lot
Thanks , keep posting content like this
what is theme color you are using bro
ayu mirage i think
THANK YOU SO0 MUCH BUIDDY !!!!!! VERY VERY important !!!!1
Good explanation Sir! What is the kind of color theme VSCode btw?
This is really very useful.
After adding the errorHandler middleware your "bad" route is still going to get caught in the error middleware
const statusCode = res.statusCode !== 200 ? res.statusCode : 500
I don't get this line, if 200 we assign 500? Can you expalin?
Good catch, its a bug
When you throw an error you should not send a 200 statuscode to the client so if there's any scenario where res.status is 200 during an error, it will default it to 500
@@internetexplorer7880by your logic this line doesn’t make sense if the status code is 201 it will send 201 and 3** will send 3** which it used for redirects and so on.
@@mikedev4673 I think the same. Anyway maybe it would be better to call always 500 in case of error?
@@internetexplorer7880exactly.. now i get it
Zod is better imo tho for validation 👀
Say A Bottle of water🤣
Brother i think there is a issue with your Mic i can't watch your video full because it hurts my ear the Mic sound sounds just like scratching in board with nails. I do want to watch the video but my ears just can't handle the mic sound
😄
Professionals use ZOD for validation!!!
Zod is a great choice if you're looking for a simple and performant validation library that can handle basic validation scenarios. Joi is a good choice if you need a highly customizable validation library that can handle complex validation scenarios
Merci
Good day greetings
Only NestJS ❤❤
Nestjs is better than express but it has less community , less tutorials
Is there is nestJs ? I always thought its was spelling mistake for nextJs
If you like a OOP you should try it.
@@yashinox5410OOP in JS sucks...
Actually in this case there is only 1 mistake - using such a ****** like express.
Salty