Butbeforewegetstarted, ifyouenjoyreadinginsteadofwatching, I haveanentirebogarticlethatgoesovermiddle, whereindepthwouldyoucancheckoutaswellifyouwantto I'llhavethatlinkeddowninthedescriptionbelow.
Sogettingstartedwithmiddle, where I wanttotalkaboutthemostbasicformofmiddlewareandexactlywhatmiddlewhereisbecauseyoumaynotbefamiliarwiththeexactdefinitionofmiddleware.
Essentiallyallthatmiddlewhereis, isitis a functionorprogramorsomethingthatisgoingtorunbetweenthetimethattheservergetstherequestandthetimethattheserversendstherequestouttotheclient.
Sowhen I clickrefreshhere, I'm sending a requesttotheserverandthatgetstotheserverandthisappdotgetprocessesit.
Andmiddle, whereisanythingthathappensbetweenthetimetheservergetstherequestandthetimethattheserversendsout a response.
Soindefinition, thisfunctionrighthereforourappdotgetusersisactually a middlewhere, becauseit's happeninginbetweenthegettingoftheresponseandthesendingoftheresponseandthatissomethingreallyimportanttounderstandWithexpressisthateverysinglethingyouwriteinrelationtoactionssuch a zapdotgetforthesedifferentactionsisgoingtobemiddle, wherewhenyouhaveyourrequestandresponsevariable, thatis a middlewherethatyou'rewritingthatisgoingtobeactinginbetweentheresponsesendingandgetting.
Themostimportanttakeawayfromthisvideo, though, isthatmiddle, whereisessentiallyjust a functionwhichtakes a request, a responseand a next, anditwillcallnextwheneveritwantstomoveontothenextformofmiddleware.