nestjsåeggjsåªä¸ªå¥½ï¼
nestjs为ä»ä¹ä¸ç«
å 为æä½ä¸ç®ä¾¿
Nest.jsæ¯ç¨äºæ建é«æä¸å¯ä¼¸ç¼©çæå¡ç«¯åºç¨ç¨åºçæ¸è¿å¼Node.jsæ¡æ¶ãæ¯æTypescriptãé¢åAOPç¼ç¨ãæ¯ætypeormãNode.jsççspringãæ建微æå¡åºç¨ã
Nest.jsæ¯ç¨äºæ建é«æä¸å¯ä¼¸ç¼©çæå¡ç«¯åºç¨ç¨åºçæ¸è¿å¼Node.jsæ¡æ¶ãæ¯æTypescriptãé¢åAOPç¼ç¨ãæ¯ætypeormãNode.jsççspringãæ建微æå¡åºç¨ã
å¹´å端æç«çææ¯æ¯ä»ä¹ï¼
æ认为çå¹´å端å¼åè æåºè¯¥ææ¡çä¸äºæ¯è¾ç«ççææ¯ä¸ç¥è¯ç¹ã
1ï¼å端æ¡æ¶åè¯è¨å±é¢
9æ份Vue3.0åå¸ï¼å£°ç§°å¯¹TypeScriptæçæ´å¥½çå¼åä½éªï¼éè¿ä»ä¸åæ¡æ¶çº§å«TSæ¯æä¸ï¼æ们å¯ä»¥çåºç¤¾åºçæ´ä¸ªé£åä»å¹´ç大家é½å»å¦ä¹ åºç¨TSï¼åæäºå¤§å®¶å¦ä½æTSç¨çæ´å¥½è¿ä¸ªæ¹åä¸æ¥äºã
æ以æ认为ä»å¹´TypeScriptçç«çç¨åº¦è¿æ¯åºè¯¥æåå¾é åçï¼æä»å¹´ä¹ä½¿ç¨TypeScriptéæäºDarukçæå¡æ¡æ¶æ¨åºäº2.0çæ¬ï¼è®©TSå¼åè æ¥ææ´å¥½çTSå¼åä½éªã
æ¥ä¸æ¥å°±æ¯ä¸¤å¤§éç£ æ¡æ¶çæ´æ°åç¨å¯¹æ¯ï¼Vue3åé¢è¯´äºä¸å¥ãèReactä¹å¨åæä¹åå¸äºReactçreleaseçæ¬ãè¿ä¸¤å¤§ä¸»æµæ¡æ¶çé¢ç¹æ´æ°ï¼ä¹è¯´æäºç¤¾åºåä½è é½å¨ä¸åæ¼åã
å¨Vue3ä¸é¤äºæ´å¥½çæ¯æTSå¤ï¼è¿æ´æ°äºCompositionAPIãèReact主è¦æ¯éä¸ç²¾åå¨å级ä½éªä¸ï¼è½ç¶æ²¡ææ°çFeatureä½æ¯æåäºå解å³äºå¾å¤ä¹åçæ¬æ½å¨çé®é¢ã
è¦è¯´åªä¸ªæç«è¿æ¯è¦ç个人å®é ç使ç¨åºæ¯åå好ï¼ä½æ¯å¹´æ¥çè¿æ²¡æå«çæ¡æ¶å¯ä»¥ä¸ä¹ä¸æã
2ï¼å¤§å端ç¸å ³ææ¯æ
ä»å¹´åºäºChromiumç微软edgeæµè§å¨ä¹å·²ç»æ¨åºãgoogleå¨web端çåå±äº§çäºå¯¹å¼åè æ·±å»çå½±åãChrome+ä¹å·²ç»åå¸å¤ä¸ªçæ¬ï¼æä¾äºä¸ç³»åçæ°ç¹æ§ï¼æ¯å¦CoreWebVitalsæ åï¼DesktopPWAçé½å¼å¾æ们å»å ³æ³¨ã
æ们说å®äºæµè§å¨ç¸å ³çé£ç¹ææ¯ä¹åï¼åèè大å端ç¸å ³çä¸äºææ¯å®è·µï¼æ¯å¦Flutterã
å¾å¤å端å¨ä»å¹´å·²ç»ä»webå¼å转å为Flutterå¼åï¼å¦ä¹ å使ç¨Dartææ¯æ¥æ建UIï¼è¿æ¯å¾å¤å¤§åçå端工ç¨å¸æ£å¨ç»åçäºæ ï¼å æ¬æçé¨é¨ä¹å¨å°è¯è¿ä¸ªäºæ ï¼ï¼è¿ä¸ªè¶å¿åºè¯¥å¨æªæ¥å å¹´è¿ä¼æç»ã
客æ·ç«¯electronå¨ä»å¹´ä¹æçé¿è¶³çè¿å±ï¼ä¸å¹´å å¤æ¬¡æ´æ°çæ¬ä¸è·¯å°äº.1.5ãéçç«æ å½±åï¼å½å å¨çº¿æè²çåä¸æ³¢å ´èµ·ãå¾å¤æ¡é¢è½¯ä»¶ï¼ç½è¯¾è½¯ä»¶é½å¨éç¨è¿ä¸ªææ¯æ¥è¿è¡å¼åï¼å¸åºä¸çå²ä½ä¹å¼å§åå¤ï¼electronææ¯å¯ä»¥è¯´å¨ä»å¹´ä¹æç«çè¶å¿ã
ç¶åæ们åççBFFå±ï¼nestjsä¾ç¶åæºï¼è¶æ¥è¶å¤ç人å¼å§è·³è¿å¦ä¹ expressåkoaå¼å§å¦ä¹ æ´ä¸°å¯çwebæ¡æ¶äºï¼æ¯å¦eggæè æçdarukï¼å¼åè å·²ç»å¨æ ¢æ ¢å½¢æå ±è¯ï¼å¨webframeworkçè·¯ä¸å¼å§è¶èµ°è¶è¿ï¼è£¸ånodejswebæå¡çæ¶ä»£å·²ç»å¼å§æ ¢æ ¢è¤ªå»ã
ä¸å¾ä¸æçè¿æserverlesså¨å端çæ®åï¼å¨å¹´å°è¾¾äºä¸ä¸ªæ°çé«æ½®ãé¿éäºï¼è ¾è®¯äºï¼å¤´æ¡äºççå½å çäºèç½ååä¹é½å¼å§å¤§ç©serverlessæ¦å¿µãä»å¯¹å æå¡å¼å§è½¬å对å¤æå¡ï¼æ®åçå¿å¤´å¾çï¼ä¹æè½å°çè¶å¿ååºæ¯ãä»å¹´çD2åæ ·ä¹æserverlessçä¸åºï¼å¯è§åéè§ç¨åº¦éæ¯å¯»å¸¸ã
3ï¼å·¥ç¨åææåä¸ªäººç´ è´¨æå
å离æ们è¿ä¸äºçæ¨å¨ç产åçææ¯ï¼æ¯å¦æ®ææç¥å¨ç¨CI/CDåpipeline管çä¸çº¿æµç¨çå ¬å¸è¶æ¥è¶å¤ï¼è¿ç§å»å¹´è¿å¯ä»¥åºå»å¹ä¸å¹çä¸è¥¿ï¼ä»å¹´ä¹éæ¥åæäºä¸çæ é åºç¡è½åï¼å¦æä¸ä¼çåå¦å¯è¦æç´§å¦ä¹ äºã
å¹´å大家é½ç¯çå槽é¢è¯å·mediumé¢ç®æ²¡ç¨ï¼èå¹´å大家å¼å§é»è®¤é¢è¯æäºå ¬å¸é½è³å°è¦å·å°mediumç¨åº¦çé¢ç®ãè¿å¯¹å¾å¤å端æ¥è¯´æ¯ä¸ä¸ªå¿æºåç´ è´¨çæåä¸è½¬åï¼å¤§å®¶å¨æ¥è§¦æ°ææ¯çåæ¶ï¼ä¹æ ¢æ ¢åç°ï¼å端æ´ä¸ªèä¸ç¯å¢çååï¼è¶æ¥è¶å¤çå ¬å¸å¯¹äººçæ´ä½ç»¼åç´ è´¨è¦æ±åé«äºã
eggjs为ä»ä¹å£ç¢ä¸å¥½è´¨éé®é¢ãeggjs为ä»ä¹å£ç¢ä¸å¥½çåå æ¯è´¨éé®é¢ï¼å 为eggjsè´¨éå·®ï¼å®ä»·é«ãå£ç¢ï¼æä¼äººå£å¤´çé¢æ¬ï¼æ³æä¼äººç议论ï¼ç¾¤ä¼çå£å¤´ä¼ 说ï¼ç¸å½äºä¸ç§å¤§ä¼å´è¾¹ç»å¸¸æèµ·çäºæ æç»ç»ã
NGå ¨å®¶æ¡¶å ¨æ 项ç®å®è·µæ»ç»Angularå¨å½å 使ç¨ç人并ä¸åå½å¤é£ä¹å¤ï¼åºæ¬é½æ¯å¤ä¼å¨ç¨ï¼ä½å ¶æ¡æ¶çææ³å´ä»å¯ä»¥ä¸ºæ们æåé´ï¼å¨æäºé®é¢æ²¡ææè·¯çæ¶åå¯ä»¥åèngç¸å ³çå¤çï¼ngå¤çæ¹å¼åæç»´ç¡®å®æ¯è¾è¶ åï¼ä½ä¹å æ¤èæ²é«å寡ãæ¬ææ¨å¨éè¿ngå ¨å®¶æ¡¶é¡¹ç®ï¼å端Angular+å端NestJS7ï¼çå®è·µæ¥æ»ç»å¯¹äºngæ¶æä¸ä¸äºäº®ç¹çå ³æ³¨ä¸æèï¼AngularåNestå¨åå端æ¡æ¶çå¤çä¸ååºä¸èï¼å¯¹æ¯èµ·æ¥æ´æåé´æä¹ã
[ç®å½ç»æ]
[ç®å½æè¿°]
æ´ä¸ªå端项ç®æ¯åºäºangularèææ¶çæçï¼å ¶åºæ¬ç®å½ç»ææ¯å¨srcçappä¸è¿è¡ç¸å ³ç»ä»¶å页é¢ç模åå¼åï¼main.tsåindex.htmlæ¯æ´ä¸ªå页åºç¨çä¸»å ¥å£ï¼æ ¹ç®å½ä¸angular.jsonç¨äºé ç½®ç¸å ³çæå ç¼è¯çç¯å¢é ç½®åæ°
[å®è·µå享]
[ç®å½ç»æ]
[ç®å½æè¿°]
å端项ç®æ¯åºäºnestjsæ¡æ¶ç大ååå°é¡¹ç®é ç½®ï¼api模å主è¦æ¯å¯¹å¤è¾åºçæ¥å£ï¼authãfiltersãguardãinterceptorsãmiddlewaresãpipesçæ¯å¯¹äºéè¦ç模åè¿è¡ç»ä¸çæ¶éå¤çï¼main.tsæ¯ä¸»å ¥å£æ件ï¼ç¨äºå¯å¨åç¸å ³é ç½®çï¼app.module.tsæ¯ç¨æ¥æ¶éææ模åçå¯¼å ¥ï¼ngåºäºæ¨¡åçæ¹å¼å¯ä»¥èµ·å°é常好çé离ææ
[å®è·µå享]
é¦å ï¼å¯¹äºæ²¡æç¨è¿ngçåå¦ç§æ®ä¸ä¸ï¼angularå ¶å®å为两个大çæ¬ï¼ä¸ä¸ªæ¯angular1.xçï¼ä¹å°±æ¯ng1ï¼ä¹å°±æ¯ç°å¨è¿æçangularjsï¼å¦ä¸ä¸ªçæ¬æ¯ng2以åççæ¬ï¼ng2ä¹å被谷ææ¶è´åï¼å®å ¨éåäºæ¡æ¶ï¼å¯ä¸å1.xç¸éç估计ä¹å°±å©é£å 个ææ³è¿å¨äºï¼æ¨¡ååãä¾èµæ³¨å ¥ãååç»å®ãMVCï¼å¯¹äº1.xæå ´è¶£çåå¦å¯ä»¥å»çVueç1.xççæ¬ï¼åºæ¬ç®æ¯ç®åççng1.xï¼Vue2ä¹åå°±ååæ¥çngåéæ¬é³äºï¼vue2主è¦æ¯ä»¥åå¸è®¢é æ¥æ¿ä»£ä¾èµæ³¨å ¥çæè·¯ï¼æ¯è¿äº...(ps:æ³çng1çæ¬çå¯ä»¥çè¿ä¸ªå°åï¼å± ç¶è¿ææ´æ°...angularjså®æ¹ä»åº)ï¼è¿éåæç主è¦æ¯Ngï¼ng8ä¹åé¤äºå¼å ¥Ivy(Ivyæ¶æå®æ¹ä»ç»)è¿ä¸ªç¼è¯æ¸²æå¨ä¹å¤ï¼å ¶å®æ¹å¨ä¸å¤§ï¼ä¸»è¦å°±æ¯å¨ä¼å以ååºé¤åæ°å»ºä¸äºapiççãNgçæºç å¾åºå¤§ï¼goggleèªç äºä¸ä¸ªbazelèªå¨åæå»ºå·¥å ·ï¼ngèªç¶ä¹æ¯é è¿ä¸ªæ建çï¼å¯¹bazelæå ´è¶£çåå¦ï¼å¯ä»¥çè¿ä¸ªGoogle软件æå»ºå·¥å ·Bazelåçå使ç¨æ¹æ³ä»ç»ï¼æè¿éå°±ä¸å±å¼ææçæºç ï¼æ´ä½çæ ¸å¿å¤§æ¡æ¶å¦ä¸ï¼
nestjsæ¯nodejsçwebåºç¨çä¸ä¸ªå¤§çéæï¼å®æåæ¯åºäºexpresså°è£ çä¸ä¸ªå端æ¡æ¶ï¼åæ¥å°æå¡ç«¯åç§ç念é½ä½¿ç¨jså®ç°äºä¸ä¸ï¼è½ç¶ä¸è½åæççæå¡ç«¯è¯è¨æ¡æ¶å¦javaçè¿è¡åª²ç¾ï¼ä½æ¯æå¡ç«¯æéè¦çä¸è¥¿åºæ¬é½å ·å¤äºï¼å¯¹äºæéæ±æ³è¦ä½¿ç¨jsæ¥å¼åå端çåå¦æ¯ä¸ªä¸éçéæ©ï¼ä¸ªäººè®¤ä¸ºç®åçbffï¼æ¯å¦æ³èªå·±æ¨¡æçå¼å个åå°æ¥æ¶è¯·æ±ï¼éæ©nodeç´æ¥åæè 使ç¨expressãkoaå°±å¯ä»¥ï¼å¯¹äºæä¸å®çä¸é´å±ç»å端å¤çï¼å¯ä»¥éç¨é¿éçeggï¼å¯¹äºå¦ä½åºäºeggæ建ä¸é´å±ï¼å¯ä»¥ççè¿ç¯æç« å¦ä½ä¸ºå¢éå®å¶èªå·±çNode.jsæ¡æ¶ï¼ï¼åºäºEggJSï¼ï¼å¯¹äºå¤§åçæå¡ç«¯ï¼å°¤å ¶æ¯å端æ¯ä»¥ng为主æ çï¼å¯ä»¥ä¼å èè使ç¨nestjsï¼å ¶æ¬¡å¯¹äºioè¾å¤è计ç®è¾å°çï¼jsæ¬èº«çç¹è´¨ï¼ï¼æè æå¡ç«¯éè¦ä¸c++é åçï¼å¤§åæå¡ç«¯åºç¨ä¹å¯ä»¥ä½¿ç¨nestãnesté»è®¤æ¯ä¸éç¨å¾®æå¡çå½¢å¼çï¼nestå°ä¸åçå¹³å°å°å¨äºä¸åçplatformä¸ï¼è¿éåªåææ®éç以express为platformçå½¢å¼ï¼å¯¹äºå欢微æå¡çåå¦ï¼å¯ä»¥å¯¹æ¯åjavaçspringcloudçåºå«ï¼è¿éå°±ä¸å表述äºï¼å ¶æ´ä½çæ ¸å¿ç»æ大è´å¦ä¸ï¼
è¿é主è¦å¨å¯¹ä¾èµæ³¨å ¥çå®ç°åä¸ä¸ªç®åçç解å享ï¼å ¶æè·¯æ¯ä¸èç¸æ¿çï¼å¯¹äºç解å端ç念çä¾èµæ³¨å ¥æå¾å¥½çç解ï¼è¿ä¹æ£æ¯å端å端åçä¸ä¸ªä½ç°ï¼ä¹æ¯ææ©çMVCæ¡æ¶ååæ¥çMVVMæ¡æ¶è¿åº¦çä¸ä¸ªåå²è¿ç¨ï¼ä¾èµæ³¨å ¥æ¹å¼å¯¹äºææ©çå端æ¡æ¶è¿æ¯æ纪念æä¹çï¼ä½æ¯å¯¹äºngå ¨å®¶æ¡¶æ¥è¯´ï¼è¿ç®æ¯å ¶åºæ¬å²å¦çä¸ä¸ªåºæ¬é¢
bAngular/b
å æ¥çä¸ä¸ngæ¯å¦ä½å®ç°injectorçï¼è¿ééç¹å¨äºä½¿ç¨äºæ½è±¡ç±»æ¥éè½½ä¸åå½æ°ç使ç¨ï¼å¯¹äºprovider循ç¯ä¾èµçå¤çï¼å©ç¨äºä¸ä¸ªMapæ°æ®ç»ææ¥åºåä¸åçProvider
bNest/b
åæ¥çä¸ä¸ï¼nestçå®ç°ï¼ä¸åäºngçå®ç°ï¼nestæ¯å©ç¨åæ°å继æ¿ç¶ç±»åæ°æ¥ç¡®å®æ´ä¸ªç循ç¯ä¾èµå ³ç³»çï¼å ¶æ²¡æ使ç¨éè½½æ¥å®ç°ï¼ä½é½å¯¹å¾ªç¯ä¾èµåäºå¤çï¼å ¶åºæ¬æè·¯æ¯ä¸è´çã
æ»ç»ï¼ä»nestång对injectorçå®ç°å¯ä»¥çåºï¼è½ç¶é½æ¯æ³¨å°å¨çå®ç°ï¼ä½æ¯ç±äºåç°æ¹å¼çä¸åï¼å èå¨å®ç°æ¹å¼ä¸ä¹ä¼ææä¸åï¼å¯¹äºtsèè¨ï¼éç¨interfaceè¿æ¯æ½è±¡ç±»ï¼ç¡®å®å¯ä»¥åé´javaç模å¼æè·¯ï¼å¯¹äºä¹ æ¯jsçæ们æ¥è¯´ï¼å¯¹äºæ´ä¸ªæ°æ®ç±»åçæ©å±ï¼å¦ï¼æ½è±¡ç±»ãæ¥å£ï¼çæ¯éè¦åå端åé´çãæ´ä½æ¥è¯´ï¼å¯¹äºä¾èµæ³¨å ¥çå®ç°æå ³é®çå°±æ¯å¨äºå¤çproviderçæ´ä¸ªä¾èµé®é¢ï¼è¿ä¸¤è é½æ¯éç¨tokençæ¹å¼æ¥åºåå¯¹å¾ å°åºæ¯å±äºåªä¸ä¸ªproviderï¼ç¶å对äºç¹æ®çç¸å ³ä¾èµå¾ªç¯çé®é¢å对åºçå¤ç
ngæ´ä¸ªçæä½ç³»å¨å½å åºç¨ç并ä¸å¹¿ï¼ä½å¹¶ä¸å¦¨ç¢å ¶ä½ä¸ºå端ç念çæ©å±å è¡è çè¿æ ·ä¸ä¸ªè§è²ï¼ä¸ªäººè®¤ä¸ºå ¶å¨é离æ§ä»¥åç³»ç»æ§æ¹é¢é½æ¯è¦ä¼äºvueåreactçï¼å è对äºç®åæ¯è¾æµè¡çå¾®å端æ¡æ¶(ps:对äºngçå¾®å端åºç¨ï¼å¯ä»¥åèè¿ç¯æç« ã第æã使ç¨Angularæé å¾®å端æ¶æçToBä¼ä¸çº§åºç¨)ï¼ä¸ªäººè§å¾å¨æ²ç®±é离çç³»ç»èåæ¹é¢ç¡®å®å¯ä»¥åé´ä¸ä¸ngçæäºæè·¯ï¼æ许æ£æ¯ç±äºè¿ä¸ªåå ï¼å®ææ¯ä¸å¤§æ¡æ¶ä¸æå ä¸tsçï¼ä¹æå¯è½æ´ä¸ªngçå¼åè æ´åæ¯ä¼ ç»ç软件工ç¨å¸ï¼å¯¹äºæ´ä¸ªå¼åè¦åå°å®ä¹æ°æ®ãå®ä¹æ¨¡åãç³»ç»è®¾è®¡ççï¼å¯¹äºå¤§å项ç®èè¨ï¼è¿æ ·ç¡®å®ä¼åå°å¾å¤å bugèéè¦éå¤ä¿®æ¹çæ¶é´ï¼ä½æ¯å¯¹äºå°å项ç®ï¼ä¸ªäººè®¤ä¸ºè¿æ¯vueæ´åéãè½ç¶å¯¹äºå½å ï¼ngåºæ¬å·²ç»å±äºææ¥é»è±äºï¼ä½æ¯å®çä¸äºç念å设计æ路确å®è¿æ¯å¼å¾åé´çï¼å¨è¿ä¸ªå å·çæ¶ä»£ï¼å大åºç¨é½å¨åçé«çº§åã大åååå±ï¼è¯´ä¸å®åªå¤©ngåå¨å½å éåå· å³°äºå¢ï¼è½ç¶å¾é¾~~åååï¼åä½å æ²¹ï¼
å大éé¸è®¾è®¡å¹è®ï¼nodeç¼ç¨å¼åææ¯çåå±è¶å¿ï¼nodeææ¯æ为webå端é¢åç主æµå¼åå·¥å ·å¯ä»¥è¯´æ¬èº«å°±æ¯ä¸ä¸ªç¾ä¸½ç误ä¼ï¼å½åè¿ä¸ªææ¯è¢«å¼ååºæ¥ä½¿ç¨çæ¶å主è¦æ¯ä¸ºäºè§£å³å端çé®é¢æåºç°çã
ä»å¤©ï¼æµåjava课ç¨å¹è®æºæå°±ä¸èµ·æ¥äºè§£ä¸ä¸nodeææ¯çåå±åç¨åæªæ¥çåå±è¶å¿ã
a)Node8è¿å ¥LTSæ¶ä»£Node.js大çååæ¯è¿å ¥Node8æ¶ä»£ï¼å®æ¯ä¸ä¸ªç¨³å®çé¿ææ¯æçæ¬(LTS)ï¼é¤äºæ§è½æåå¤ï¼è¿æ以ä¸å 个è¦ç¹ã
Async/Awaitæ¯æã
å ¶å®å¨Node.jsv7.6å°±å¯ä»¥éè¿flagæ¯æäºï¼å¨node8éç´æ¥è½å°ã
éè¿Asyncå½æ°å¯ä»¥æ´å¥½çè¿è¡å¼æ¥æµç¨æ§å¶ï¼è¿ç¦»CallbackHellã
å¨Asyncå½æ°éï¼ä½ å¯ä»¥éè¿awaitè°ç¨Promiseï¼ä»¥åéè¿coå 裹çgeneratorï¼å¯ä»¥è¯´ï¼ååæ¯å®ç¾çAsyncå½æ°ï¼ååä¹å®ç¾å ¼å®¹åç§éç代ç ï¼ç§°ä¸ºå¼æ¥ç»æ解å³æ¹æ¡ä¸ä¸ºè¿ã
ES6模åæ¯æã
éè¿vue/reactãwebpackãbabelåtypescriptçç«çåå±ï¼es6模åå¾å°äºå¹¿æ³æ®åååºç¨ï¼å¨Node.jsv8.5å¯ä»¥éè¿--experimental-modulesæ¥å¼å¯è¿ä¸ªä½éªçç¹æ§ã
å½ç¶ï¼ä½ æ³å¨Node.jsæ´æ©çæ¬é使ç¨ES6模åï¼å¯ä»¥éç¨@std/esm模åã
HTTP2æ¯æã
å¨Node.jsv8.8å°±å¼å§é»è®¤å¯ç¨äºï¼/
2024-12-22 22:24
2024-12-22 22:08
2024-12-22 21:33
2024-12-22 20:49
2024-12-22 19:51