Join Ray Villalobos for an in-depth discussion in this video What is Node.js?, part of Building a Website with Node.js and Express.js (2014).
Now how would that help us if we were on a server. Well, in the same way that we can wait for user interaction on the client, Node can track a variety of events happening on the server. Say a database loading, a file transfer, or even client interaction. But Node does this in a very unique way. Now one of the most powerful features of Node.js is that it is designed to avoid waiting for things to happen. Now this is very different than what happens when you make requests from a traditional server. Now say for example, you create a request to a database.
Well the server generally requests the data from the server. But then has to wait until the server queries that database and returns the data before doing anything else. We call that blocking. And if you've ever done a complex database query, you've probably seen instances where the client has to just sit and wait for that process to be done. But Node exceeds at handling two-way connections, connections between the server, and say, a database. So when Node makes a request to a database it doesn't have to worry about waiting for that database to return the data.
And once the data is received from the server, it sends it to the appropriate client. So it's much more efficient than traditional server languages. Now the ability to handle connections is why Node is really good at creating real time applications. Because of it's non-blocking architecture, Node can handle a lot of connections simultaneously, and is great at creating applications where the client is talking to the server. But, unlike other services, it's really good at applications where the server needs to push the data to the client.
Or our clients need to communicate with each other. So things like chats, multiplayer games, real time data streaming and more. Node isn't just a fade it's become quite popular with main street companies like Walmart and PayPal. If you're trying to figure out if Node.js is the right platform for your web application. Just take the time to watch a couple of these videos. One from PayPal and one from Walmart. So you may be ready to go run into your server and install Node.js. But before you do, let's take a look at some of the challenges that happen when working with Node.
Node.js is itself a very concise library. So, you are going to need to add modules in order to expand its capabilities. If you take a look at the API documentation, you'll see that Node itself is very tiny. Now there isn't much here, so this brings me to another issue. Node by itself wasn't really designed for creating websites. It was really created to handle server tasks and so building aside with Node.js requires additional libraries. In this course, I'll be showing you how to work with the Express.js framework.
So Node won't be your go to tool for every type of project, but it's really good at handling two way network communications. You can build a website using Node, but in order to do so you're really going to need something on top of the node like Express.js that'll make it more user friendly.
- Installing Node.js and Express.js
- Exploring the node package manager (npm)
- Creating and modularizing routes
- Using templates
- Adding partials
- Using the Express Generator
- Preparing your site structure
- Adding static content
- Importing your data
- Passing custom data through routes
- Publishing your application