A programmatic description of an API that doesn’t include an implementation. In Node.js, a good example is the Streams API.
A function written in a shorthand syntax. Instead of writing function () {}, write () => {} when passing functions as arguments to other functions. If the function accepts only one argument, the parentheses can be omitted.
Describes code that doesn’t necessarily run in the order in which it appears. In Node.js, this term is used to distinguish APIs that accept callbacks that will be run at a point in the future. For example, fs.readFile accepts a callback that receives the file’s contents after it has been read.
The libraries that are built into Node.
ECMAScript 2015 introduced destructuring, which allows objects and arrays to be broken into variables and constants. For example, const { name } = { name: 'Alex' } creates a constant called name with the value alex.
ECMAScript is a scripting language specification standardized by Ecma International. There are several ECMAScript standards; this book focuses on ECMAScript 2015 (ECMAScript 6th Edition). JavaScript implementers use the ECMAScript standard to make sure their interpreter is compatible with JavaScript written for other implementations.
A string that causes a function to be called. The function is known as an object listener. An emitter sends the named event. The basic class for creating emitters in Node is EventEmitter.
Node’s event loop waits for external events and converts them into callback invocations. Other systems use similar things-—message dispatchers and run loops—to quickly route events to the corresponding event handler.
JSON is a lightweight data-interchange format, intended to be easy to read and write, and based on a subset of JavaScript.
A multiplatform library for asynchronous I/O. It’s used in Node, but also other libraries and languages such as Julia.
Blocking operations halt execution until the operation completes. Node uses nonblocking I/O, which means reads from a network or file resource won’t block execution.
Node’s package manager. It allows you to install Node packages from a large central repository and to manage dependencies in Node projects.
The Promise object is a standardized ECMAScript 2015 API for representing values that may be available now, in the future, or never.
A command-line interface enabling you to evaluate code and see the results.
The rest parameter syntax in ECMAScript 2015 allows an unknown number of arguments in a function to be represented as an array. To name two arguments but put the rest in an array, use function (a, b, ...rest). It can also be used with destructuring to copy objects: const newObject = { ...oldObject }.
A convention for specifying library compatibility using three numbers: major, minor, and patch, written as 1.0.2 (major: 1, minor: 0, patch: 2). An application that depends on version 1.0.2 should be compatible with 1.1.1, but not 2.0.0.
A function that has been passed to a function and may run later.
JavaScript functions capture the variables defined in their enclosing scope. If you define function B inside function A, B will have access to all of A’s values.
A module format for defining which values should be exported from the current JavaScript file. See module.
Web application used to edit text and images that will be displayed on a public-facing website.
The order in which statements will be executed. Because Node is asynchronous, control flow is of interest, as JavaScript offers many ways of dealing with control flow, including callbacks, promises, generators, basic looping primitives, and iterators. In Node, flow control refers to the way we group sequences of asynchronous tasks.
Scope means the parts of the program that can access a value, so global scope means a value is accessible everywhere within a program.
Node modules are single files that contain JavaScript. Values (typically, functions and constants) can be exported so they can be used in other files.
A callback within a callback; when a callback has been passed to a function, it’s sometimes necessary to define another callback inside the first callback.
A file that defines a Node project’s name, author, license, and dependencies. Every Node program and library you create should have a package.json file.
JavaScript objects are collections of keys and values, and keys and values are known as the object’s properties.
A list of program instructions that had executed up to the point when an error occurred.
The value of all the variables in a program at a given time.
Code that’s frequently duplicated and that could be automated.
Preprocessed JavaScript code from several source files that’s usually minified and compressed, and then served to clients.
A command-line tool and programmer library for making HTTP requests. It’s often used as a debugging tool for quickly checking how web servers respond to requests.
A programmer-friendly data model that makes it easier to interact with database tables or documents than using the database’s native language.
When an HTTP POST is made to a web server, including a simple form POST, the form’s contents are encoded into the request body. The most common format, application/x-www-form-urlencoded, is similar to URL encoding, which replaces unsafe ASCII characters with percent signs.
An internet standard for adding nontextual data to emails and multipart message bodies. This allows email clients to show HTML, images, and text in non-ASCII character sets.
A library that maps between programmer-friendly data structures (for example, JavaScript objects) and database data structures (for example, tables and foreign keys).
Stateless web API using a set of predefined operations in HTTP. The operations are based on HTTP verbs; the most common are GET, POST, PUT, and DELETE.
The URL fragment and HTTP verb that a given route handler should process.
A user-defined callback that runs when an HTTP request is made to a web application. The route handler usually generates content, perhaps from a database, or modifies a database, and then generates the response by using a template or format such as JSON.
A file that’s served by a web server without any additional processing. Typically, images, CSS files, and client-side JavaScript files are static assets.
Plain-text format that can include embedded data or JavaScript code and be used to generate HTML to streamline HTML’s syntax.
A set of tools and configuration files for generating JavaScript that will run efficiently in a browser.
A program that checks the correctness of a source file’s format. Linters can be used to enforce a given programming style on a project by checking against a set of linting rules.
Running a method on the return value of a previously called method.
Connecting a data output to an input. In UNIX, processes are pipelined by using the vertical bar character (|); in Node, streams are connected by using method chaining.
A file that allows browser debuggers to map from a line in a transpiled source file to the original code.
An efficient data input and/or output channel that may be text or binary data. Node supports readable, writable, and other stream types, and these streams can be linked together by using pipes.
A program that runs and collates the results of unit tests found in one or more files.
Also known as source-to-source compilers, JavaScript transpilers convert one type of ECMAScript to another. The most common use is to convert modern ES2015 to backward-compatible ECMAScript 5, which can run in more browsers. Another example is TypeScript, which is a superset of JavaScript that gets transpiled into ES5 or ES2015.
Transforms or transpiles source code.
Changes the behavior of the build process itself, rather than the output files.
Some database libraries are written in a generic fashion and can be extended with specific adapters that implement functionality for the desired database.
If a function, class, or module can easily be changed in a project, or reused in another project, then it is loosely coupled.
A framework that includes features for working with both client-side and server-side code. That usually means it has libraries for dealing with HTTP requests, request routing, database modeling, and communication with code running in a browser.
URL parameters that appear after a question mark and are separated by ampersands.
The HTTP method (GET, POST, PUT, PATCH, DELETE) representing the action that should be performed on a remote resource.
JavaScript applications that run both client-side and server-side by sharing the same code.
Functions that can be called in sequence to modify an HTTP request and response.
Design pattern for separating software into components; the model manages data and logic, the view transforms the data into a user interface, and the controller converts interactions into operations for the model or view.
A database structure based around relations between the stored entities.
An application that’s served to the browser once and doesn’t require a full-page reload. If the application needs to change the URL in the browser for any reason, the HTML5 History API is used to give the impression that the URL has changed and the browser has loaded a new page from the server.
A set of libraries for developing a web application with support for extensibility through plugins or middleware.
A password-hashing function. This function maps arbitrary amounts of data to a string of fixed size that can be stored safely in a database, so the user’s plain-text password isn’t stored.
Part of the HTTP standard that deals with serving different versions of a document at the same URI. User agents (browsers) can request a different data format if the server supports it.
Programs that convert supersets of CSS to CSS that a browser can interpret. The Sass and LESS stylesheet languages both include CSS preprocessors, and these languages add features such as variables, nesting, and mixins.
Random data used in addition to the input of a hash function, making dictionary attacks harder.
An in-memory database that’s also used as a cache and message broker. It’s useful for storing user sessions and dealing with push messages in web applications.
A map from a string field and a value, used to represent objects in a Redis database.
An object that determines how your server will respond to a given HTTP request. It includes the response body, which is usually a web page, and the headers.
A running program (process) can be made up of threads that execute concurrently. JavaScript’s model is to use a single thread, but allow the thread to switch context and run different code when events happen. The events in a browser are interactions such as the user clicking a button; in Node, they’re typically I/O events, such as network operations or data being read from a disk.
Lightweight markup languages that are converted to HTML and add features that make it easier to inject values from code, and iterate over arrays or objects.
Middleware components that aren’t distributed by the authors of the original web library or framework.
The visibility of a variable is determined by its scope. In JavaScript, adding a function adds a new level of scope. Any variables defined in that function are visible by any functions defined within that function.
This usually means a class that contains methods for use in other classes. In Sass, mixins are groups of CSS declarations that can be reused in multiple places; in Pug, mixins are used to define reusable template fragments.
Small, reusable template.
A lambda is an anonymous function, so a section lambda in Hogan is a way of associating a function with a tag in a template.
In JavaScript, curly brackets, semicolons, and newlines are used to separate statements. If a new lexical block is required, a function or control statement is used. In languages with significant whitespace, such as Pug, lines of code are grouped together by the number of spaces used to indent each line.
If a web application accepts user input from forms or URL parameters, and those values are redisplayed in templates, then it may be possible to inject malicious code. Values must be escaped first to be safe from this type of attack.
For a database to be ACID-compliant, it must support operations that are atomic (the operation succeeds, or the operation fails and the database is left unchanged), consistent (the data changes only in the allowed ways), isolated (ensuring concurrent execution), and durable (after a change has been made, it will remain, even if the system crashes or is rebooted).
A binary format used by MongoDB for representing objects. Objects consist of an ordered set of elements; the elements are made up of a field name, a type, and a value. The types supported by BSON include string, integer, date, and JavaScript code.
A program that runs in the background, usually starting automatically when the system boots.
A formal definition of the data and relationships between items in a database. It’s the design of the database.
One or more database operations that are grouped together and run according to the ACID properties.
A database stored on multiple computers, potentially but not necessarily in different geographical locations.
An attempt to hide complexity that exposes too many details and issues of the underlying implementation.
A database that stores semistructured data without a predefined schema, sometimes in JSON or XML. Examples include MongoDB and CouchDB.
An optimization technique that stores the result of a function so it doesn’t have to be called again.
A database that doesn’t use tabular relations as found in relational databases.
A column in a database table that’s used to uniquely identify each row.
A pattern in which messages can be sent to multiple receivers.
An API that’s more convenient for programmers than writing SQL queries by hand.
Used as the theoretical basis for relational databases to model the stored data and queries that can be performed on it.
A group of MongoDB processes that maintain the same dataset.
A way of allowing JavaScript to run on background threads in browsers.
Ensure that an expression matches an expectation. This can be a simple Boolean statement, equality, or practically anything else. In Node, assertions throw exceptions when they fail. A test runner can catch and collate these exceptions to produce test reports.
An extension of TDD that uses a different API style to encourage a focus on where in the process the test occurs, what to test and what not to test, and how much to test in one go. It also tries to improve understanding of test failures, and the naming of test units.
Testing a slice of functionality through the whole system. In web development, that means full-stack testing: the browser and server are tested at the same time.
Objects or values that behave like real counterparts, but are usually a simple veneer that provides just enough behavior to allow a test to run. Rather than accessing real files or networks in tests, which could be slow or dangerous if destructive operations occur, mocks can be used to safely simulate their behavior.
Writing tests before the code under test.
A program that manages loading tests, running them, and then collecting the results so they can be displayed. Mocha is a test runner.
A JavaScript operator that returns a string for a given object or value.
Small parts of a module, such as functions or methods of a class, are tested in isolation against assertions in small test cases (units).
Amazon’s virtual computer service.
A type of virtualization, containers are isolated user-space instances of an operating system, running on top of a host operating system. Containers offer additional control over resource usage and security benefits, and they can be quickly started up and destroyed.
Distributed servers that deliver static content.
An image of the filesystem that Docker will use to create a container.
Heroku’s term for a container; this is used to run both servers and arbitrary commands in an isolated environment on Heroku’s servers.
An orchestration service run by Amazon for scripting deployments to Amazon’s other services, such as EC2.
A command that runs periodically and renames log files based on the date, and then optionally compresses them to use less storage space.
Provides an encrypted command-line (or X11) interface to a remote computer for running commands. It can form the workflow of a web developer when initially configuring a new server, or connecting to servers to run maintenance or debugging commands.
A program for running programs with other user privileges. It’s usually used to run commands that need special privileges, such as editing system configuration files.
Program arguments are the flags provided on the command line that enable or disable certain features.
Value returned by a program when it completes. Nonzero values indicate an error.
The methods an operating system provides to allow running programs to communicate. An example is pipes, which use the output of one program as the input of another, but even files can be considered a form of interprocess communication.
A consortium that publishes the Single UNIX Specification, a family of standards that qualifies producers of operating systems to use the UNIX trademark.
Command-line user interface enabling commands to be entered and the results viewed. It’s called a shell because it’s a layer around the operating system.
Capturing the output from a program and sending it as input to another program or file.
The error stream for outputting error messages from a running program.
The input stream for a running program.
The output stream for messages printed by a program.
An open source browser from which Google’s Chrome browser derives its code.
A Node process that manages the Electron app and access to files and the network.
The Chromium web view.
React applications use a mix of HTML fragments alongside JavaScript. This is preprocessed into pure JavaScript before it runs in a browser. This language is called JSX.
A program or library that’s written using the operating system’s built-in APIs.
A library by Facebook for building data-driven web and mobile user interfaces.
A function that creates and initializes a JavaScript object.
A text format for tabular data that’s typically used with databases or spreadsheet programs. The values are split into columns by using commas, and rows by using new lines.
The standards that define the API for JavaScript working with HTML. The DOM is a language-independent interface working with HTML.
A way of including structured data in HTML that’s readable by both humans and software. Because HTML doesn’t always represent structured data clearly, microformats can be used to embed data such as addresses, geographical locations, and calendar entries in HTML without any special tags.
An expression that matches patterns in a string.
A standard used by websites to tell web crawlers and scrapers what content can be scanned or excluded from scraping.
Search engine that focuses on a niche.
Converting HTML into structured data that can be stored in files or a database.
A query language for selecting nodes from an XML document.