The Universal Guide to Building REST APIs

Tao of Node

Proven rules and guidelines to build better Node.js applications. From architecture and design to tooling, testing and performance.

125 rules, 6 chapters, 190 pages

By Alexander Kondov, author of Tao of React

Evergreen knowledge that will never go out of date.

Tao of Node Book Cover

Node.js & Express beyond the basics.

You take a Node.js course and learn the basics. You can build simple applications and know how things work. You start building your first larger project and questions pop up. There are many resources that can teach you the little pieces. No one tells you how to put them together to build real software.

How do I structure my project so it's easy to maintain?

Where do I put my business logic and how do I make it reusable?

What libraries should I use and how do I test my application?

Most applications need to be extended, modified and supported. To work productively you need more than just surface-level knowledge of Node. You need to know how to structure a codebase, what practices to follow when building services and how to make trade-offs.

Let me help you out. Through trial and error I've formulated a set of principles that I follow when building Node applications. I've learned them the hard way but you don't have to.

For beginners and intermediate developers.

Tao of Node is made for beginners who want to learn about building real-world applications and intermediate developers who want to advance in their careers. The best time to read it is when you've grasped the fundamentals and are starting to build real applications.

This book will not teach you Node.js from scratch. It builds on top of the core concepts and helps you form the right principles. What do you need? Basic understanding of a router like Express, experience with any kind of database and one personal project to practice with.

If you've built an application following a tutorial and you're wondering how to structure itthis is for you.

If you're unsure what's the best way to deploy it or what libraries to usethis is for you.

If you're not sure what you should focus on to make your code cleanerthis is for you.

Tao of Node will help you go from beginner to intermediate by helping you understand core principles about software design.

Chapters

Each chapter contains a set of simple rules that will help you build great software. You don't have to read them in a particular order. Dive in and learn what's most interesting to you.

Architecture

High level concepts and decisions that make a codebase modular and extensible - structure, abstractions and business logic.

Tooling

The technologies and libraries to focus on for your next project - frameworks, databases, supporting tools, logging and monitoring.

Testing

Development is never final. We'll learn principles about testing that will help us maintain quality and stability as our application grows and changes.

Performance

It doesn't matter how good your product is if it's slow. We'll explore core performance principles to keep in mind.

Serverless & GraphQL

Two technologies with great Node.js support that any engineer should understand. We will go over the best practices for each one.

Scenarios

A collection of common problems that you can face in your work. From extracting a microservice to how to apply these patterns to existing projects.

Principles

Each rule is a concise, self-contained principle that teaches you how to build better Node.js applications. They are straight to the point without unnecessary explanations and noise. Reading them in order helps, but you can use the book as a reference and hop from principle to principle.

Don't
// Avoid handlers with many responsibilities
const handler = async (req, res) => {
const { name, email } = req.body
if (!isValidName(name)) {
return res.status(httpStatus.BAD_REQUEST).send()
}
if (!isValidEmail(email)) {
return res.status(httpStatus.BAD_REQUEST).send()
}
await queryBuilder('user').insert({ name, email })
if (!isPromotionalPeriod()) {
const promotionalCode = await queryBuilder
.select('name')
.from('promotional_codes')
.where({ target: 'new_joiners' })
transport.sendMail({
// ...
})
}
return res.status(httpStatus.CREATED).send(user)
}
Do
// Handlers should only handle HTTP logic
const handler = async (req, res) => {
const { name, email } = req.body
try {
const user = userService.register(name, email)
return res.status(httpStatus.CREATED).send(user)
} catch (err) {
return res
.status(httpStatus.INTERNAL_SERVER_ERROR)
.send()
}
}

Evergreen Knowledge

The JS ecosystem is constantly changing. Libraries come and go, tools evolve and best practices change. That's why I've only focused on the timeless principles you can apply to any project for years to come.

It describes the fundamental software design concepts that will help you build maintainable applications. Whether you use Express, Fastify, Hapi, or the next big framework - these principles will still apply.

Get the book

You buy me lunch and I tell you everything I know about Node & Express.

$19

eBook

  • All 6 chapters
  • 125+ rules
  • 190 pages
  • Evergreen knowledge

Not sure?

I believe that basic knowledge should be public and accessible so I have uploaded around a third of the book for free on my personal blog. It's been read by over 20K people. You can take a look right now, no email required.

You can see what others had to say about it on Hacker News, the Bytes newsletter, the JS Weekly newsletter, and the Node Weekly newsletter.

Read the FREE version

(no email or credit card required)

About the author

Alexander Kondov

Alexander Kondov

I'm a software engineer by day, writer by night and Dungeons & Dragons enthusiast in between.

I started working with Node because I wanted to use the same language in the browser and on the server. Since then I've become passionate about this technology and I've used it in both startups and large corporations. Node's future is bright and I want to help others learn the best practices around it.

My aim is to pass down what I've learned about architecture and software design through my books. Tao of Node is the second in a series that started with Tao of React.

FAQ