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?

http://stackoverflow.com/questions/18568089/whats-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”?

http://stackoverflow.com/questions/13438924/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

Cluster

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 (http://www.commonjs.org/) and RequireJS (http://requirejs.org/) 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

https://darrenderidder.github.io/talks/ModulePatterns/#/

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

http://stackoverflow.com/questions/5869216/how-to-store-node-js-deployment-settings-configuration-files

assert.deepStrictEqual

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 *