Learn the design patterns that transcend Express.js and recur throughout high-quality production codebases, with a step-by-step approach that teaches by doing.
Wonderfully entertaining and illuminating. Guaranteed to induce frequent “ah-ha!†moments. Easily one of the best treatments of backend programming with Node.js.
— Chris Aquino, author of Front-End Web Development: The Big Nerd Ranch Guide
Express is arguably the ubiquitous library for building Node backends. As of mid-2019, it is a dependency of 3.75 million codebases on Github alone. So if you hop into a Node codebase, chances are Express is part of it.
Good design in an Express.js backend is good design anywhere. The patterns you learn to develop Node backends will outlive Express and influence your design approaches in unrelated platforms.
- Learn Express.js by building a pure backend with authentication from scratch.
- Apply best practices to architect resilient, testable Node.js backends.
- Discover functional design patterns that transfer to any tech stack.
Who Is This Book For?
Searching for an Express.js primer that isn’t another screencast or exhaustive reference guide? Whether you’re a seasoned backend developer, frontend developer or recent web bootcamp graduate, this is the guide for you.
- Learn the intuitions of developing elegant, maintainable backends without the distractions of every tangential tool in the ecosystem.
- Solidly grasp the motivation behind each concept as you build step-by-step.
- Expand your design palate with patterns that will transfer to other platforms.
What You Will Learn
This book focuses on best practice, conventional backend design for pure backend APIs. As we build a full-featured backend together, expect to:
- Demystify HTTP: the web’s core abstraction
- Use telnet and Insomnia to test backend features
- Refactor a vanilla Node.js http.Server into an Express app
- Apply the Router design pattern to tease apart growing functions
- Drop in Express’s Router factory with zero changes
- Leverage JavaScript’s Function Objects to seamlessly upgrade middleware
- Work with streaming, JSON and multipart request bodies
- Build custom, decoupled middleware that’s trivial to reuse
- Extract complex branch logic into dedicated middleware
- When to use global, route or router middleware to prevent coupling
- Handle exceptions with error handling middleware
- Community middleware for static servers, file uploads, logging, body parsing, MIME types and more
- Design perspectives on authentication vs. authorization
- Build conventional authentication endpoints
- Write loosely coupled username/password authentication middleware
- Authenticate with JSON Web Tokens that coexists with other auth strategies
- Create graceful global middleware
- Currying, partially applied functions and other Functional Programming patterns
- Customize middleware with Middleware Factories
- Design patterns for elegant authorization logic
- Split authorization into Policies and Enforcers
- Guard routes with custom exceptions
What Do I Need to Know?
You should have a strong hands-on foundation in JavaScript and Node.js, including:
- Callbacks, async functions and Promises.
- ES2015, especially destructuring syntax and arrow functions.
You don’t need prior backend experience. If you understand how servers and clients interact, experience from either side of the equation is sufficient.