Node.js 6.x Blueprints

Book description

Create stunning web applications and Restful APIs from start to finish with Express, Loopback, MongoDB, and MySQL using this definitive guide

About This Book

  • Create stunning applications with Node.js from scratch, no matter the goal
  • Discover a wide variety of applications you can effectively integrate third-party libraries and other front-end frameworks with Node.js
  • Leverage all the new features introduced in Node.js 6.X

Who This Book Is For

This book caters to developers who are looking to build projects right from a simple website to more complex one such as a blog, chat application, a photography site, and a lot more. A Basic knowledge of JavaScript and Node.js would be extremely beneficial.

What You Will Learn

  • Explore MVC design pattern in Node.js
  • Build solid architectures by following test-driven development
  • Look beyond web applications and create your own desktop app with Node.js
  • Develop single page applications using Node.js with the RESTful APIs, MongoDB, and ORM
  • Master the Express framework and build a complete application with a real database
  • Create a real-time and fully functional online chat application with Socket.IO

In Detail

Node.js is the most popular framework to create server-side applications today. Be it web, desktop, or mobile, Node.js comes to your rescue to create stunning real-time applications. Node.js 6.x Blueprints will teach you to build these types of projects in an easy-to-understand manner.

The key to any Node.js project is a strong foundation on the concepts that will be a part of every project. The book will first teach you the MVC design pattern while developing a Twitter-like application using Express.js. In the next chapters, you will learn to create a website and applications such as streaming, photography, and a store locator using MongoDB, MySQL, and Firebase.

Once you're warmed up, we'll move on to more complex projects such as a consumer feedback app, a real-time chat app, and a blog using Node.js with frameworks such as loopback.io and socket.io. Finally, we'll explore front-end build processes, Docker, and continuous delivery.

By the end of book, you will be comfortable working with Node.js applications and will know the best tools and frameworks to build highly scalable desktop and cloud applications.

Style and approach

This is an easy-to-follow guide full of practical examples. This book takes a project-based approach and each chapter contains step-by-step instructions to create stunning applications across different application domains from scratch.

Table of contents

  1. Node.js 6.x Blueprints
    1. Node.js 6.x Blueprints
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. www.PacktPub.com
      1. eBooks, discount offers, and more
        1. Why subscribe?
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    7. 1. Building a Twitter-Like Application Using the MVC Design Pattern
      1. Installing Node.js
        1. Installing Yeoman
      2. Installing Express generator
      3. Building the baseline
        1. Adding changes to the package.json file
        2. Running the application
      4. Changing the application's structure
        1. Changing the default behavior to start the application
      5. Restructuring the views folder using partials
      6. Adding templates for login, sign-up, and profile
      7. Installing additional middleware
      8. Refactoring the app.js file with the new middleware
      9. Adding config and passport files
      10. Creating a models folder and adding a user schema
      11. Protecting routes
      12. Creating the controllers folder
      13. Running the application and adding comments
        1. Checking the error messages
      14. Summary
    8. 2. Build a Basic Website Using MySQL Database
      1. What we are building
      2. Creating the baseline applications
      3. Installing the Swig template engine
      4. Refactoring the views folder
      5. Creating a controllers folder
        1. Removing the default routes folder
      6. Adding partials files for head and footer
      7. Installing and configuring Sequelize-cli
      8. Editing the config.js file with database credentials
      9. Creating a User scheme
      10. Creating Band schema
        1. Creating associations between Band and User models
      11. Creating the database on MySql
        1. Using db migrations to insert data on Mysql
      12. Checking database tables
      13. Creating the application controllers
      14. Creating the application templates/views
      15. Adding style to the application
      16. Adding routes and a controller to the application
      17. Adding database content
      18. Creating a Bands form
        1. Inserting a new Band
      19. Main difference between ODM (mongoose) and ORM (sequelize)
      20. Summary
    9. 3. Building a Multimedia Application
      1. What we are building?
      2. Starting with package.json
      3. Adding baseline configuration files
      4. Adding server folders
      5. Configuring the app.js file
      6. Creating the config.js file
      7. Creating the controller's files
      8. Creating model files
      9. Creating view files
      10. Creating the public folder content
      11. Inserting images in the application using the upload form
      12. Inserting video files into the application using the upload form
      13. Important notes about image and video upload
      14. Summary
    10. 4. Dont Take a Photograph, Make It – An App for Photographers
      1. What we are building
      2. Creating the baseline applications
        1. Changing the application structure
        2. Adding Node modules to deal with images and the Cloudinary cloud service
      3. Creating the book controller
        1. Creating the book model file
      4. Adding a CSS framework to the application
      5. Refactoring the views folder
      6. Creating the .env.js file
        1. Creating and configuring a Cloudinary account
      7. How Cloudinary works
      8. Running the application
        1. Uploading and showing images
        2. Checking the MongoDb picture collection
      9. Creating folders in the Cloudinary dashboard
      10. URL transformation rendering
        1. Adding a direct link to the original image
      11. Summary
    11. 5. Creating a Store Locator Application with MongoDB Geospatial Query
      1. What we are building
      2. Creating the baseline application
        1. Refactoring the default structure
          1. Creating partial views for footer and head
          2. Setting Swig template to use HTML extension
          3. Creating partial files
          4. Creating applications template files
      3. Using the Geolocation HTML5 API
      4. Creating the application controller
      5. Creating models
      6. Creating the views template
      7. Adding locations to MongoDB
      8. Understanding Geospatial indexes on MongoDB
        1. Creating 2dsphere indexes in MongoDB
      9. Checking the Geolocation application
      10. Ordering points by distance
      11. Summary
    12. 6. Building a Customer Feedback App with a Restful API and Loopback.io
      1. What we are building
        1. Creating the baseline structure
      2. Creating models with command line
      3. Editing models after creation with command line
      4. Creating a datasource through the command line
      5. Connecting models to datasources
      6. Using the API Explorer
        1. Inserting records using endpoint
        2. Retrieving records using endpoint
      7. Adding database relations
      8. Dealing with LoopBack boot files
      9. Consuming the API
        1. Adding HTML content to client side
        2. Adding Bootstrap framework and React library
      10. Creating React components
      11. Creating new feedbacks
        1. Simple checking endpoints
        2. Disable remote LoopBack endpoints
      12. Summary
    13. 7. Building a Real–Time Chat Application with Socket.io
      1. What we are building
      2. Starting with a package.json file
      3. Adding configuration files
      4. Adding task manager files
      5. Creating the app.js file
      6. Creating the route file
      7. Creating the application views
      8. Installing frontend components with Bower
        1. Adding some CSS
        2. Adding live reload plugin
        3. Checking the application folder structure
      9. Creating the Socket.io events
        1. Adding socket.io behavior on the client side
      10. Starting the chat application
      11. Summary
    14. 8. Creating a Blog with the Keystone CMS
      1. What we are building
      2. Installing Keystone framework
      3. Creating the scaffold application
        1. Fixing the lint error and admin object name
      4. Running the Keystone  blog
      5. Anatomy of the Keystone engine
      6. Changing the default bootstrap theme
      7. Modifying the KeystoneJS core template path
        1. Building our own theme
        2. Changing the stylesheet
      8. Adding the Gallery script
      9. Extending the keystone.js core
      10. Inserting content using control panel
      11. Summary
    15. 9. Building a Frontend Process with Node.js and NPM
      1. What we are building
      2. Creating the baseline application
        1. Adding a Datasource to the project
        2. Creating application models
        3. Adding relationships between application models
        4. Setting up a static site
      3. Refactoring the application folder
        1. Creating the images folder
        2. Creating the libraries folder
        3. Creating the scripts folder
        4. Creating the SASS folder
        5. Installing Bower
        6. Installing application dependencies
        7. Create the scss folder structure
      4. Refactoring the client folder
        1. Adding the application views
        2. Installing AngularJS files
      5. Creating the AngularJS application
        1. Using Loopback's AngularJS SDK
      6. Adding content to the application
      7. Creating the Building tasks
        1. Installing the dependencies
        2. Creating the copy task
        3. Creating the SASS task
        4. Creating the linting task
        5. Creating the image optimization task
        6. Creating the concatenate task
        7. Creating the build task
      8. Using tasks with individual commands
      9. Deploying to Heroku Cloud
        1. Creating a Heroku application
        2. Creating a deploy.sh file
      10. Summary
    16. 10. Creating and Deploying Using Continuous Integration and Docker
      1. What we are building
      2. What Continuous Integration means
      3. Creating the baseline application
        1. Adding the root files
        2. Creating the config folder and files
        3. Creating the controllers folder and files
          1. Adding modules and authentication middleware
          2. Adding login GET and POST methods
          3. Adding signup GET and POST methods
          4. Adding account GET and UPDATE methods
          5. Adding account DELETE method
        4. Creating the model folder and files
        5. Creating the public folder and files
          1. Creating a custom stylesheet
          2. Creating the fonts folder and adding font files
          3. Creating the JavaScript folder and files
        6. Creating the views folder and files
          1. Adding the layouts folder and file
          2. Adding the pages folder and files
          3. Adding the partial folder and files
          4. Creating the test folder and test file
      4. Running the application
      5. Creating a GitHub or Bitbucket free account
        1. Creating a GitHub free account
      6. Creating a Heroku free account
      7. Creating a MongoLab free sandbox account
        1. Creating a user and password for the database
        2. Getting the string connection
      8. Initializing a git repository and pushing to GitHub
      9. Creating a Heroku application using Heroku Dashboard
        1. Linking the Heroku application to your git repository
        2. Adding environment variables to Heroku
      10. Creating a Codeship free account
        1. Adding environment variables to Codeship
        2. Creating setup and test commands in the Codeship project configuration
        3. Creating the pipeline for deployment on Heroku
        4. Adding the Heroku API key to Codeship
          1. Checking the test and deploy steps on the Codeship dashboard
      11. Installing Docker and setting up the application
        1. Checking the Docker version
        2. Creating a Docker file
        3. Creating a Docker image
        4. Preparing and running the Docker image
        5. Uploading the project image to your Docker hub account
      12. Summary

Product information

  • Title: Node.js 6.x Blueprints
  • Author(s): Fernando Monteiro
  • Release date: August 2016
  • Publisher(s): Packt Publishing
  • ISBN: 9781785888434