Home Books Browse by series All books Agentic AI Engineering Series From Spreadsheets to Code Data Science Foundations Series The Applied Python Library Rust in Practice Cybersecurity for Absolute Beginners Go For Absolute Beginners The TypeScript for Absolute Beginners AI-Powered Excel Automation Kotlin For Absolute Beginners Blog Download Data About Us Contact Browse Library →
TypeScript for Backend APIs cover
Book 3 of the The TypeScript for Absolute Beginners series

TypeScript for Backend APIs

Node.js Services That Don't Lie to You

by Sable Marchetti

Kindle
$9.99 $4.99 -50%
Paperback
$29.80 $18.99 -36%

TypeScript for Backend APIs

Node.js Services That Don't Lie to You

Build a reliable, type-safe backend from the database to the API response.

A backend is more than a collection of routes. It is a system of contracts between clients, application logic, databases, authentication systems, and external data. When those contracts are implicit, small changes can quickly become production bugs.

TypeScript for Backend APIs takes the TypeScript skills developed in the first two books and applies them to modern backend development with Node.js.

You will build contactly-api, the REST API that powers the frontend application from Book Two. Starting with a single Fastify route, the project grows into a complete backend with typed requests and responses, runtime validation with Zod, database persistence with Drizzle ORM and PostgreSQL, authentication with JWT, authorization, typed error handling, testing, configuration, logging, observability, OpenAPI documentation, and deployment to Railway.

The book does not assume previous backend experience. Fastify, Zod, Drizzle, PostgreSQL, and the required SQL concepts are introduced as they become necessary, allowing you to learn backend development while building a real application.

The central idea is simple: make the backend's contracts explicit and let TypeScript help enforce them throughout the system.

Inside the Book

  • Why TypeScript Changes Backend Development — Understand why type safety matters at the API boundary and throughout the backend.
  • Your First Fastify Server — Create your first typed Node.js API server.
  • Request and Response Types — Define clear contracts for incoming requests and outgoing responses.
  • Validation with Zod at the Boundary — Validate untrusted external data before it enters your application.
  • Drizzle ORM and the Database Schema — Define a PostgreSQL database schema directly in TypeScript.
  • Typed Queries and Mutations — Build database operations with precise inferred types.
  • Relations, Joins, and the N+1 Problem — Work with related data while avoiding common database performance problems.
  • Migrations and Schema Evolution — Change your database safely as your application evolves.
  • Authentication with JWT — Implement authentication and typed user identity.
  • Authorization and Route Guards — Control what authenticated users are allowed to access.
  • Error Handling and the Error Hierarchy — Create predictable, structured API errors instead of silent failures.
  • Testing the API — Test your backend with unit and HTTP integration tests.
  • Environment, Configuration, and Secrets — Manage configuration safely across development and production.
  • Logging, Observability, and OpenAPI — Make your API easier to monitor, debug, and document.
  • Capstone: Deploy Contactly-API — Bring the complete backend together and deploy it to Railway.

What You Will Learn

  • How TypeScript improves Node.js backend development
  • How to build typed APIs with Fastify
  • How to type HTTP requests, parameters, and responses
  • How to validate untrusted data with Zod
  • How to design PostgreSQL schemas with Drizzle ORM
  • How to write typed database queries and mutations
  • How to work with relations, joins, and migrations
  • How to implement JWT authentication
  • How to protect resources with authorization and route guards
  • How to design a typed error hierarchy
  • How to test REST APIs with Vitest
  • How to manage environment variables and secrets
  • How to add logging, observability, and OpenAPI documentation
  • How to deploy a complete TypeScript backend

From Database to API Response

The book follows a single request through the entire backend architecture. Data arrives at the API, is validated with Zod, reaches a typed route handler, passes through authentication and business logic, is persisted through Drizzle and PostgreSQL, and finally returns as a typed response.

This makes the role of TypeScript visible at every important boundary and shows how a well-designed type system can connect the different layers of a real backend application.

The backend also shares the same Contact domain model established in Book One and used by the frontend in Book Two. The result is a natural continuation of the series: the CLI becomes the web application, the web application becomes a full-stack system, and TypeScript connects the pieces.

Book One teaches the language. Book Two builds the frontend. Book Three completes the backend.

Together, they form a practical path from TypeScript fundamentals to full-stack TypeScript development.

Pages323
ISBNB0HFQ9G714
PublisherWaskey Press
FormatPaperback & Kindle
Share this book

Reader reviews

No reviews yet — be the first to share your thoughts.

Leave a review

Share your experience with this book. Reviews are moderated before publication to keep discussions useful and respectful.

Reviews are moderated and appear once approved.

You might also like

View all books →
Buy on Amazon →