Every API you’ve called has a server deciding its answers. Until now, you’ve been the client. In this first course of the Node Servers and REST APIs path, you write the server.
You’ll build it for Mrs. Okafor, the secretary of Hollybank Allotments, a community garden whose plots people rent. Her phone rings every week with the same three questions: which plots are free, how big plot 7 is, and how to join the waiting list. Each question becomes a request that your server answers, so people can ask the board, a small API, instead of her phone. Here’s a first taste of the finished plot board answering two of them:
$ curl -i http://localhost:3000/plots/7
HTTP/1.1 200 OK
{"number":7,"size":500,"holder":"Daniel Price"}
$ curl -i http://localhost:3000/plots/99
HTTP/1.1 404 Not Found
{"error":{"code":"plot_not_found","message":"There's no plot 99.","details":null}}
The headers are left out here. Plot 7 gets a 200 and the plot’s details, and plot 99 gets a 404 that the board chooses.
What You’ll Learn
By the end of this course, you’ll be able to write a server with Node’s node:http module that routes requests by method and path, reads JSON bodies, and answers every request with the right status code and a JSON body.
You’ll get there in four steps:
- A Server That Answers: answer requests.
- Routing Requests: route them by method and path.
- Reading Request Bodies: read the bodies they send.
- Project: The Hollybank Plot Board: build the board from Mrs. Okafor’s brief, and explain it to the AI mentor that’s built into RealJS.
Before You Start
You should be comfortable with:
- Calling APIs with
fetch() - Reading a raw HTTP exchange
- Handling failures with
asyncandawait - Writing strict TypeScript that Node runs directly
You need a current Node LTS (this course uses Node 26), a terminal, and any editor.
How the Course Works
The course has text lessons and short videos, a coding exercise after each section, a project, and a quiz. Follow the lessons on your own computer with the course’s code download. The exercises run in your browser, so there’s nothing to install.
The course has one code download, a ZIP file below this video. Two of its folders get you started:
01-call-server/: the finished plot board, to try out first. You’ll start it withnpm startand send requests to it in the next lesson.02-start-server/starting-project/: the starting project, withpackage.json,tsconfig.json, andplots.json, which you’ll build your own board in.
The other folders hold the board as each lesson leaves it.
Next, in Call a Server You Didn’t Write, you’ll try the finished board.