Lab · Backend Development
Lab: your first Express server
The brief
Install Node.js and Express on your own computer and build the Kirana API: a health check, a product lookup with a path parameter and a 404, and a POST that reads JSON and answers 201. You test each part with curl, the way backend developers do.
Why it matters
Node.js with Express runs the backends of thousands of Indian startups and agencies. Every backend job starts with this loop: write a route, start the server, hit it with curl or Postman, read the status and the JSON. Being fast at it is the most basic backend skill.
Skills you practise
- node and npm
- npm init and npm install
- express(), app.get and app.post
- req.params and res.status
- express.json() middleware
- environment variables (PORT)
- testing with curl
You need
- Node.js 20 or newer (the LTS version from nodejs.org)
- A terminal: Terminal on macOS/Linux, or PowerShell on Windows 10/11 (type curl.exe there, because curl is a different command in PowerShell)
- VS Code or any code editor
What you will have at the end
A kirana-api folder with package.json and server.js: a running Express API with a health check, a lookup with 404 and a validated POST.
How it is marked (rubric, 100 points)
| Everything runsEvery pasted output passes and the checklists are honestly ticked. | 45 |
|---|---|
| Right status codes200 for reads, 201 with Location for creates, 400 for bad input, 404 for missing items. | 20 |
| Good habitsPORT from the environment, node_modules ignored, input validated before it is stored. | 20 |
| Can explainYou can explain what middleware is and why express.json() must come before the routes. | 15 |
0/5 steps done
Step 1 of 5
Check Node.js and npm
node -v shows version 20 or newer, and npm -v shows a version number.
Node.js runs JavaScript outside the browser, and npm installs packages like Express. Install the LTS (long-term support) version from nodejs.org; it is the one companies use. Older versions such as 16 and 18 no longer get security fixes, and new packages refuse to install on them.
$ node -v; npm -vYour notes: server.js
Write down each command you ran. It goes into your project summary.