This tutorial will help you learn all about middleware in Express JS. It applies built-in middleware, custom middleware that we will construct to log events and handle errors, and third party middleware. If you're just getting started with Node.js, you may want to start at the beginning of the Node.js for Beginners tutorials playlist found here: kzbin.info/aero/PL0Zuz27SZ-6PFkIxaJ6Xx_X46avTM1aYw
@Alibeee872 жыл бұрын
Thank you for all your help! I appreciate you mentioning keyboard commands as well, that's fantastic info for a beginner!
@DaveGrayTeachesCode2 жыл бұрын
You're welcome! 🙏
@viciousinsights69022 жыл бұрын
This has been truly enlightening, this series has helped me tremendously with the aspects of node & expressjs I had been struggling with. I look forward to learning more from you in the future!
@DaveGrayTeachesCode2 жыл бұрын
Glad it helped! 🚀
@ahmad-murery3 жыл бұрын
Well explained Dave, Middleware can be very handy to allow only authentic users to access certain pages, I recently started using the Rest Client extension for VS Code instead of Postman, I found it easier to work with as I don't have to leave VS Code to test my API, it also let me have all my requests in a plain text file that can be included side by side with the app files. Thanks Dave 🚀
@DaveGrayTeachesCode3 жыл бұрын
Thank you Ahmad. 🙏 Yes, there are many good applications of middleware including authentication. Is the VS Code extension you are using called Thunder Client? I have heard good things!
@DaveGrayTeachesCode3 жыл бұрын
@@ahmad-murery thank you my friend! I will check them both out and compare. Have a great weekend!
@ahmad-murery3 жыл бұрын
@@DaveGrayTeachesCode Have a great day you too my friend, if possible, make a video about the comparison and maybe put it under the web dev tools playlist, regards
@DaveGrayTeachesCode3 жыл бұрын
@@ahmad-murery thank you - great idea, Ahmad!
@juangomez8742 жыл бұрын
Dave, you are my new hero. Thanks a lot for these videos, they had helped me a lot. Very very clear. Keep up the good job.
@DaveGrayTeachesCode2 жыл бұрын
Thank you for the kind words, Juan! 🙏
@pets_talk2 жыл бұрын
great tutorial! Coming from the frontend world, it really helps me to undestand how the backend works!
@DaveGrayTeachesCode2 жыл бұрын
Happy to help! Thanks Natalia! 🙏💯
@NaviaryMusic Жыл бұрын
Thanks Dave!! My websites coming along nicely!
@DaveGrayTeachesCode Жыл бұрын
Fantastic!
@saquibansari7866 Жыл бұрын
6:02 Check this time stamp And can you please elaborate that the path of css file you have assigned is different as we used to assign without middlware. I found it after searching alot that the path of middlware and the path of opening html file in a browser will be different. I still don't know why it is so. So kindly clear this out.. please please please please❤❤❤❤❤
@wgllgw3 ай бұрын
Hi Dave, you must be a very good teacher/mentor. I would love to work under/learn from someone like you! You addressed a lot of pertinent questions, in a prudent sequence. Plus your explanations are clear and concise. It lends a lot of motivation to why things are they way they are (these are the hardest thing to Google!). Thank you so much for taking the time and effort to share your knowledge and wisdom!
@ampinkus9 ай бұрын
Hi Dave, I just finished this module of the course and o far it is really excellent! I would only recommend that each module should start with an introductory slide explaining what will be developed in the module and perhaps a graph with the interaction of the different functions that will be implemented.
@ofofononoumoren Жыл бұрын
Absolutely great video. Just for improvement purpose, it's best to import logger as a single value (const logger = require('./destination')) rather than as an object with named properties since that not how it was exported in the logEvents file. Even if, it doesn't matter anyways. Thanks for this very elaborate module, Dave.
@MrQVeeBoo Жыл бұрын
Very nice explanation. Step by step. Easy to follow. Thx
@loikvokhidov7688 Жыл бұрын
algorithm should recommend these videos to all the people who want to learn NodeJS.
@DaveGrayTeachesCode Жыл бұрын
Thank you!
@cyberpaimpol2 жыл бұрын
Super tutorial, progression is smooth and so interesting, thx !
@DaveGrayTeachesCode2 жыл бұрын
Happy to hear that!
@piotrekjazz12872 жыл бұрын
Apart from the great content, thanks a lot also for the source code, that slowly becomes a youtube standard, at least at most of the popular channels.
@DaveGrayTeachesCode2 жыл бұрын
You're welcome. 🙏 Early on in this series, I don't think I provided it. I often think typing out the code helps students learn. As we started to put together a REST API project I thought the source code would be good to build upon as the series progressed.
@piotrekjazz12872 жыл бұрын
@@DaveGrayTeachesCode Good point, but most of the time you want to check/test just a small bits and then it is problematic writing everything.
@moiraleon87442 жыл бұрын
Quick question, what extension do you have that allows your file names in your Explorer tab to have different icons and colors?
@DaveGrayTeachesCode2 жыл бұрын
That is vscode-icons. I recommend 5 extensions here: kzbin.info/www/bejne/roLGoYScetqgh9k
@Uniqlo9215 ай бұрын
Hey dave, at @34:51, I accidentally forgot the "else" in the if else block for req.accepts('json'). So it was if(req.accepts('html') followed by if(req.accepts('json'). When I tested with my browser, I got the JSON response. So it seems that my request accepted both html and json. However, I noticed that you said we needed postman to test the json functionality, which I agreed with until I hit my issue. Do you know why the above happened. I also wanted to thank you for making such a fantastic and comprehensive tutorial on Node. I am currently using this to get out of my automated testing pigeonhole :)
@unique33452 жыл бұрын
A very useful tutorial!!!!
@DaveGrayTeachesCode2 жыл бұрын
Glad it was helpful!
@DeepakGupta-hj2dv3 жыл бұрын
Can you please make a video node JS microservices crash course
@DaveGrayTeachesCode3 жыл бұрын
Thank you for the good suggestion! 🙏
@mertfromhellАй бұрын
im edging to this playlist rn
@DrCash7 Жыл бұрын
Ona managed vps and keep running into cors error when my front end loads and talks to the backend. I've added the cors settings after the installed apps and still running into cors errors. Need halp
@soudaminipanda Жыл бұрын
Very nice tutorial. Very easy to understand
@baxtables Жыл бұрын
when a new Error("Not allowed by CORS") is created, does the app.use(errorHandler) receive it automatically, because it has a first arguement as err?
@brandonjoaocastillo7490 Жыл бұрын
Why you dont use next() in the errorHandler function? you did it in logger, its because is the last middleware or something like that?
@DaveGrayTeachesCode Жыл бұрын
You are correct - if my memory is right, it is last.
@denmccormik7654 Жыл бұрын
Thank you for the lesson. Do you know why browser doesn't allow to fetch from console from it's starting window (when url is empty, when we just opened the browser without starter page)? I thought that origin just will be undefined but everything would work.
@DaveGrayTeachesCode Жыл бұрын
The browser always implements cors. Ref: developer.mozilla.org/en-US/docs/Web/HTTP/CORS
@tabliqatchi66962 жыл бұрын
This is gem people!
@keithbacalso94332 жыл бұрын
Even I did not removed the `.css` I can still access it in the browser.... ? why?
@bnmbnm72782 жыл бұрын
24:56 Excuse me, can you explain why the code(line 80-83) work? How does it work? I cannot understand...Thank you...
@DaveGrayTeachesCode2 жыл бұрын
app.use() indicates we are going to use middleware. We're passing in an anonymous function as the middleware. The function is sending an http status code of 500 along with the error message in the response to the client.
@sonamohialdin33762 жыл бұрын
Amazing tutorial thank you
@DaveGrayTeachesCode2 жыл бұрын
You're welcome, Sona! 💯
@NoorNoor-bl2jr3 ай бұрын
There is no logs file in your git repository.
@DaveGrayTeachesCode3 ай бұрын
Yes, you should create your own logs.
@kkomax7 Жыл бұрын
This tut hasn't been liked enough. I usually don't comment to thank, but thanks Dave
@ramziosta2 жыл бұрын
I got an error optionsSuccessStatus undefined , so I declared let optionsSuccessStatus; outside corsOptions, and that removed the error and got everything to work fine. is that an allowed hack?
@DaveGrayTeachesCode2 жыл бұрын
I would not do that. I suggest downloading my source code and comparing to yours to find the difference and what caused your error.
@MohammadBarghamadii2 жыл бұрын
Thank you so much
@DaveGrayTeachesCode2 жыл бұрын
You're welcome, Mohammad!
@Pareshbpatel11 ай бұрын
A comprehensive tutorial on Middleware in Express, beautifully presented. Thanks, Dave {2023-10-05}: implemented
Thank you very much for this lesson. With all due respect. and I do sincerely and deeply have A LOT of respect for everything you are doing here: For me, the last part where you immediately say to "Like" the video is a bit too aggressive, Without a single second of silence to breathe, to process, and to execute the "Like" on our own - Without you asking us to do so, but just because of a natural sense of gratitude. I feel less sympathy for this kind of... "strategy"(?), because... Whoever likes the video - will give them a "Like", And whoever likes to subscribe - will certainly subscribe. Furthermore, think of people who already subscribed to your channel, And yet don't have any other choice but to listen to this request in the end of each and every video, Regardless of the fact that they already did it. My suggestion (/request) : Give your viewers a little bit more credit 😌 (in addition, there is actually a graphic invitation to subscribe during the videos already...)
@Jazz__Dev Жыл бұрын
is channel is not the only one you know... As a matter of fact, I love listening to that part... just watch the tutorial and move on... All these are absolutely unnecessary..
@Jazz__Dev Жыл бұрын
fetch('localhost:3500') Promise {} VM1113:1 GET localhost:3500/ net::ERR_FAILED (anonymous) @ VM1113:1 VM1113:1 Uncaught (in promise) TypeError: Failed to fetch at :1:1 HI Dave, not sure if i'm the only one getting this particular error and i'm not even sure where to fix it... Why is the console fetch throwing that error please?
@DaveGrayTeachesCode Жыл бұрын
The fetch is failing, but it is difficult to say why from here. After it fails, you get a type error. Go back over it and check your source code compared to mine. One little thing can make a difference.
@AdityaDey424 Жыл бұрын
Hey have you solve the issue? I also get this problem. If you solve this then please told me the solution.
@kaustavbhattacherjee7952 Жыл бұрын
I'm getting the same error as well even when I use the exact same snippet
@shreyalanka9 ай бұрын
Same here😢
@Riowx76 ай бұрын
Same but i am also not getting data in log file when i used fetch('localhost:3500') in google.com