nodejs
by Elliott McNary
埃利奧特·麥克納里(Elliott McNary)
NodeJS歷險記 (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.
在經歷了FreeCodeCamp的前端課程之后,幾周前,我構建了一個應用程序,并想在進入NodeJS領域時編寫一個更新。 我終于能夠獲得我的驕傲的前端證書,但是當我跳入后端時,興奮很快就消失了。
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.
到目前為止,學習NodeJS非常困難。 試圖撒上仙塵沒有任何意義。 從主要使用JQuery和一些基本JS技術的前端到使用普通Java腳本和數百個回調的后端,這向我表明我不知道自己在做什么。
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需要對Java語言有基本的了解。 當我開始嘗試學習它時,我絕對沒有。 我不得不回頭看幾個小時的YouTube視頻,講解回調,事件循環,關閉,作用域等…
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.
我開始獲得相當多的了解,但是在大量回調之后仍然會迷失。 我使用的是learningyounode,即使沒有尋找解決方案也無法解決第一個問題。
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進行路由和Node的基本思想。 在我意識到自己并沒有真正吸收正在發生的事情之前,我構建了不少于4種不同的To-Do應用,2個reddit克隆,1個Twitter克隆和2個聊天應用。 我絕對不會盲目地遵循說明,但是他們認為我對Java語言了解太多。
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頻道上觀看系列節目,這確實幫助我降低了基本面。 我打算嘗試制作另一個Reddit克隆,直到我意識到我應該學習自己關心的東西,即我構建的Soundcloud隊列應用程序。
I stopped watching things and started reading through documentation. I followed getting started tutorials to try and understand the fundamentals a bit more.
我不再看東西,而是開始閱讀文檔。 我按照入門教程進行操作,以嘗試進一步了解基礎知識。
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.
我經常談論在編程時讓某些東西“點擊”的感覺,而這次我有同樣的感覺。 這是一個您永遠不會忘記的時刻,因為腎上腺素不斷增加,您可以看到一些光線。 當我能夠使用鍵值對設置我的第一個數據庫時,讓事件將事件推送到數據庫,然后將JSON發送到我創建的路由中是不可思議的。 已經很晚了,我拳頭像瘋子一樣在房間里抽水。
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.
從那開始,我開始獲得一些信心,并不斷地推動自己。 我致力于在MongoDB中查找,排序和增加現有文檔。 我意識到我想要直播,所以我開始研究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.
我認為我以前使用的教程的問題在于,我從來沒有真正了解過為什么要做事情。 我一直只是在做它們而沒有真正考慮它。 要知道為什么要做什么,這非常重要。
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?”.
我沒有去搜索以“我如何……”開頭的內容,而是開始尋找原因并試圖弄清實際情況。 我的搜索開始看起來更像“什么是OAuth中的刷新令牌?” 或“在Passport.js中序列化和反序列化做什么?”。
When I made that switch I really started to learn.
當我做出切換時,我真的開始學習了。
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.
不斷自我推銷也很重要。 如果您有想要制作的東西,請構建它。 總是有一種方法可以完成某件事,這取決于您自己決定(除非它是API限制之類的東西,否則……您只需要稍微加點子就可以了:)。 如果您不知道如何認證用戶,請嘗試學習。 如果您不知道如何創建RESTful API,請學習! 這將花費大量時間,但是一旦點擊,您就會欣喜若狂。
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.
上周日,我一直在該區域工作,直到海鷹隊在墨爾本開始比賽的凌晨5點為止。 這是一個14個小時的編碼過程。 我以前從未真正享受過如此多的樂趣和關注。 這是一種瘋狂的感覺。
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).
我終于弄清楚了(如何進行)如何在Heroku中部署它,并且它是實時的。 現在有一個提要,顯示正在網站上排隊的歌曲,右上角還有一個現場藝術家提要,顯示了現在正在站點上搜索的藝術家。 我還為所有一直排隊的前10首歌曲實現了前10名的排名(自啟動此功能以來)。
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.
對于所有使用它來查找新音樂的人來說,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.
正確學習Node和Javascript將會很漫長,但是我有耐心。 三個月前,我什至不知道變量是什么。
You can follow my adventure on Twitter as well.
您也可以在Twitter上關注我的冒險經歷。
翻譯自: https://www.freecodecamp.org/news/adventures-in-nodejs-d3d1f85a9d3e/
nodejs