What is Express middleware and how does it work? (in-depth)

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ธ.ค. 2024

ความคิดเห็น • 184

  • @mykalimba
    @mykalimba 4 ปีที่แล้ว +26

    Note to everyone watching: if you ever see your browser spin-waiting as seen in some points in this video, that's usually an indication that the app isn't completing a path through your middleware or route handlers. Sometimes it's a missing call to next(), like shown here. Sometimes there's a code path through a route handler that doesn't call a res.end(), res.json(), or res.whatever().

    • @Dev-tf2bx
      @Dev-tf2bx 6 หลายเดือนก่อน

      yeah .. learned that hard way ! (took me a week to figure out )

  • @MichaelMooregrownman
    @MichaelMooregrownman 4 ปีที่แล้ว +49

    Great video! You may be one of the few that totally explains Express middleware. Also I agree that understanding middleware will help make you a better Express Developer. I feel like a better Express Dev already

    • @NewHorizon-v9p
      @NewHorizon-v9p 4 ปีที่แล้ว +1

      sure , because express itself build on 2 concepts first is middleware function second is callback functions . if you comfortable with these concepts so you good to go

  • @josuerbague6851
    @josuerbague6851 2 ปีที่แล้ว +4

    One of the few tutorial makers who create understandable ones. You deserve more views.

  • @slow_start
    @slow_start 4 ปีที่แล้ว +18

    Zach! Brotha! You have single-handedly demystified everything surrounding Express and Passport for me. Something literally every major js tutorial youtuber has failed to do. So glad I found you man, thanks again. Subbed.

  • @bunnybloods768
    @bunnybloods768 4 ปีที่แล้ว +1

    This is the only video in youtube that you can easily understand what is middleware is

  • @atee3938
    @atee3938 2 ปีที่แล้ว

    I have been trying to understand middleware concept ,watched several tutorial ,this explains everything perfectly and all my doubt cleared.its the best explanation on TH-cam after watching all explanation on middleware

  • @sadhucat4476
    @sadhucat4476 4 ปีที่แล้ว +15

    Such understandable explanations. I love that he fully explains how and why things work.

  • @thankyouthankyou1172
    @thankyouthankyou1172 ปีที่แล้ว +1

    I like your teaching very much! it is clear, calm. thank you so much, I've learnt a lot from you

  • @Moch117
    @Moch117 2 ปีที่แล้ว

    Bro I've watched so many videos on Express middleware and NONE of them covers the concepts like you do. They are all just spitting out code without explaining WHY things work the way they do. I found the error handling and next() explanations extremely helpful.
    Thank you!

    • @zachgoll
      @zachgoll  2 ปีที่แล้ว

      Nice, that’s definitely the goal of this channel. I want to show 1) why something works and 2) how I figured it out. Glad to hear you’re getting that out of it!!

  • @josphatoluoch5205
    @josphatoluoch5205 4 ปีที่แล้ว +1

    I am at 12:17 but already liking it. Thank a lot Zach for the good explanations.

  • @tayyabferozi
    @tayyabferozi 2 ปีที่แล้ว

    The guy just gives concepts, rather than giving "how to do this" or "how to do that" tutorials.... Love from Pakistan

  • @armaandhanji2112
    @armaandhanji2112 4 ปีที่แล้ว +7

    Really appreciate the longer videos like these that really dig into the details. Thanks again so much! Subscribed.

  • @hyakoissei466
    @hyakoissei466 2 ปีที่แล้ว

    This is the best resource for understanding Express middleware on the whole internet

  • @rizgamingvids
    @rizgamingvids 4 ปีที่แล้ว +6

    Thank you very much for helping to understand the middlewares in express. I have been confusing in understanding the middlewares since last a couple of months and today you helped me to understand this concept very well. Thank you again.

  • @justadev____7232
    @justadev____7232 4 ปีที่แล้ว +2

    After reading/watching from multiple sources, finally someone who teaches this concept in a way that I get it!!!! Thanks Zach!!! Your teaching abilities are amazing!!! Props!!!!

  • @nithishkumars1657
    @nithishkumars1657 3 ปีที่แล้ว

    I dont know how u cleared my doubts that i have been confusing my myself with......but yaah...ur magic worked....hatsoff mann.....love from India ❤️

  • @Hayden-ws7ru
    @Hayden-ws7ru ปีที่แล้ว

    Before this series I was dumb enough to not know, what I didn't know. Absolute legendary explanations, thank you very much!

  • @yitzchaksviridyuk932
    @yitzchaksviridyuk932 3 ปีที่แล้ว +2

    Thank you very much for the time and effort you invest into making these videos. They are high quality, and you're the first developer on TH-cam I've actually seen explain these things. Thanks again.

    • @zachgoll
      @zachgoll  3 ปีที่แล้ว +1

      You're very welcome!

  • @jjkelsey1180
    @jjkelsey1180 4 ปีที่แล้ว +3

    I've watched several videos explaining express.js...and this video is the most clear and informative one for me. Thank you so much :D

  • @deveshkumar2533
    @deveshkumar2533 3 ปีที่แล้ว

    Zach..Brother....!! Under 10k subscribers for this channel, unbelievable . I just don't understand this world sometimes. You solve mysteries like none other!!

    • @zachgoll
      @zachgoll  3 ปีที่แล้ว

      Really appreciate it, we’re almost there though!!

  • @lukemuga434
    @lukemuga434 4 ปีที่แล้ว

    Wow!!! Now this is an in-depth guide to express middleware.

  • @chidibede2417
    @chidibede2417 4 ปีที่แล้ว

    Wowww, I have been working with middlewares without actually understanding it in such details...THANK YOU!!!!!!!!!! My Computer Professor I never had

  • @manishmadan5543
    @manishmadan5543 2 ปีที่แล้ว

    waiting for such detailed explanation from a long time, my quest is finally over !

  • @hiteshkayastha2490
    @hiteshkayastha2490 3 ปีที่แล้ว

    Bro! I am very thankful for this video, not just because such a video is available because of you, but also the time you took to explain everything seamlessly.

  • @NotPastelDreams
    @NotPastelDreams 3 ปีที่แล้ว

    This is the best video I ever watched. despite watching so many videos I lost my head on learning middleware but you have cleared all my doubts. I am your permanent sub now.

    • @zachgoll
      @zachgoll  3 ปีที่แล้ว

      Glad it was the video that clicked :)

  • @sidarjunful
    @sidarjunful 4 ปีที่แล้ว +1

    Wow excellent explanation of the topic. I have been scratching my head since last week. searching all over the internet to find a simple explanation of node. express and server, but explanations over the internet are filled with jargons that only experienced developers can understand. Keep sharing such type of excellent content, it means a lot for people like me. Liked and Subscribed.

  • @joeygarcia7826
    @joeygarcia7826 2 ปีที่แล้ว

    Great job! The one thing that I still haven't seen demonstrated in any of these Express middleware videos is content negotiation, something that can return an error too, such as a 406 or a 415.

  • @JohnCamden
    @JohnCamden 4 ปีที่แล้ว +1

    Very helpful. This whole series is great.

  • @JFarmsLivestock
    @JFarmsLivestock 2 ปีที่แล้ว

    This is perfect!
    I subscribed immediately after the first 5 minutes of this video. He explained everything in detail.
    Thanks for this great video.

  • @ukasz6770
    @ukasz6770 4 ปีที่แล้ว +1

    Wow! never thought I could understand this in one video. Definitely subscribing!

  • @kurtisivey7672
    @kurtisivey7672 2 ปีที่แล้ว

    This video is gold. Definitely came away knowing so much more about middleware. Thanks for explaining it so well.

  • @libertad83y
    @libertad83y 4 ปีที่แล้ว +2

    Amazing! It should be the first thing to understand and master, congrats Zach!

  • @mounirelbertouli9990
    @mounirelbertouli9990 3 ปีที่แล้ว

    Yeeaaah finally i get a great explanation about Express middleware , no boring ! Thanks a lot Mr.Zach

  • @haciendadad
    @haciendadad 2 ปีที่แล้ว

    WOW, Thank you Zach! I love seeing the new group of instructors, they are really good! I am a new subscriber now, I hope more people discover your channel! The only feedback I have, is I think your volume should be a little higher. I heard it fine, but I had to put up the volume to its highest level on the video itself and my laptop and it was perfect, but I was in a quiet room, other than that it was great. I am going to checkout the Passport videos next!

  • @BernardoGuerreiro-d8m
    @BernardoGuerreiro-d8m 9 หลายเดือนก่อน

    The error handling part was amazing. Thanksss

  • @thinksmartstudios
    @thinksmartstudios ปีที่แล้ว

    it was an wonderful explanation. I've been struggling all day today to understand this, you made it so simple. I could finally connect al lthe dots.Thankyou so much

  • @helmialfathseptiana6383
    @helmialfathseptiana6383 4 ปีที่แล้ว

    I wish u always keep sharing stuff like this, so fundamental, the series is gold ! thx

  • @luunguyenphat9399
    @luunguyenphat9399 3 ปีที่แล้ว

    You're doing a very good job. I have skimmed through your videos in this video's playlist, at first, I supposed that I already knew it, but your explanation makes me clearer understood. However, I have to increase the video play speed to 1.5x. Last word, thanks! :D

    • @zachgoll
      @zachgoll  3 ปีที่แล้ว

      Awesome! Glad you got some value in them. Can totally understand the 1.5x speed; I do that on most TH-cam programming tutorials too 😁

  • @mohammedfalih8713
    @mohammedfalih8713 3 ปีที่แล้ว

    man you are a phenomenal
    after tons of videos I've watched
    you explain the topic in 30 minutes and add on them the whole express framework
    keep up your great work. wish to you all the best ❤🤟

  • @johnnyboghean2242
    @johnnyboghean2242 3 ปีที่แล้ว

    Really great video! I have been using middleware already but after just simply watching this video I feel like I truly have an understanding of how they work.

  • @forexhoss9381
    @forexhoss9381 ปีที่แล้ว

    Damn thank you so much man. I just recently started learning about the backend of things, specifically I just started with Express.js and man, this definitely is a bit more difficult than I anticipated. The middleware concept had me initially so confused. But I just finished this entire video and saw your TH-cam Header Image, I definitely must say, after watching this video, this hard concept has FINALLY clicked 😄 Thank you so much man! Overall I think you delivered this extremely well. The general pace and simple examples with thorough explanations really add value.

  • @huckbit
    @huckbit 4 ปีที่แล้ว +1

    Magic! Thank you very much for this video Zach !!! Your channel is awesome. Thank you for all your videos.

  • @evilservo
    @evilservo 4 ปีที่แล้ว

    Awesome job, finally someone taught me the REAL basic to build my castle of express upon, THANKS A LOT, no mattter how much I thank you it will never be enough

  • @assortedpov
    @assortedpov 3 ปีที่แล้ว

    This was excellent, a very clear and understandable explanation. I'm in my 2nd year of a degree with 2/3 computer science classes. One of the classes I've been studying since October has had me writing and extending a couple (a bookshop which we extended fortnightly for 6 months and a nutritional app/recipe builder) of Node/Express apps which serve ejs templates and also serve as APIs for database operations (experimented with MongoDB & mySQL on different assignments). I've got good scores all year but haven't properly understood middleware until now.

    • @zachgoll
      @zachgoll  3 ปีที่แล้ว

      I can totally relate! Glad to see you’re taking the initiative to seek knowledge outside of the classroom-it really goes a long way!!

    • @assortedpov
      @assortedpov 3 ปีที่แล้ว

      ​@@zachgoll I came across your channel tying to figure out session management for another university project. I have a Vue app hosted on Heroku (served by an Express instance) and it uses an Express API I wrote for db (MySQL) operations, which is CORS configured to accept HTTP requests from the Vue app and is hosted on a virtual machine on my university departmental server. Hopefully I'll slowly figure it out from your Passport authentication series. These videos are great, thanks for the time you've clearly put into creating them

    • @zachgoll
      @zachgoll  3 ปีที่แล้ว

      In addition, I'd also keep an eye on my #fullstackroadmap series. I will be covering these topics over the next couple of weeks through building an E-Commerce app. Here's the playlist - th-cam.com/video/ZZJT5uskuvI/w-d-xo.html

    • @assortedpov
      @assortedpov 3 ปีที่แล้ว

      @@zachgoll Thanks, I expect I'll check those out at some point in future. Just had a quick look at what's in the playlist and by the time you get to session management, it might be too late for my purposes. But I reckon i'll figure it out from your Node/Passport auth series

  • @diegor5805
    @diegor5805 4 ปีที่แล้ว +1

    I really needed this video. It clears up so many questions!

  • @ytdevs
    @ytdevs 3 ปีที่แล้ว

    Yup, I'm in love lol thanks for series, it's a masterpiece. Appreciate you man

  • @hercules3484
    @hercules3484 4 ปีที่แล้ว +1

    Very much needed video. Thank you very much.

  • @ahmadza1836
    @ahmadza1836 4 ปีที่แล้ว +2

    A very brain friendly explanation, keep up the good work

  • @flowerofash4439
    @flowerofash4439 2 ปีที่แล้ว

    this tutorial is sooo goood
    detailed, easy to understand
    and generous

  • @antonyrichard369
    @antonyrichard369 3 ปีที่แล้ว

    Superb .. I know what is middleware earlier .. they are good as well .. but yours is deep .. loved it

  • @CoryTheSimmons
    @CoryTheSimmons 4 ปีที่แล้ว +2

    This is a great series Zach. Thank you so much for the effort! It's really high quality and useful. =)

  • @kalaiselvan7352
    @kalaiselvan7352 3 ปีที่แล้ว

    Simple as that. loved the explanation and going to watch remaining parts instead of a course which I actually bought. Thanks man.

  • @takshpatel8109
    @takshpatel8109 2 ปีที่แล้ว

    Best Video on Middleware. Thank you so much for this video

  • @atharvsankpal
    @atharvsankpal 5 หลายเดือนก่อน

    Great, you provided timeless knowledge!!!

  • @code-of-duty
    @code-of-duty 4 ปีที่แล้ว +1

    Nicest thing i have ever seen for express

  • @amanaggarwal5884
    @amanaggarwal5884 3 ปีที่แล้ว

    The explanations are very very good and to the point. Loved it

  • @miraclesdohappen2352
    @miraclesdohappen2352 3 ปีที่แล้ว

    Myself using Node JS and Express pretty extensively but your video given a great insight specially on express middlewares, for sure this will help me to optimize my code..great work dude cheers and gud luck with your future videos once again great stuff:-)

  • @danyalahmed641
    @danyalahmed641 4 ปีที่แล้ว +2

    This guy really deserve to be noticed by "so called" developer community on TH-cam

  • @TakshvysDad
    @TakshvysDad 4 ปีที่แล้ว

    So much detailed explanation . Blessed to come across your tutorial. Great job. Please keep posting like this. You are going to take over the express tutorial.

  • @kidschannel2473
    @kidschannel2473 4 ปีที่แล้ว

    This is nothing but best, who tf will even dislike this video?

  • @aghahasaan
    @aghahasaan 4 ปีที่แล้ว

    Thank you so much, I was so confused until today that I switched to long polling for my chat app just cause I didn't really get the real flowcharts although my socket io application is working just fine.. this is the best tutorial on this topic and explains everything that is required, others use too many middlewares or middlewares along with templating engines and other cool technologies..

  • @farlight6044
    @farlight6044 4 ปีที่แล้ว +1

    Great video
    It's very clear and informative
    Thanks!

  • @MasterTeeee
    @MasterTeeee 2 ปีที่แล้ว +3

    Something that's really important, and that you didn't mention in this tutorial, is that next() is like a recursive function call, in that it also `unwraps` (unless a later middleware `return`s before it gets a chance to)... What I mean by that is, any code you have that's placed AFTER the next() statement will be run once the last middleware has been reached.
    Pseudo code example:
    middleware1
    log(1)
    next()
    log(2)
    middleware2
    log(3)
    Would result in:
    1
    3
    2
    Being logged.

    • @zachgoll
      @zachgoll  2 ปีที่แล้ว

      Yep that’s a great one! Definitely have to be careful with that, I generally throw a return statement before calling next() if there’s code that comes after it that I don’t want to run

  • @lorocongarrote
    @lorocongarrote 4 ปีที่แล้ว

    unrated tutorials, no way this is a free course, thanks!

  • @sreeni3037
    @sreeni3037 3 ปีที่แล้ว

    Simply Superb Zach. Very clear explanation. Just Subscribed.

  • @NimTaoWingChun
    @NimTaoWingChun 3 ปีที่แล้ว

    Absolutely brilliant. You are a great teacher, very clear and easy to understand. Keep it up.

  • @TakshvysDad
    @TakshvysDad 4 ปีที่แล้ว

    So much detailed explaining . Blessed to come across your tutorial. Great job. Please keep posting like this.

  • @nanda_8
    @nanda_8 3 ปีที่แล้ว

    Loved this!!!
    Underrated video for sure

  • @divaynagar1929
    @divaynagar1929 2 ปีที่แล้ว

    Very concise and to the point video !!! Great one ...

  • @donaldjr.labajo5687
    @donaldjr.labajo5687 3 ปีที่แล้ว

    This sir, is by far the best explanation I have ever seen since I started learning programming. Thank you x3000!

  • @arkhamian7586
    @arkhamian7586 3 ปีที่แล้ว

    One of the best explanations out there. Thank you for doing this!

  • @amancode7013
    @amancode7013 3 ปีที่แล้ว

    you got a talent for explaining, keep it up brodie

  • @digvijayyamagekar7139
    @digvijayyamagekar7139 3 ปีที่แล้ว

    Lord zach gollwitzer, thank you very much for this clear explanation, ✌️✌️

  • @TheDJARCHY
    @TheDJARCHY 4 ปีที่แล้ว +1

    This is so great... Can you do a part 2 about testing those middlewares??

    • @zachgoll
      @zachgoll  4 ปีที่แล้ว +2

      Like unit testing?

  • @imarpit007
    @imarpit007 4 ปีที่แล้ว +1

    Very nice tutorial. A lot of things to learn and this video will definitely help you.

  • @junaidrehman429
    @junaidrehman429 2 ปีที่แล้ว

    Great Video. I would be thrilled if you come up with a video of CRUD using MERN and clean architecture.

  • @stephane777777
    @stephane777777 ปีที่แล้ว

    Really good. This is what I was looking for. many thanks Zach

  • @kaan1780
    @kaan1780 3 ปีที่แล้ว

    Fantastic explanation! Now I have a much better understanding when it comes to what happens when I app.use() libraries like bodyParser, Helmet, Cors and so on...

  • @9gager87
    @9gager87 4 ปีที่แล้ว +1

    Great video, thank you so much! Keep making these videos!

  • @johnyanastacio1107
    @johnyanastacio1107 4 ปีที่แล้ว +1

    Thank you brother, this series is helping me so much...

  • @pratikdas9138
    @pratikdas9138 2 ปีที่แล้ว

    you are best ,,, you have explained all basic in one video thanks

  • @boopfer387
    @boopfer387 ปีที่แล้ว

    excellent one of the best if not the best! Thank you Zach!

  • @iben1195
    @iben1195 4 ปีที่แล้ว +1

    I feel like an express guru right now 🤗

  • @jamilkabir3168
    @jamilkabir3168 4 ปีที่แล้ว

    You’re so good at explaining! Please keep making videos. Thanks!

  • @michelbouchet3605
    @michelbouchet3605 4 ปีที่แล้ว +1

    That's a very nice tutorial. Thank you!

  • @rajashekhar433
    @rajashekhar433 4 ปีที่แล้ว +1

    Thanks for the video 😊

  • @darkapopovich6331
    @darkapopovich6331 3 ปีที่แล้ว

    This is super clear and useful, thank you!

  • @monkeystylle
    @monkeystylle 4 ปีที่แล้ว

    thank you, this makes me understand express a lot better..

  • @sayonarasun1577
    @sayonarasun1577 4 ปีที่แล้ว +1

    great explanation. thanks a lot mate!

  • @deepaktdk3637
    @deepaktdk3637 ปีที่แล้ว

    Great explanation.Much needed.

  • @jacksonjk12345
    @jacksonjk12345 ปีที่แล้ว

    Excellent explanation. Very helpful❤

  • @mahmoudhashim3720
    @mahmoudhashim3720 หลายเดือนก่อน

    Woow, thank you.
    U make it so Easy!!!! Big love & thanks.

  • @valikonen
    @valikonen 3 ปีที่แล้ว +1

    Amazing tutorial, thanks and I hope to get more like this about Node. Maybe how to use node with typescript or how to use i18n and so on :)

    • @zachgoll
      @zachgoll  3 ปีที่แล้ว +1

      I’m making a full stack web dev series as we speak! More Node tutorials coming your way soon 😎

  • @kimjiyoung8655
    @kimjiyoung8655 2 ปีที่แล้ว

    Zach! Super thanx from Denmark, it helps so much!! ;

  • @ecofriend93
    @ecofriend93 4 ปีที่แล้ว +1

    This is great! Thanks a bunch!

  • @bertt1055
    @bertt1055 3 ปีที่แล้ว

    Best best best tutorial on req res next cycle

  • @ys4105
    @ys4105 2 หลายเดือนก่อน

    Great explaination! Thanks!😁🤝👍

  • @kavin-nivak
    @kavin-nivak ปีที่แล้ว

    Thank you for making this bro❣️❣️

  • @kchemutai3483
    @kchemutai3483 ปีที่แล้ว

    Thanks so much for this awesome explanation Zach. This helped me alot

  • @atheermohmed7802
    @atheermohmed7802 3 ปีที่แล้ว

    OMG I felt like I will never understand it, thank you so much