Node.js Part 2

Node is a good platform for writing an email server, file server, or proxy server, for example, and it can also be used as a client for these kinds of services. Node provides a few tools to aid in writing high quality and performant I/O applications.

From a programming point of view, you can think of buffers as similar to arrays, except they’re not resizable and can only contain the numbers 0 through 255 as values. This makes them ideal for storing binary data of, well, anything. Because buffers work with raw bytes, you can use them to implement any low ­level protocol that you desire.

A simple TCP server that echoes any data it receives back to the client

What’s the difference between pipes and sockets?

The pipe() function reads data from a readable stream as it becomes available and writes it to a destination writable stream.

Define a debug function based on a  DEBUG environment variable

What is an “event emitter”?

A  move() function that renames, if possible, or falls back to copying

The Node stack is composed of globally available functionality, core modules, and community­ created modules.

Debugging with the console module


Node Inspector

There are no classes in JavaScript because objects inherit directly from other objects, which is called prototypal inheritance.

Exporting and Importing Modules

Another bad part in browser JavaScript is that there is no way to include modules. Scripts are supposed to be linked together using a different language (HTML), but dependency management is lacking. CommonJS ( and RequireJS ( solve this problem with the AJAX­y approach. Node.js borrowed many things from the CommonJS concept.

it’s a common practice in node.js apps (and Mongoose) to open a database connection once, when the program starts, and then to keep it open until termination. this applies to web apps and servers as well.

creating TLS/SSL Keys and Certificates

HTTPS server

mocha, describe, beforeEach, afterEach, it, console.log usage

Module Patterns

How to store Node.js deployment settings/configuration files?


Instances of the Buffer class are similar to arrays of integers but correspond to fixed­ sized, raw memory allocations outside the V8 heap. The size of the Buffer is established when it is created and cannot be resized.

Use of SlowBuffer should be used only as a last resort after a developer has observed undue memory retention in their applications.


Leave a Reply

Your email address will not be published. Required fields are marked *