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

Node.js: Related Tools & Skills

Book Description

While there have been quite a few attempts to get JavaScript working as a server-side language, Node.js (frequently just called Node) has been the first environment that's gained any traction. It's now used by companies such as Netflix, Uber and Paypal to power their web apps. Node allows for blazingly fast performance; thanks to its event loop model, common tasks like network connection and database I/O can be executed very quickly indeed.

In this book, we'll take a look at a selection of the related tools and skills that will make you a much more productive Node developer.

It contains:

  • Unit Test Your JavaScript Using Mocha and Chai by Jani Hartikainen
  • An Introduction to Functional JavaScript by M. David Green
  • An Introduction to Gulp.js by Craig Buckler
  • A Side-by-side Comparison of Express, Koa and Hapi.js by Olayinka Omole
  • An Introduction to Sails.js by Ahmed Bouchefra
  • Building Apps and Services with the Hapi.js Framework by Mark Brown
  • Create New Express.js Apps in Minutes with Express Generator by Paul Sauve
  • Local Authentication Using Passport in Node.js by Paul Orac
  • An Introduction to MongoDB by Manjunath M

This book is for anyone who wants to start learning server-side development with Node.js. Familiarity with JavaScript is assumed.

Table of Contents

  1. Node.js: Related Tools & Skills
  2. Notice of Rights
  3. Notice of Liability
  4. Trademark Notice
  5. About SitePoint
  6. Preface
    1. Who Should Read This Book?
    2. Conventions Used
      1. Code Samples
      2. Tips, Notes, and Warnings
  7. Chapter 1: Unit Test Your JavaScript Using Mocha and Chai
    1. by Jani Hartikainen
    2. What Is Unit Testing
    3. Setting up the Tools
      1. Testing on Node.js vs Testing in the Browser
    4. Setting up a Directory Structure
    5. Setting up a Test Runner
    6. The Basic Test Building Blocks
    7. Writing the Test Code
    8. Running the Test
    9. The Test Results
    10. Putting It Together
      1. Running the Tests in the Browser
        1. Live Code!
        2. Live Code!
        3. Live Code!
        4. Live Code!
      2. Running the Tests on Node
    11. What's Next?
  8. Chapter 2: An Introduction to Functional JavaScript
    1. by M. David Green
    2. Imperative JavaScript
    3. Object-Oriented JavaScript
    4. Functional JavaScript
    5. Start Thinking Functionally
  9. Chapter 3: An Introduction to Gulp.js
    1. by Craig Buckler
    2. That Sounds Scarily Complicated!
    3. Task Runners: the Options
    4. What About Gulp 4?
    5. Step 1: Install Node.js
      1. For Windows Users
      2. For Linux Users
    6. Step 2: Install Gulp Globally
    7. Step 3: Configure Your Project
      1. For Node.js Projects
      2. Git Users
      3. Following Along on Unix
    8. Step 4: Install Gulp Locally
      1. Alternative Deployment Options
    9. Step 4: Create a Gulp Configuration File
      1. ES6
    10. Step 5: Create Gulp Tasks
      1. Image Task
      2. HTML Task
      3. JavaScript Task
      4. CSS Task
    11. Step 6: Automate Tasks
    12. Step 7: Profit!
  10. Chapter 4: A Side-by-side Comparison of Express, Koa and Hapi.js
    1. by Olayinka Omole
    2. Background
      1. Express.js
      2. Koa
      3. Hapi.js
    3. Philosophy
      1. Compatibility
      2. Express.js
      3. Koa
      4. Hapi.js
    4. Starting a Server
      1. Express.js
      2. Koa
      3. Hapi.js
    5. Routing
      1. Express.js
      2. Koa
      3. Hapi.js
    6. Middleware
      1. Express.js
        1. Koa
      2. Hapi.js
    7. Usage
    8. Conclusion
  11. Chapter 5: An Introduction to Sails.js
    1. by Ahmed Bouchefra
    2. Main Features
    3. Sails.js vs Express.js
    4. The Waterline ORM/ODM
    5. Getting Started with Sails.js
      1. Prerequisites
      2. Installing the Sails.js CLI
      3. Scaffolding a Sails.js Project
      4. The Anatomy of a Sails.js Project
      5. Running your Sails.js Project
      6. Creating Waterline Models
      7. Sails.js Controllers
      8. Testing with Postman
      9. Routing in Sails.js
    6. Conclusion
  12. Chapter 6: Building Apps and Services with the Hapi.js Framework
    1. by Mark Brown
    2. The Project
    3. The Starting Point
    4. The Route Handler
    5. The Model Layer
    6. Our RESTful Actions
    7. Testing Our API Is as Easy as HTTPie
      1. Defensively Check for null Values and Return an Error
      2. Extend Sequelize.Model to throw an Error
    8. Path Parameters
    9. The Request Object
    10. Adding a Second Model
    11. Authentication with JWT
    12. Generating a JWT
    13. Validation with joi
    14. Who Is Consuming this API?
  13. Chapter 7: Create New Express.js Apps in Minutes with Express Generator
    1. by Paul Sauve
    2. What is Express?
    3. Getting Started
      1. Options
    4. Application Structure
      1. bin
      2. public
      3. routes
    5. app.js
    6. A Useful Tool
  14. Chapter 8: An Introduction to MongoDB
    1. by Manjunath M
    2. What’s MongoDB?
    3. Installing MongoDB
    4. Installing MongoDB on macOS using Homebrew
    5. Basic Database Operations
    6. MongoDB CRUD Operations
      1. Create Operation
      2. Read Operation
      3. Update Operation
      4. Delete Operation
    7. An Overview of MongoDB Drivers
      1. MongoDB Node.js Driver
      2. Mongoose Driver
    8. Conclusion