Session

Download Package:
npm install express-session --save
Include Module:
var session = require("express-session");

app.use(session({
    secret: "your secret string",
    resave: false,
    saveUninitialized: false
}));
Set Session Variable: Access the session object from the request object, and add your own variables to the session object. Those variables will be available to that client only:
request.session.yourVariable = something;
Get Session Variable: Access the session object from the request object, and access your variables from the session object. You can access variables that were added by that client only:
request.session.yourVariable
Destroy Session: Access the session object from the request object, and remove all variables that were added by that client:
request.session.destroy();

More Info: npm page

WebSocket

Download Package:
npm install socket.io --save
Include Module:
var socketio = require("socket.io");
Listen for Connections: In your server JavaScript, find where you are starting the app and add the following:
var server = app.listen(process.env.PORT, function() {
    console.log("app started");
});

io = socketio.listen(server);
Broadcast Data: In your server JavaScript, send data to all connected clients:
io.emit("yourEvent", yourData);
Include Script: In your HTML, put the following in the <head>:
<script src="/socket.io/socket.io.js"></script>
Connect to Server: In your client JavaScript, connect to the server:
var socket = io();
Listen for Data: In your client JavaScript, listen for data from the server:
socket.on("yourEvent", doSomething);

function doSomething(data) {
    // write code here to do something with the data
}

More Info: npm page

Uploading Files

Create Form: In your HTML, create a form with a file input and submit button:
<form action="/yourRoute" method="POST" enctype="multipart/form-data">
    <input type="file" name="yourFileInputName">
    <input type="submit">
</form>
Download Package:
npm install formidable --save
Include Modules:
var formidable = require("formidable");
var fs = require("fs");
Save File: In your file upload route, get the file from the request and save it to a folder:
var form = new formidable.IncomingForm();
form.maxFileSize = 25 * 1024 * 1024; // 25 megabytes

form.parse(request, saveFile);

function saveFile(error, fields, files) {
    var temporaryPath = files.yourFileInputName.path;
    var permanentPath = __dirname + "/yourFolder/" + files.yourFileInputName.name;

    fs.rename(temporaryPath, permanentPath, doSomething);
}

function doSomething(error) {
    // write code here to do something after saving the file
}

More Info: npm page

Resizing Images

Download Package:
sudo apt-get update
sudo apt-get install imagemagick
npm install node-imagemagick --save
Include Module:
var imageMagick = require("node-imagemagick");
Resize Image: In your server JavaScript, resize an image:
var options = {
    srcPath: yourImagePath,
    dstPath: yourDestinationPath,
    width: someWidth
};

imageMagick.resize(options, doSomething);

function doSomething(error) {
    // write code here to do something after resizing the image
}

More Info: npm page

Sending Emails

Download Package:
npm install emailjs --save
Include Module:
var emailjs = require("emailjs");
Send Email: In your server JavaScript, connect to the email server and send an email:
var emailServerInfo = {
    host: "smtp.gmail.com",
    user: "mrcodejr@gmail.com",
    password: "mrcodeswildride",
    ssl: true
};

var email = {
    from: "Your App Name <mrcodejr@gmail.com>",
    to: someEmailAddress,
    subject: yourEmailSubject,
    text: yourEmailBody
};

var emailServer = emailjs.server.connect(emailServerInfo);
emailServer.send(email, doSomething);

function doSomething(error) {
    // write code here to do something after sending the email
}

More Info: npm page

Sending Requests

Download Package:
npm install request --save
Include Module:
var request = require("request");
Send Request: Send a request:
request.post(yourUrl);
Send Data: Send a request with data:
var data = {
    form: {
        yourKey: yourValue
    }
};

request.post(yourUrl, data);
Process Response: Send a request with data and process the response:
var data = {
    form: {
        yourKey: yourValue
    }
};

request.post(yourUrl, data, doSomething);

function doSomething(error, response, body) {
    // write code here to do something with the body
    // you can get what was sent with response.request.body
}

More Info: npm page

Reading Files

Include Module:
var fs = require("fs");
Read File: Read a file:
fs.readFile(yourFile, "utf8", doSomething);

function doSomething(error, contents) {
    // write code here to do something with the file contents
    // you can split the contents into separate lines with contents.split("\n")
}

More Info: module page