4 ms·
Your welcome. I love node, don't get me wrong there are frustrating parts to it like any language, but overall it has been super productive after you get past
by davismwfl 11y ago
Your welcome.
I love node, don't get me wrong there are frustrating parts to it like any language, but overall it has been super productive after you get past the learning curve. Coming from Python you will have little trouble, and the learning curve isn't too bad if you have a reasonable handle on javascript. For node there are a ton of libraries, code snippets and modules that are available, way more today than even just a few years ago. Searching npm is a good start and from there most people link directly to their code on github so you can see how things are done.
As for debugging, I use Webstorm as an IDE and I can set breakpoints, walk thru code and do all the normal things you would in an IDE environment. I personally still use vim at times to when I am doing simple things and don't need to fire up the IDE, but all our node projects are in Webstorm just because it speeds up development. I also still dump a bunch of stuff to the console when I am debugging just because I am weird that way, plus in some cases I found it is faster than debugging code sections where timing can be different every run.
Some learning curve issues. Remember node is event driven, code is not necessarily synchronous when you read it top down. Callbacks wind up getting deep and ugly if you aren't careful, generally IMO when I see too many callbacks nested it is either a place where promises should be used or even more likely it is a place that just is trying to do too much and screams for breaking steps up. There are some modules to familiarize yourself with too that you will use a lot, async immediately comes to mind in addition to the express series.
As for our user module, no we haven't open sourced it or even written it up externally yet, but I think I might do one or both soon. Honestly passportjs is a great little module from all that I know, but when we started writing our systems we evaluated it and just didn't feel it fit what we were doing. Today that decision might be different if we had to start over.
In general, our systems use MongoDB for the database, Mongoose for schema's and then we rolled our own authentication, utilities and errors. We use winston for logging as it works well and gives us a ton of flexibility. As part of our middleware too, we added methods to the request object to allow us to simply call our api backend, so we have an apiGet, apiPut, apiPost, apiDelete. These handle all the complexity of calling the API and remove a lot of headaches and in turn makes the code way easier to debug and far cleaner.
- tixocloud 11y agoThanks so much for all that input. I'm excited by using node but at a previous workplace, I've been through JS hell where everything becomes spaghetti so I am slightly more cautious about things. Debugging was a nightmare although it could probably be down to the fact that JS best practices weren't used. I'll check out passportjs for sure and evaluate whether or not I should roll my own thing but yes, the user module will be absolutely invaluable!