Node & Express Intro


The Daily Slate | Node & Express Intro
In this tutorial, we create a basic Node JS site with the Express framework from scratch. The project is meant to serve as a generic site that can be extended for use in most consumer-facing applications. The site incorporates much of the core functionality expected in modern apps today:
  • Database integration with Mongo DB
  • Profile signup/login
  • REST API design
  • Session Management
This is a good introduction to Node JS and backend programming in general. It provides a soid foundation for the more advanced, full-featured tutorials on Velocity 360.

Who

This tutorial is well suited for beginners who have basic Javascript experience. If you are a complete beginner with no coding experience at all, this is too advanced and we suggest learning the basics of Javascript and object oriented programming (tutorials on that will be posted soon).

Units


1. Setting Up With Express

In this video, we install the required tools (Node, express, Mongo) and create a basic web project using the Express Generator. Then we add our first route, the API handler, which will eventually manage the main CRUD (Create, Read, Update, Delete) operations for our profiles.

2. Mongo DB and API Routes

In this video, we set up the Mongo database integration using the Mongoose ORM then add the Profile schema. We connect to Mongo and run queries for all Profile objects in the database (none right now) via the API route from the first video.

3. Profile Regisration

In this video, we create a simple sign up for on the home page in order to create actual profiles for the backend. We register a few fake profiles and then create another route to fetch them individually.

4. Controllers and Promises

In this video, we extract the Profile CRUD operations into its own controller file in order the make the API route more modular. We also introduce the concept of promises to avoid overly nested callbacks and use promises instead of completion handlers to run our controller code.

5. Hashing Password

In this video, we conceal passwords from the API requests. Then we hash the passwords on profile registrations so that even if they are exposed from the database, they will be encrypted. Last, we set up an account route for the registration process which will redirect the user to a profile page on sign up.

6. Sessions

We set up session management in this video in order to keep track of the logged in user. This way, whenever the user navigates to various pages on the site or leaves and returns later, we will know who the user is.

7. JSON Web Tokens

In this video we use JSON web tokens to further enhance our authentication set up. When a user logs in, we create a token with secret key that gets passed back and forth with every subsequent request. We then use it to identify the logged in user on the profile page and render the username.

8. Submitting Comments

In this video, we set up the comment area so that users can submit comments. We post comments to your API handler at first to ensure it works, then we create a new endpoint in the account route in order to bind comments to the profile that is currently logged in.

9. Displaying Profile Comments

In this video, we render the comments for the logged in user on the profile page. We changed the template engine to mustache which gives us additional functionality for looping through data.

10. Styling and Partials

To finish out the site, we add Bootstrap for basic styling on the profile page. We also render the Nav bar using partials which enables us to avoid repeat code throughout the various pages of a site.

Purchase

$15.00

Purchase this tutorial for $15 and receive all videos, code samples and access to the forum where people post questions and answers.

Purchase, $15

Membership

Premium

$19.99/month

Join as a premium member for $19.99 each month and receive unlimited access to all tutorials, code samples, and forums on the site.

  • Downloadable Code Samples
  • Downloadable Videos
  • Q & A Forum Access
  • Discounts on Live Courses
Join

Basic

Free

Join as a basic member to gain access to the free tutorials, get notifications when new tutorials and courses are published, and participate in the Q&A forums.



Join