This document is a Work In Progress.
- Introduction to NodeJS
- CommonJS Modules
- Intro to npm
- Globals, Process and Buffer
- Asynchronous Patterns
- Event loop
- Async functions
- Control Flow and Exception Handling
- Communication
- EventEmitter
- Cluster
- Streams
- Socket.io
- RESTful API
- HTTP (methods, headers)
- REST principles
- Express
- Starting with Express
- Templating
- Data Repositories
- MongoDB
- Intro to MongoDB
- Mongoose
- Reddis
- MongoDB
- Debugging and Profiling
- Others
- Popular modules
- Links
In this section, you will learn the basics of NodeJS. From how NodeJS application organize their source code, to how application dependencies are handled by NPM, and which global objects are provided by default.
NodeJS application organize their code into modules. There are a couple of standards on how to write a module in JavaScript. By convention, NodeJS has decided to use the CommonJS Module Specification.
NPM is a package manager for JavaScript, and is the default for Node.js. NPM makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you're sharing.
- What is NPM? Short explanation video
- Installing node and updating NPM
- Create and publish modules to NPM
As we have learnt, NodeJS's module system discourages the use of globals. However, it provides a few important globals that we can use. This section list the most important ones.
- Buffer: To handle binary data, NodeJS provides the global Buffer object. Buffer instances represent memory allocated independently of V8's heap. Here is an example of how to use buffers.
- Global: This module represent the global scope. It is not a good practice to use this global. When you define a global variable in a browser, its scope is the global one, but in node is different: you define a variable inside a module without "var" and its scope is the module itself.
- Process: Process is a node module that can be accessed anywhere without the need to be required. It exposes process manipulation such as signalling, exiting, the process id (pid), and more.
This section introduces NodeJS's event loop, and different patterns to deal with asynchronous control-flow.
- Solutions to control the flow
- Managing the asynchronous nature of NodeJS
- The Async library
- Error Handling in NodeJS
This section introduces the use of events, clusters, and streams in NodeJS.
Many objects in Node emit events: a net.Server emits an event each time a peer connects to it, a fs.readStream emits an event when the file is opened. All objects which emit events are instances of events.EventEmitter. http://nodejs.org/api/events.html
A single instance of Node runs in a single thread. To take advantage of multi-core systems the user will sometimes want to launch a cluster of Node processes to handle the load. http://nodejs.org/api/cluster.html
A stream is an abstract interface implemented by various objects in Node. Streams are pipes that let you easily read data from a source and pipe it to a destination. http://nodejs.org/api/stream.html:
Socket.IO enables real-time bidirectional event-based communication. It works on every platform, browser or device, focusing equally on reliability and speed.
This section introduces RESTful principles, along with the HTTP protocol basics.
- RFC 2616: HTTP Methods
- RFC 2616: HTTP Header fields
- How to make a simple HTTP request in Node
- Node API: HTTP documentation
Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
- Generating the application
- Example application: Hello World!
- Basic routing using Express
- Using middlewares
- Migrating from 3.x to 4.x
- Express Module Repository
In this section you will learn about two popular data repositories.
MongoDB is an open source document-oriented database that provides high availability, high performance and automatic scaling.
- Official documentation
- MongoDB architecture: Data Model, Query Model and Management
- Performance best practices for MongoDB
- Tutorial: creating an API with Node and MongoDB
Redis is an open source, BSD licensed, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.
In this section, you will learn how to debug, and profile a NodeJS application.
- How to debug using Node inspector
- Debugging apps using WebStorm
- Profiling NodeJS applications
- CPU Profiling
This section presents relevant modules written by the community, which are proven, and useful to write any NodeJS application. In addition, we provide further documentation to for you to explore.
-
Express Framework: Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. https://www.npmjs.com/package/express
-
Async Library: Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. https://www.npmjs.com/package/async
-
Request: Request is a simplified HTTP request client, designed to be the simplest way possible to make HTTP calls. It also supports HTTPS. https://www.npmjs.com/package/request
-
Socket.io: Socket.IO is used to create realtime web applications. It enables realtime, bi-directional communication between web clients and server. https://www.npmjs.com/package/socket.io
-
Lodash: Lodash is a toolkit of Javascript functions that provides clean, performant methods for manipulating objects and collections. https://www.npmjs.com/package/lodash
-
Mocha: Mocha is a feature-rich JavaScript test framework running on node.js and the browser, making asynchronous testing flexible and simple. https://www.npmjs.com/package/mocha
-
Mongoose: Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. If you use MongoDB, this is a must. https://www.npmjs.com/package/mongoose
-
Underscore: Underscore.js is a utility library that provides support for the usual functional suspects without extending any core JavaScript objects. https://www.npmjs.com/package/underscore
-
Redis: Redis is an open source, BSD licensed, advanced key-value cache and store. You can store keys in memory with optional durability. https://www.npmjs.com/package/redis
-
Jade: Jade is a high performance template engine heavily influenced by Haml and implemented with JavaScript for node and browsers. https://www.npmjs.com/package/jade
-
Moment: A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates. It was designed to work both in the browser and in Node.JS. https://www.npmjs.com/package/moment
-
Passport: Passport is an authentication middleware. It's sole purpose is to authenticate requests through an extensible set of plugins known as strategies. https://www.npmjs.com/package/passport
-
Nodemailer: Nodemailer is an easy to use module to send e-mails with Node.JS (using SMTP or sendmail or Amazon SES) and is unicode friendly. https://www.npmjs.com/package/nodemailer
-
Q: A JavaScript library for promises (CommonJS/Promises/A,B,D). https://www.npmjs.com/package/q
-
Mongodb: A node.js driver for MongoDB https://www.npmjs.com/package/mongodb
-
MySQL: A node.js driver for MySQL. https://www.npmjs.com/package/mysql
-
Nodemon: Nodemon is a simple monitor script for using during development of a node.js app. https://www.npmjs.com/package/nodemon
-
Hapi: Hapi is a simple to use framework with support for input validation, caching, authentication, and other essential facilities for building web and services applications. https://www.npmjs.com/package/hapi
- Official documentation: http://nodejs.org/api/
- IO.js Official Documentation: https://iojs.org/api/
- Comparison between NodeJS and Java: http://www.infoworld.com/article/2883328/java/java-vs-nodejs-an-epic-battle-for-developer-mindshare.html
- 6 things you should know about JavaScript: An interesting article about Node.js http://www.javaworld.com/article/2079190/scripting-jvm-languages/6-things-you-should-know-about-node-js.html
- Tips to make your app faster: http://www.sitepoint.com/10-tips-make-node-js-web-app-faster/