How Do Bootcamp Students Build Their First REST API?

For Bootcamp students learning backend development · Based on Traversy Media Node/Express REST API Builder

// TL;DR

If you're in a coding bootcamp and need to build your first backend project, this skill gives you a repeatable recipe. You'll scaffold a Node.js/Express REST API with five CRUD endpoints, separate routes from controllers for clean architecture, and test everything in Postman. It covers the exact mistakes bootcamp students make — double paths, undefined req.body, const vs let arrays — so you avoid hours of debugging. Use it for your capstone project or any assignment requiring a working API.

Why do bootcamp students struggle with their first REST API?

Most bootcamp curricula jump from frontend JavaScript to backend Node.js without explicitly teaching project structure. Students end up with a 300-line index.js file mixing server setup, route definitions, and business logic. The Traversy Media Node/Express REST API Builder solves this by enforcing a clear rule: routes go in /routes, logic goes in /controllers, and index.js only handles configuration.

This separation isn't just about cleanliness. When your instructor or peer reviews your code, they can immediately find any endpoint's logic by navigating to the controller file. During debugging, you know exactly which file to check.

How do you set up a project that won't break during your demo?

Start with `npm init -y` in an empty folder. Add `"type": "module"` to package.json so you can use import/export syntax. Install your dependencies:

```bash

npm install express body-parser

npm install --save-dev nodemon

```

Add a start script: `"start": "nodemon index.js"`. This means you run `npm start` once and never manually restart the server again. During a live demo, this prevents the classic mistake of forgetting to restart after a code change.

In index.js, import Express and body-parser, create the app, register `bodyParser.json()` middleware before any routes, and call `app.listen(5000)`. Use port 5000 to avoid clashing with a React frontend on 3000.

What's the correct file structure for a bootcamp API project?

Your project should look like this:

```

project-name/

├── index.js

├── routes/

│ └── users.js

├── controllers/

│ └── users.js

└── package.json

```

The routes file uses `express.Router()` and contains five one-liner route registrations — nothing else. The controllers file exports five handler functions: `getUsers`, `getUser`, `createUser`, `deleteUser`, and `updateUser`. Each function receives `(req, res)` and contains all the logic.

Critical rule: when you mount the router in index.js with `app.use('/users', usersRoutes)`, the paths inside the routes file must start with just `/` — not `/users`. Express concatenates the mount path with the route path. Writing `/users` in both places creates `/users/users`.

How do you implement all five CRUD operations without getting confused?

Follow this order:

1. GET all — Return the entire array with `res.send(users)`. This is your sanity check.

2. POST — Read `req.body`, spread it into a new object with a `uuidv4()` ID, push to the array, and confirm.

3. GET one — Extract `req.params.id`, use `Array.find()`, return the match.

4. DELETE — Extract ID, reassign the array with `Array.filter()`. Remember: the array must be declared with `let`, not `const`.

5. PATCH — Extract ID, find the record, conditionally update only the fields present in `req.body`. Never overwrite the ID.

Test each operation in Postman before moving to the next. For POST and PATCH, set the body to raw JSON. Browsers can only make GET requests — you cannot test POST, PATCH, or DELETE from the URL bar.

What should you do after your API is working?

Swap the in-memory array for a real database. The beauty of route/controller separation is that only the controller file changes. Your routes file and index.js remain untouched. Connect PostgreSQL using the `pg` package, replace `users.push()` with an INSERT query, and replace `users.find()` with a SELECT WHERE query. This is the exact progression most bootcamp capstone projects require.

Start building now: create your project folder, run `npm init -y`, and follow the 12-step workflow.

// FREQUENTLY ASKED QUESTIONS

What's the best first backend project for a bootcamp student?

A CRUD REST API for a simple resource like users or products is the best starting project. It teaches HTTP methods, routing, middleware, and project structure — all foundational backend skills. The Traversy Media Node/Express pattern gives you exactly five endpoints to implement, which is manageable in a single sprint while covering all core concepts.

Do I need to know databases to build this API?

No. This pattern starts with an in-memory JavaScript array as a mock database. You can build and test all five CRUD endpoints without touching PostgreSQL or MongoDB. Once the API works, you swap the array operations for real database queries — only the controller file changes. This lets you learn API structure and database integration as separate steps.

Why does my bootcamp instructor want routes and controllers separated?

Separation of concerns is a core software engineering principle. When routes only define paths and controllers only contain logic, each file has one responsibility. This makes code easier to read during reviews, easier to debug when something breaks, and easier to extend when adding new features. Most professional codebases enforce this pattern.