Developer Foundations line, station 7 of 9
Building APIs with Node.js
Design and build a production-ready REST API with Node.js, TypeScript, NestJS and PostgreSQL.
- 6lessons
- 4 hto read and do
- Intermediatelevel
- 6podcast episodes
- 7checked exercises
Tools you'll use in this course
The lessons open these with a template ready. They work for your own job too, no course needed.
About this course
Every app on your phone talks to an API. This course teaches you to design one that other developers enjoy using and that keeps working when traffic grows and mobile data drops: clear resources and status codes, one error shape, validation on every input, safe database access, authentication and per-shop permissions, background jobs, idempotent order placement, tests against a real database and an OpenAPI contract.
You build the Partner app's ordering API for Mangrove Market's 1,800 partner corner shops, on the same stack Mangrove's own engineers use: NestJS on Node.js and TypeScript, PostgreSQL through Prisma, and Redis for a job queue. Lagoon Digital, the outside agency that builds the Partner app, is your first customer, so every endpoint has to be documented, predictable and safe to call twice on a weak connection.
Each lesson has diagrams, a worked Mangrove example, real code you can run, quick checks, practice tasks (most auto-checked in your browser), flashcards and a podcast episode. The course project is the partner ordering API itself, and the final exam earns a free certificate.
What you will be able to do
- Design REST resources, status codes, one error shape and cursor pagination that clients can rely on
- Build NestJS modules, controllers and services with dependency injection and validation on every input
- Store and query data safely in PostgreSQL through Prisma, with migrations, transactions and no N+1 queries
- Add authentication, role and per-shop permissions, and rate limits that return clear errors
- Move slow work to background jobs and make order placement safe to retry with idempotency keys
- Test the API against a real database in CI and publish an OpenAPI contract with a change policy
Syllabus
6 stops, about 4 h in total. Each stop fills in when you complete the lesson.
Designing an API people can use
Before you write a line of NestJS, you write the contract for the partner ordering API: which resources exist, what each method does, which status codes the Partner app can branch on, one error shape, and pagination that stays correct while 1,800 shops keep ordering.
REST API designStatus codes and errorsPaginationAPI versioning
Your first NestJS service
The partner ordering API from Designing an API people can use now gets real code. This lesson follows one request through NestJS stop by stop, shows how modules and dependency injection keep the code in clean pieces, and makes sure no field reaches your business rules without being checked.
NestJSTypeScriptREST API design
Data with PostgreSQL and Prisma
The partner ordering API stops keeping orders in memory and starts keeping them in PostgreSQL, through Prisma. This lesson shows what the ORM does for you, what it hides from you, and how to write data code that stays correct when two people order for the same shop at the same second.
PostgreSQLPrismaNestJSTypeScript
Who are you and what may you do?
The partner ordering API serves 1,800 shops, about 40 sales reps and Mangrove's admins. Every request must answer three questions in order: who is calling, what may this kind of user do, and is this shop's data theirs. This lesson turns those questions into status codes, tokens, NestJS guards, scoped queries and rate limits.
AuthenticationNestJSREST API designRate limiting
Background jobs and idempotency
A shop owner on weak mobile data taps "Place order", the app times out, and it tries again. This lesson makes that retry safe: the slow work moves to a background job, and the order endpoint remembers each request so the same order sent twice creates one order.
Background jobsREST API designNestJSPrisma
Testing and documenting the API
An API is a promise to the apps that call it. This lesson shows how to prove the promise with tests that run against a real PostgreSQL, and how to write it down as an OpenAPI document that Lagoon Digital can build the Partner app against without guessing.
API testingOpenAPINestJSPostgreSQL
Capstone: Ship the partner ordering API
A realistic project with a rubric and a model answer.
Final exam and certificate
10 questions drawn at random, 70% to pass.
Capstone project
Ship the partner ordering API
Lagoon Digital starts building the next Partner app release in two weeks and needs a real API to build against. Build the ordering API that lets Mangrove's partner corner shops browse their price list, place and track orders, cancel an order before it is picked, and download invoices, in a public GitHub repository with NestJS, PostgreSQL and Prisma. Shop owners like Ravi use it on patchy mobile data, so the app retries, and Mangrove's sales reps place orders for the shops assigned to them. Every error must use one shape, every input must be validated, a shop must never see another shop's orders, the same order sent twice must create one order, and invoice PDFs must be made in a background job. Hand Lagoon Digital an OpenAPI document and a short change policy they can trust.
You will hand in
- A NestJS API with at least eight endpoints over shops, price lists, orders, order lines and invoices, with Prisma migrations and seed data
- Authentication with per-shop and sales-rep permissions, rate limits, and an Idempotency-Key on order creation
- A background job that renders invoice PDFs, with retries and a failed-job alert
- Unit and integration tests that run against a real PostgreSQL in GitHub Actions
- An OpenAPI document, a README for Lagoon Digital and a short changelog and deprecation policy
Check what you know
Already know some of this? Answer 6 quick questions, one from each lesson, and we will mark the lessons you can skim. It takes about 3 minutes and nothing is graded.
Questions
How long does the course take?
About four hours for the six lessons, roughly 30 to 40 minutes each, plus 8 to 15 hours for the project. Most lessons include code you can run on your own laptop.
Why NestJS?
It is the framework Mangrove's platform uses, and it is common in companies that run Node.js on the backend. The design ideas (resources, status codes, validation, permissions, idempotency, tests against a real database) carry over to Express, Fastify, Django, Spring or Go.
What should I take first?
JavaScript Deep Dive and How the Web Works. SQL & Data Modeling helps for the database lesson but is not required, and each lesson links to the earlier lesson it builds on.
Do I need to install PostgreSQL and Redis?
For the project, yes: Docker is the easiest way to run both on your laptop, and GitHub Actions can start PostgreSQL for your tests. The practice exercises inside the lessons run in your browser with nothing to install.
Is the certificate free?
Yes. All lessons, podcasts, exercises, the final exam and the certificate you earn by passing it are free.
Is it really free?
Yes. Every lesson, podcast episode, exercise, quiz, final exam and certificate is free. The labs and their templates for real work are free too. Plus and Premium add every lab challenge, weekly extras and a mentor on top, and they never lock the tools or the courses.
How does the final exam work?
You get 15 questions drawn at random from a larger bank. You need 70% to pass. If you do not pass, you can try again after 24 hours. The exam is graded on the server and you never see the answer key.