Node.js Essentials

2-day advanced JavaScript course in Node.js — JS-04

JavaScript TrainingCourse Overview

This Node.js training course, is targeted at web developers with previous JavaScript programming knowledge and experience. It is designed as both a general introduction to the Node.js library, and as a practical introduction to using Node.js as a platform for building web applications.

This first half of this JavaScript training course concentrates the basics of installing, configuring and using Node.js, including: installing and using Node.js modules (NPM packages); creating and running command line JavaScript programs; creating, running, and interacting with customised web servers via the Connect library/framework.

The second half of the course takes delegates through the process of building and deploying a simple, but complete, web application using the Express.js library/framework. Through that process, students will learn how to manipulate JSON records; interact with databases; use websockets; emit and receive events via websockets; integrate and test their application.

JavaScript TrainingCourse Contents

Introduction to Node.js

  • What is Node.js?
    • Standalone JS virtual machine (V8)
    • Extensions for general programming
  • Features: what can Node.js do?
    • Server-side JavaScript
    • Servers/clients for any net protocol
    • Typically replaces web stacks, e.g.
    • Apache/Tomcat+PHP, Ruby on Rails
  • Why should you use Node?
    • Asynchronous events vs. threads
    • Performance
    • Server utilisation

Getting Started

  • Selecting a Node.js installation process
  • OS packaged installations
  • Mac, Windows, Linux
  • Source code installation
  • Installing the package manager (npm)
  • Running commands
  • To test your installation
  • Command-line tools, incl. REPL
  • Launching a server
  • Interacting with a server script
  • Starting Node servers at system startup

NPM Modules

  • Understanding modules
  • The require() function
  • Module scopes
  • Module caching
  • Finding NPM modules
  • Using modules
  • Maintaining modules
  • Using the npm command
  • Creating modules
  • Getters and setters
  • JavaScript patterns

Command Line Scripts

  • Getting user input
  • Reading arguments
  • Parsing command lines with Optimist
  • jQuery selection without the browser
  • Building command-line tools
  • Restarting scripts automatically
  • Validating JavaScript code

Web Servers

  • Responding to requests
  • Using Connect
  • Reading request data
  • Sending different response types

Building an Express app

  • Creating an Express app/project
  • Organising/structuring the app
  • Generating HTML views with Jade
  • Navigating datasets
  • Filtering data
  • Request variables and routes
  • Posting data
  • Modifying data through PUT requests
  • Handling GET requests returning JSON
  • Modifying HTTP response headers

WebSockets

  • Instant 2-way client-server comms.
  • Native browser support
  • Node.js and websockets: Socket.io
  • Emitting and receiving events
  • Communicating with individual sockets
  • Messaging across sockets
  • Implementing chat interfaces
  • Handling event types

Databases

  • Why MongoDB? Document-oriented
  • Connecting to with Mongoose
  • Encapsulate DB access in models
  • Define a Schema
  • Define a Model
  • Use validators, modifiers, getters, virtual attributes, default Values
  • Define instance methods and static methods
  • Reference other docs via DB Refs
  • An alternative: connecting to MySQL
  • Using node-mysql

Testing

  • Unit testing methods
  • Isolating blocks of code
  • The Mocha test framework
  • Testing HTTP with SuperTest

Conclusion

  • Hosting Node projects
  • Node.js sites and resources

JavaScript TrainingCourse Schedule

JavaScript TrainingFurther Details

Course Objectives

On completion of this JavaScript training course, you should be able to:

  • Understand what Node.js is
  • Appreciate the advantages and disadvantages of Node.js based web apps
  • Select and use popular Node.js libraries
  • Use Optimist for parsing JavaScript commands
  • Manage HTTP requests using the Connect framework
  • Create server applications using the Express framework
  • Debug and test web applications using Mocha and SuperTest
  • Integrate Node-based applications with MongoDB and MySQL DB

Target Audience

  • Experienced JavaScript programmers
  • General programmers with some JavaScript knowledge and substantial web development experience

Training Pre-requisites

Successful completion of the following 3-day JavaScript course; or equivalent knowledge and experience:

Training Style

This JavaScript training course, is instructor-led, hands-on practical training.

Hands-on practical work will take 40% to 60% of the contact time, depending on the needs, abilities and experience of the training group.