Skip to content
engineering workbench.by StudyPort Academy
All projects
Beginner45 min

Notes API

Build a small notes : one route, then full CRUD on an in-memory MongoDB, then reject empty titles on create and update.

ExpressCRUDMongoDBValidation

YOUR BUILD CHECKLIST

  1. Export an Express app with GET /notes returning [].
  2. Back the notes with MongoDB and add POST, PATCH, and DELETE.
  3. Reject blank titles on create and update with 400.

STAGE BRIEF

1. First route

Uses Why a framework, Routing

Export an Express app. GET /notes should return an empty JSON array. No database yet.

Open the related lesson

YOUR APP

Work in one file. When you move to the next stage, this code stays. Each Run still fires one request (or one stdout capture) against a fresh database when MongoDB is involved.

GET /notes

Project mode: your code carries into the next stage. Each Run is still one request.

3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.

Solution walkthrough

Each stage has a finished file for that point in the project. Open it when you are stuck. Loading a starter or a solution is your choice; the editor does not overwrite your work unless you ask.

1. First route

Uses Why a framework, Routing

Export an Express app. GET /notes should return an empty JSON array. No database yet.

2. CRUD on MongoDB

Uses CRUD operations, Connecting Express to MongoDB

Connect once, store notes in a collection, and support list, create, update, and delete.

3. Required title

Uses Never trust client input

POST and PATCH must reject a missing or blank title with 400 before writing.

Make it your own

The original works. These are your next experiments.

  • Optional: add a done boolean and PATCH it without replacing the title.
  • Optional: return 404 when PATCH targets a missing id.
Open a fresh playground