O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learn Node.js by Building 6 Projects.

Book Description

This is an advanced, practical guide to harnessing the power of Node.js by creating 6 full-scale real-world projects, from creating a chat application to an eLearning system.

About This Book

  • Develop scalable and lightweight applications using Node.js
  • Learn how to interface Node.js with other popular technologies such as MongoDB, MySQL, and more
  • Your companion to master the Node ecosystem through six real-world projects

Who This Book Is For

If you are a web developer or a student who wants to learn about Node.js in a hands-on manner, this book will be perfect for you. A basic understanding of HTML, JavaScript, and some front-end programming experience is required.

What You Will Learn

  • Create powerful applications using Node.js
  • Build scalable and lightweight web applications
  • Use the Express Framework to build web applications
  • Understand the coding principles behind practical web applications
  • Understand the concepts of network programming
  • Use Node.js with other technologies including Kickstart and Heroku
  • Use Node with database technologies Cassandra and MongoDB

In Detail

With its event-driven architecture and efficient web services capabilities, more and more companies are building their entire infrastructure around Node.js. Node has become a de facto part of web development that any serious developer needs to master.

This book includes six Node.js projects that gradually increase in complexity. You'll start by building a simple web server and create a basic website. You will then move to create the login system, blog system, chat system, and e-learning system.

By creating and following the example projects in this book, you'll improve your Node.js skills through practical working projects, and you'll learn how to use Node.js with many other useful technologies, such as ExpressJS, Kickstart, and Heroku.

Style and approach

This book adopts a unique, learn-as-you-do approach as you build on your understanding of Node.js progressively with each project. It contains six advanced Node.js projects. This book is designed so that implementing each project will empower you with a unique skillset, and enable you to implement the next project more confidently.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Learn Node.js by Building 6 Projects
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. Packt is searching for authors like you
  5. Preface
    1. What this book covers
    2. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    3. Get in touch
      1. Reviews
  6. A Simple Web Server
    1. Installing Node.js
      1. Installing the Git Bash tool
    2. Introduction to NPM and a basic HTTP server
    3. Serving HTML pages
    4. A basic website
      1. A basic website using Bootstrap
    5. Summary
  7. A Basic Express Website
    1. Understanding Express
      1. Installing Express
      2. Exploring the app.js file
    2. Pages routes and views
      1. Setting up View
      2. Back to basics
        1. id and classes
        2. Nesting
        3. Text
    3. Adding Layouts
      1. Using Bootstrap - Jumbotron
        1. Creating the Home page view
          1. Passing variable to view
        2. Creating an About page view
    4. The Nodemailer contact form
      1. More about the basic website
    5. Summary
  8. The User Login System
    1. Getting started with MongoDB – part A
      1. Installing MongoDB
    2. Getting started with MongoDB – part B
      1. Data fetching from the shell
      2. Create, read, update, and delete using MongoDB
    3. App and middleware setup
      1. Middleware for sessions
      2. Middleware for messages
    4. Views and layouts
      1. Index
      2. Creating a form
      3. Creating the login view
    5. The register form and validation
    6. Models and user registration
    7. Password hashing with bcrypt
      1. Installing bcrypt
    8. Passport login authentication
    9. Logout and access control
    10. Summary
  9. The Node Blog System
    1. App and module setup
    2. A custom layout template
    3. Homepage posts display
    4. Adding posts
    5. Text editor and adding categories
    6. Truncating text and categories view
    7. Single post and comments
    8. Summary
  10. ChatIO
    1. The ChatIO user interface
      1. Setting up the ChatIO UI
    2. Sending chat messages
      1. Creating the Node.js server
    3. User functionality
    4. Deploying an app with Heroku
    5. Summary
  11. E-Learning Systems
    1. The app and HTML Kickstart setup
      1. Setting up an application using Express Generator
        1. Configuring the app.js file
        2. Configuring the views directory
        3. Running the setup in the browser
      2. Implementing our layout
        1. Configuring the title and header in the layout
        2. Configuring the body in the layout
          1. Configuring the paragraph
          2. Configuring the sidebar
          3. Configuring hr
        3. Configuring the footer in the layout
      3. The final application
    2. Fetching classes – part A
      1. Setting up partials
      2. Adding some classes
      3. Creating a class model
        1. Fetch all classes
        2. Fetch single classes
        3. Working on the GET home page route
    3. Fetching classes – part B
      1. Setting up new route file – classes.js
        1. Creating the index.handlebars file for the classes page
      2. Configuring classes.js for the class details page
        1. Creating details.handlebars for the class details page
    4. Registering users
      1. Creating a user model
        1. Get User by Id
        2. Get User by Username
        3. Create Student User
        4. Create Instructor User
        5. Compare Password
      2. Configuring User Register
      3. Configuring the register.handlebars file
        1. Creating the student model
        2. Creating the instructor model
      4. Configuring the users.js file
        1. Testing the app for the errors
        2. Creating different objects in user.js for user collection
          1. Creating the new student object
          2. Creating the new instructor object
        3. Running the app for the instructor
        4. Running the app for the student
    5. Logging in users
      1. Setting up the Login page
    6. The Instructor and Student classes
      1. Configuring the student and instructor route
        1. Configuring the classes.handlebars files in student and instructor folders
      2. Making the link to register dynamic
      3. Making the instructor to able to register
        1. Testing the instructor registration to the classes
    7. Class lessons – the last section
      1. Setting up the Add Lesson link in the Classes tab
        1. Creating route for the Add Lesson link
          1. Configuring newlesson.handlebars
          2. Configuring the POST request
          3. Getting our Add Lesson values
          4. Configuring the class model for the Add Lesson model
          5. Changing the button text
        2. Testing the Add Lesson link
          1. Checking the added lesson in the Mongo shell
      2. Setting up the View Lesson link in the class
        1. Configuring the lessons.handlebars file
        2. Viewing lessons in the class
    8. Summary
  12. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think