side. It uses open-sourced Chrome's V8
browsers like Opera and Vivaldi.
Node.js uses an event-driven, non-blocking I/O model. Functions like Querying Db, file system read/write operations are designed to be asynchronous non-blocking. Task completion will be signed through callbacks. Special care needs to be taken to avoid callback hell
Node.js is single threaded. You need to use process managers like pm2 to spin additional instance of your application to efficiently use the available cores on the server.
Node follows the Unix principle. One utility per file. Npm modules should be used like Lego blocks for building the software.
Validation logic, post records insertion logic are all written as middleware. It is Middleware not middlewares
word play, is the dependency manager for Node.js. Dependencies are
are installed in
It used for installing front-end assets like HTML, CSS, JS. The dependency
details are maintained in
and are installed in
bower_components/ folder. These days, more
frontend framework are preferring npm
over bower for managing dependencies.
Express is the most popular, widely used framework in the Node land. It is partly, because it is the "E" of the "MEAN" stack. Also, it is unopinionated. You can use routes to handle request - response, controller for db model interaction. It is easy to set up and run with it.
There are also other notable frameworks such as Walmart's hapi.js, Paypal's kraken.js. If you're coming from Rails background, you can check sails.js. It tries to solve the same problem that Rails had solved for Ruby.
IDEs like WebStorm will have everything integrated into the environment out of the box.
package.json is the equivalent of
is the dependency repository like
maven central. Equivalent of Jar is
You can run the Node.js application in any port you want, but it is highly desirable to have a public url address without port number. Since the default HTTP port 80 falls under 1024, you could require a sudo access to run the application on this port. This may lead to conflict with the web servers like Apache or Nginx that require port 80 to run. We can avoid this by the starting the application in ports > 1024 using process manager like pm2 and then fronting it with Nginx.
For my new posts, early access to my side projects, and more, get on my private email list, here:subscribe