Skip to content

globant-ui/nodejs-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

NodeJS Lab

This document is a Work In Progress.

Table of Content

  1. Introduction to NodeJS
  2. CommonJS Modules
  3. Intro to npm
  4. Globals, Process and Buffer
  5. Asynchronous Patterns
  6. Event loop
  7. Async functions
  8. Control Flow and Exception Handling
  9. Communication
  10. EventEmitter
  11. Cluster
  12. Streams
  13. Socket.io
  14. RESTful API
  15. HTTP (methods, headers)
  16. REST principles
  17. Express
  18. Starting with Express
  19. Templating
  20. Data Repositories
    1. MongoDB
      1. Intro to MongoDB
      2. Mongoose
    2. Reddis
  21. Debugging and Profiling
  22. Others
  23. Popular modules
  24. Links

Introduction to NodeJS

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.

CommonJS Modules

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.

Intro to NPM

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.

Globals, Process and Buffer###

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.

Asynchronous Patterns

This section introduces NodeJS's event loop, and different patterns to deal with asynchronous control-flow.

Event loop

Async functions

Control Flow and Exception Handling

Communication

This section introduces the use of events, clusters, and streams in NodeJS.

EventEmitter

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

Cluster

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

Streams

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

Socket.IO enables real-time bidirectional event-based communication. It works on every platform, browser or device, focusing equally on reliability and speed.

RESTful API

This section introduces RESTful principles, along with the HTTP protocol basics.

HTTP (methods, headers)

REST principles

Express

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

Starting with Express

Templating

Data Repositories

In this section you will learn about two popular data repositories.

MongoDB

MongoDB is an open source document-oriented database that provides high availability, high performance and automatic scaling.

Redis

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.

Debugging and Profiling

In this section, you will learn how to debug, and profile a NodeJS application.

Others

Popular modules

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.

Links

  1. Official documentation: http://nodejs.org/api/
  2. IO.js Official Documentation: https://iojs.org/api/
  3. Comparison between NodeJS and Java: http://www.infoworld.com/article/2883328/java/java-vs-nodejs-an-epic-battle-for-developer-mindshare.html
  4. 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
  5. Tips to make your app faster: http://www.sitepoint.com/10-tips-make-node-js-web-app-faster/

About

A hands on training to learn NodeJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published