javascript
nodejs_NodeJS历险记
nodejs
by Elliott McNary
埃利奧特·麥克納里(Elliott McNary)
NodeJS歷險(xiǎn)記 (Adventures in NodeJS)
I built an app a couple of weeks ago after going through FreeCodeCamp’s Front-End curriculum and wanted to write an update as I head into NodeJS-land. I was finally able to obtain my Front-End certificate, which I am very proud of, but the excitement quickly wore off once I jumped into the backend side of things.
在經(jīng)歷了FreeCodeCamp的前端課程之后,幾周前,我構(gòu)建了一個(gè)應(yīng)用程序,并想在進(jìn)入NodeJS領(lǐng)域時(shí)編寫一個(gè)更新。 我終于能夠獲得我的驕傲的前端證書,但是當(dāng)我跳入后端時(shí),興奮很快就消失了。
Learning NodeJS has been incredibly difficult so far. There’s no point in trying to sprinkle it with fairy dust. The move from the front-end of primarily using JQuery and some basic JS techniques, to the backend with plain ol’ Javascript and hundreds of callbacks showed me that I had no clue what I was doing.
到目前為止,學(xué)習(xí)NodeJS非常困難。 試圖撒上仙塵沒有任何意義。 從主要使用JQuery和一些基本JS技術(shù)的前端到使用普通Java腳本和數(shù)百個(gè)回調(diào)的后端,這向我表明我不知道自己在做什么。
NodeJS requires a fundamental understanding of Javascript. I definitely didn’t have that when I started trying to learn it. I had to go back to watching hours of YouTube videos explaining callbacks, the event loop, closures, scope, etc…
NodeJS需要對(duì)Java語(yǔ)言有基本的了解。 當(dāng)我開始嘗試學(xué)習(xí)它時(shí),我絕對(duì)沒有。 我不得不回頭看幾個(gè)小時(shí)的YouTube視頻,講解回調(diào),事件循環(huán),關(guān)閉,作用域等…
I started to get a fair amount of understanding, but would still get lost after tons of callbacks. I was using learnyounode and couldn’t even get past the first problem without looking for a solution.
我開始獲得相當(dāng)多的了解,但是在大量回調(diào)之后仍然會(huì)迷失。 我使用的是learningyounode,即使沒有尋找解決方案也無法解決第一個(gè)問題。
I started consuming an incredible amount of MEAN Stack tutorials to try and get the basic ideas of using Express for routing and Node. I built no less than 4 different To-Do apps, 2 reddit clones, 1 Twitter clone, and 2 chat apps, before I realized I wasn’t really absorbing what was going on. I definitely wasn’t mindlessly following instructions, but they assumed I knew too much about Javascript.
我開始使用大量的MEAN Stack教程,試圖獲得使用Express進(jìn)行路由和Node的基本思想。 在我意識(shí)到自己并沒有真正吸收正在發(fā)生的事情之前,我構(gòu)建了不少于4種不同的To-Do應(yīng)用,2個(gè)reddit克隆,1個(gè)Twitter克隆和2個(gè)聊天應(yīng)用。 我絕對(duì)不會(huì)盲目地遵循說明,但是他們認(rèn)為我對(duì)Java語(yǔ)言了解太多。
I started watching a series on TheNewBoston’s YouTube channel that really helped me get the fundamentals down. I was going to try and make another reddit clone, until I realized that I should learn with something I care about, the Soundcloud queue app I built.
我開始在TheNewBoston的YouTube頻道上觀看系列節(jié)目,這確實(shí)幫助我降低了基本面。 我打算嘗試制作另一個(gè)Reddit克隆,直到我意識(shí)到我應(yīng)該學(xué)習(xí)自己關(guān)心的東西,即我構(gòu)建的Soundcloud隊(duì)列應(yīng)用程序。
I stopped watching things and started reading through documentation. I followed getting started tutorials to try and understand the fundamentals a bit more.
我不再看東西,而是開始閱讀文檔。 我按照入門教程進(jìn)行操作,以嘗試進(jìn)一步了解基礎(chǔ)知識(shí)。
I’ve frequently talked about the feeling of getting something to “click” when programming, and this time I had the same feeling. It’s a time you’ll never forget because your adrenaline is pumping and you can see some light. When I was able to setup my first database with key-value pairs, have events push things to the database, and then send the JSON to a route that I made was incredible. It was late and I was fist pumping around my room like a lunatic.
我經(jīng)常談?wù)撛诰幊虝r(shí)讓某些東西“點(diǎn)擊”的感覺,而這次我有同樣的感覺。 這是一個(gè)您永遠(yuǎn)不會(huì)忘記的時(shí)刻,因?yàn)槟I上腺素不斷增加,您可以看到一些光線。 當(dāng)我能夠使用鍵值對(duì)設(shè)置我的第一個(gè)數(shù)據(jù)庫(kù)時(shí),讓事件將事件推送到數(shù)據(jù)庫(kù),然后將JSON發(fā)送到我創(chuàng)建的路由中是不可思議的。 已經(jīng)很晚了,我拳頭像瘋子一樣在房間里抽水。
From there I started to gain some confidence and kept pushing myself. I worked on finding, sorting, and incrementing my existing documents in MongoDB. I realized I wanted a live feed so I started looking into Socket.io.
從那開始,我開始獲得一些信心,并不斷地推動(dòng)自己。 我致力于在MongoDB中查找,排序和增加現(xiàn)有文檔。 我意識(shí)到我想要直播,所以我開始研究Socket.io。
I think the problem with the tutorials I was consuming before, was that I never really learned why I was doing things. I was always just doing them and not really thinking about it. It’s incredibly important to know why you’re doing what you’re doing.
我認(rèn)為我以前使用的教程的問題在于,我從來沒有真正了解過為什么要做事情。 我一直只是在做它們而沒有真正考慮它。 要知道為什么要做什么,這非常重要。
Instead of googling something that started with “How do I…”, I started searching for the why and trying to figure out what’s actually going on. My searches started to look more like “What is a refresh token in OAuth?” or “What does serialize and deserialize do in Passport.js?”.
我沒有去搜索以“我如何……”開頭的內(nèi)容,而是開始尋找原因并試圖弄清實(shí)際情況。 我的搜索開始看起來更像“什么是OAuth中的刷新令牌?” 或“在Passport.js中序列化和反序列化做什么?”。
When I made that switch I really started to learn.
當(dāng)我做出切換時(shí),我真的開始學(xué)習(xí)了。
It’s also very important to keep pushing yourself. If you have something that you want to make, build it. There is always a way to do something, it’s just up to you to figure out (unless of course it’s an API limitation or something…then you just need to get a bit hack-y :). If you don’t know how to authenticate users, try to learn. If you don’t know how to create an RESTful API, learn! It’ll take a ton of time, but once it clicks you’ll be ecstatic.
不斷自我推銷也很重要。 如果您有想要制作的東西,請(qǐng)構(gòu)建它。 總是有一種方法可以完成某件事,這取決于您自己決定(除非它是API限制之類的東西,否則……您只需要稍微加點(diǎn)子就可以了:)。 如果您不知道如何認(rèn)證用戶,請(qǐng)嘗試學(xué)習(xí)。 如果您不知道如何創(chuàng)建RESTful API,請(qǐng)學(xué)習(xí)! 這將花費(fèi)大量時(shí)間,但是一旦點(diǎn)擊,您就會(huì)欣喜若狂。
I was so in the zone last Sunday I was working until 5am when the Seahawks started playing here in Melbourne. It was a 14 hour coding-binge. I’ve really never had that much enjoyment and focus with anything before. It was a crazy feeling.
上周日,我一直在該區(qū)域工作,直到海鷹隊(duì)在墨爾本開始比賽的凌晨5點(diǎn)為止。 這是一個(gè)14個(gè)小時(shí)的編碼過程。 我以前從未真正享受過如此多的樂趣和關(guān)注。 這是一種瘋狂的感覺。
I’ve finally figured out (well sort of) how to deploy this with Heroku and it’s live. There is now a feed showing the songs that are being queued on the site, as well as a live artist feed in the top right showing the artists being searched now across the site. I have also implemented a Top 10 ranking for the Top 10 songs queued all time (well, since launching the feature).
我終于弄清楚了(如何進(jìn)行)如何在Heroku中部署它,并且它是實(shí)時(shí)的。 現(xiàn)在有一個(gè)提要,顯示正在網(wǎng)站上排隊(duì)的歌曲,右上角還有一個(gè)現(xiàn)場(chǎng)藝術(shù)家提要,顯示了現(xiàn)在正在站點(diǎn)上搜索的藝術(shù)家。 我還為所有一直排隊(duì)的前10首歌曲實(shí)現(xiàn)了前10名的排名(自啟動(dòng)此功能以來)。
The Random 20 is still there for all of those who use it to find new music. And thanks to a suggestion on my last post, I’ve enabled users to log in with their SoundCloud accounts and like songs.
對(duì)于所有使用它來查找新音樂的人來說,Random 20仍然存在。 多虧了我在上一篇文章中的建議,我使用戶能夠使用他們的SoundCloud帳戶和喜歡的歌曲登錄。
Learning Node and Javascript properly is going to be a long journey, but I have patience. Three months ago I didn’t even know what a variable was.
正確學(xué)習(xí)Node和Javascript將會(huì)很漫長(zhǎng),但是我有耐心。 三個(gè)月前,我什至不知道變量是什么。
You can follow my adventure on Twitter as well.
您也可以在Twitter上關(guān)注我的冒險(xiǎn)經(jīng)歷。
翻譯自: https://www.freecodecamp.org/news/adventures-in-nodejs-d3d1f85a9d3e/
nodejs
總結(jié)
以上是生活随笔為你收集整理的nodejs_NodeJS历险记的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 结束书
- 下一篇: 梦到养狮子是什么意思