liveBook · Manning

Node.js

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

Node.js is a runtime platform for executing JavaScript outside web browsers, commonly for server-side applications and tooling.

Node.js is a runtime platform for executing JavaScript in an event-driven environment, making it practical to build network applications outside web browsers. JavaScript is the language; Node.js is the runtime, also commonly called node. section 4.3

A minimal Node.js setup supports AWS programming from the terminal:

  • Install Node.js for your operating system, then verify it with node --version; the examples target Node.js 14. section 4.3
  • Verify npm, the Node.js package manager, with npm --version. section 4.3
  • Run a script with node script.js, or install project dependencies with npm install. section 4.3 section 12.3

Node.js is used with the AWS SDK for JavaScript to call AWS APIs from application code. The SDK handles authentication, retries, HTTPS communication, and XML or JSON serialization, while Node.js runs the surrounding scripts and applications. section 4.3

AWS applications built with Node.js

A Simple S3 Gallery uses Node.js and the AWS SDK to upload images to S3 and download them for display. Other examples use Node.js to add DynamoDB items or send URL-processing messages to an SQS queue. section 7.5 section 12.3 section 14.2.4

Listing 12.3 nodetodo: Using docopt in Node.js (index.js)
const fs = require('fs');               #1
const docopt = require('docopt');       #2
const moment = require('moment');       #3
const AWS = require('aws-sdk');         #4
const db = new AWS.DynamoDB({
  region: 'us-east-1'
});
  
const cli = fs.readFileSync('./cli.txt', 
 {encoding: 'utf8'});                 #5
const input = docopt.docopt(cli, {      #6
  version: '1.0',
  argv: process.argv.splice(2)
});
#1 Loads the fs module to access the filesystem
#2 Loads the docopt module to read input arguments
#3 Loads the moment module to simplify temporal types in JavaScript
#4 Loads the AWS SDK module
#5 Reads the CLI description from the file cli.txt
#6 Parses the arguments, and saves them to an input variable

The listing shows a Node.js CLI loading modules, configuring the AWS SDK, reading arguments, and preparing DynamoDB access. section 12.3

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Defines the runtime and demonstrates installation, commands, dependencies, and AWS SDK integration without explaining runtime internals.
Examples
Uses an S3 image gallery, DynamoDB todo data, and an SQS-backed URL-to-PNG workflow.
What it assumes
Teaches the JavaScript-versus-runtime distinction and installation from zero, while assuming comfort with basic programming concepts.
What you can do after
Apply it via the AWS SDK to run scripts, access AWS services, and build small network applications.
How it connects
Connects JavaScript with the AWS SDK, S3, DynamoDB, SQS, npm, and command-line applications.

Also explained in

Compare how 4 books explain Node.js →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.