M I Dash, dash, saveDash, Devandwewanttoinstallnodemon, Andwhatnodemonisgoingtoallowustodoistomakeourserverautomaticallyrefresheverysingletimewemakechanges.
DaJason, Youcanseeallofourdependencieshereandlet's justcreate a simplestartscript.
Sowe'regonnacallthisDevStartandthisisgoingtorunnodemonserverdotJsAndthisisgoingtostartup a filecalledserverdotJsusingnodemon, whichmeansit'llautorefreshforest.
Sowe'regonnauseprocessdot e n v dotportThisway, whenyoudeployyoursite, youcansettheportenvironmentvariableandusethat, butindevelopmentwe'renotgonnahavethatvariableset.
Andinordertogetpropersyntaxhighlightinginthis e Jsfile, whenwestartgoingforwardandusingactual E.
J s syntax, you'regonnawanttodownloadanextensionhere, whichiscalled E.
J s languageSupport.
Asyoucanseeatthetop, makesureyouhavethisinstalledandthatwillyouproperlygetthesyntaxhighlightinginsideofyour e Jsfile.
Let's justshrinkthatbackdown.
Soinsideofour e Jsfile, whatwecandoisactuallyputallofthecodeinsidehereforrenderingoutfirstthatformaswellasthetable, whichisgoingtocontainallofourdifferentresultsfortheshortUralswe'vealreadygenerated.
Sofirst I wanttojusthave a titlefor a page.
We'regonnausean H one.
I'm justgonnacallthisEuroshrinker.
Thenwe'regonnahaveourformwhichisgoingtohaveanactionwhichwe'regoingtohandlelaterand a methodBushinourcaseisgoingtobe a postmethod.
Andinsidethisform, weneedtohaveaninputwhichisgoingtohandleourfulleuroandthen a submitbutton.
Soit's create a labelwhichisgoingtobeforourfullgirlandwasgettingsomeheresay, fullgirl.
Andthenwe'realsoactuallyjustmakethateuroinstead, andthenwe'regoingtohaveaninput, andthisisgoingtobe a typeofeuro.
We'regonnagiveit a namehereoffulleuro, andwe'realsogoingtogiveitan I D.
Butthat's becausewehaven't setupthebackandforthNowbeforewegetontothebackend, let's actuallycreatethisshowfor a table, whichisgoingtocontainallofourdifferenteuroswhenwecreatethem.
Soit's createdtable, andinsidehere, wewannahave a header, andinsideofthatheadofwe'regonnahave a row, whichisjustgoingtohavethreedifferentthisforteaheadingsinsideofit.
Andthe 1st 1 isgonnabefarfull, Uriel.
Andthenwe'regonnahaveanotheronewhichisgoingtobefor a shorteurothatwegenerate.
Sothefirstthing I wanttodoisworkonstylingoutourform.
Butactually, beforewecouldgettostylingtheform, let's wrapeverythinginsideof a classcalledcontainer.
Andinthiscontainerisjust a bootstrapclass, whichallowsustohavenicepaddingandmarginsandeverythingbetweentheedgeofourpage.
Sowehavethatcontainer, puteverythinginsideofit, andifwesaverefresh, youseethatjustgivesus a littlebitofmarginandpatting, whichlooksprettygood.
Nowwecanmoveontostyleinourform.
Soit's at a classhere.
We'regonnause n y dashforthisisgonnaaddmarginontopandthebottom.
Soifwesaverefresh, youcanseeitjustspacedourformoutfromourtitleandourtable, andwe'realsogonnause a forminlinesowecanhaveourforminlinelikethiswhenwestartapplyingalloftherestofourbootstrapclasses.
Now, theveryfirstthingwe'regonnado, whichseems a littleweird, iswe'reactuallygonnahidethislabelandonlyallowittobereadbyscreenwriters.
Soifweapply a classherewhichisequal, that s ouronlythismeansthiswillbescreenreaderonly.
Thisjustallowsustonothavetoworryaboutanydeprecationwarnings, because, asyou'llsee, if I removethisand I save, youcanseethat I getthesedeprecationwarningsdownhere.
Andthat's becauseweareusing a certainversionofMongo, DeviandMongoose.
Butweneedsomewaytogenerate a shortversionoftheEarlbecauseourformonlyhasoneyourroyaltoenter.
Butweneedtoactuallygenerate a shorteurotouse.
Sotodothat, we'regonnausethelibrarycalledShort I D.
Solet's closeoutofhere.
Itwasgonnaend, p m.
I short I d.
Andthisis a librarythatisverysimple.
Allitdoesistocreate a uniqueshortidentifier.
Solet's importthatwesayshort, I d isequaltorequireof a short I d.
Andthishas a singlefunctioninsideofitthatwe'reworriedabout, whichisshort I d Johngenerate.
Andthisfunctionjustgenerates a short i d forus.
Soinordertousethatwithourshortcolumnherewecanactuallyspecifydefaultandwepassit a functionanddysfunctionisgoingtorunasthedefaultvalueforourshortcolumn, andwecanjustsayshort, I d dotgenerate.
Andsincethisdotgenerateis a function, thisisessentiallythesamethingaspassingit a valuelikethis.
WecangomodelsandshortyourOh, sonowwehaveourshortyouarebeingimportedandinourpostwecanactuallycreate a newone.
Sowhatwecansayisshortyour l dotcreteandallwewanttodoispassinthatfullvalue, whichisfull, andweknowwecangetourbodyvaluesbysamerequestthatbodyandthisisgoingtogiveusaccesstoourform.
Andifwecheckinour e Jsfile, wehave a namesetonthisoffullyouroh, sowewanttojustaccessthefullyour l propertyofourbody.
Andnow, ifwesave, wereabletoactuallycreate a newshort, you'reallhere.
Onethingtonote, though, isthisis a synchronousaction.
Itactuallyhappensinthebackground.
Andwewanttomakesurewewaituntilthisisfinishedexecutingsowecouldjustcreate a sinkfunctionwillmakethis a synchronous, andthenwe'lljustusetheOh, wait, heweren't heretosay, wewannawaitforthistofinishcreatingbeforewemoveon.
Andifyou'renotfamiliarwith a sinkOh, wait.
I haveanentirevideocoveringitinthecardsandthedescription.
Andthisisgoingtogetallofthegirlsinsteadofourshortyouroldtablesowecanjustsayshortgirlsisgoingtobeequalto a waitingthatfunctionmotors.
Makesurethatthisisan a sinkfunctionsothatwecanuse a waitandthenwecanpassthoseshortyourrollsdownintoourviewbyjustpassinglikethis, anobjectwithshortyourrollslikethis.
Sowe'regonnasayapdotgetandwe'regoingtodoisgetanythingthathas a valuehere.
Sowe'regonnacallthisshortyouare l soessentiallywhatthisissayingisgivemeanyroutethathasinformationdirectlyafterthefirstslash.
Sohere, directlyafterthefirstslash, wehavethistextandthisisgoingtobesavedin a parametercalledshortgirl.
Andthenwecoulddothesamething.
Requestresponse.
Andwhilewe'reatit, we'rejustgonnamakethisin a sinkfunctionaswell.
Andinsidehere, wecanuserequestthatprogramdot a shorteuroandthisisactuallygoingtobewhateverwepasshere, thisshorteuroinsideofourgirlupheresowecanjustactuallyuseshortURLourmodel.
Sowhenevertheshortpropertyequalsshorteuro, wewanttoactuallyfindthatmodelsowecansayourshortgirlisgoingtobeequalto a waitingthisfunction.
Andifwetake a quicklookatthis, what's happeningiswe'rejustcallingtofindonemethodonourdatabase, passingitinoursearchquery, whichisjustsayingwewanttofindwhicheveryonehasthisshort I d, whichispassedinfromoureuro.
Andthenwe'regoingtosaveittothisvariable.
Now, sometimespeoplearegonnapass a eurothatdoesn't exist.