codex-lv4-may-2025

Server Mini-Project: CRUD API in Memory

Build a RESTful Express API that implements core CRUD operations using in-memory data storage. This project consolidates everything you’ve learned about Express routes, HTTP status codes, JSON responses, and error handling.

Focus on just ONE resource for this project—choose something you’re interested in like cats, baseball-cards, videos, or any other single collection. This keeps the scope manageable while you master the fundamentals.


📚 Instructions

📖 Start Here: Review the server lesson guides (Parts 1-5) to understand Express fundamentals, route handling, and testing patterns.

⚠️ Important: Please change “items” to a resource of your choosing throughout this project. Examples: cats, baseball-cards, videos, books, pokemon, or any other collection you’re interested in. This makes your API more personal and helps you think about real-world use cases.

Additional Resources:


✅ Requirements

Your Express API must include:

  1. Core CRUD Operations
    • GET /items - Return all items (status 200)
    • POST /items - Create a new item (status 201)
    • GET /items/:id OR DELETE /items/:id - Retrieve or remove a specific item
    • Proper JSON responses for all endpoints
    • Note: Replace “items” with your chosen resource name (e.g., /cats, /baseball-cards, /videos)
  2. Error Handling
    • Return 404 with JSON error body when item not found: { "error": "message" }
    • Return 400 with JSON error body for invalid input
    • Consistent error response format across all endpoints
  3. Data Management
    • Use in-memory array to store items
    • Generate unique IDs for each item (use crypto.randomUUID())
    • Seed initial data with at least 2-3 sample items
  4. Code Organization
    • Export Express app for testing
    • Clean, readable code structure
    • Meaningful variable and function names
    • Comments explaining key sections
  5. Testing (Optional but Recommended)
    • Set up Vitest with Supertest
    • Write at least 3 test cases covering happy paths and error cases
    • Run tests with npm run test
  6. Documentation
    • README.md with setup instructions
    • Description of endpoints and their behaviors
    • Example requests/responses
    • List of technologies used

🎓 Deliverable

Submit: GitHub repository URL containing:

Before submitting, verify:


📝 Project Phases

Phase 1: Setup & Basic Routes

Key Terms

Phase 2: Create Operation

Key Terms

Phase 3: Read/Delete by ID

Key Terms

Phase 4: Error Handling & Polish

Key Terms

Phase 5: Testing (Optional)


🆘 Need Help?


📊 Rubric (100 pts)


Good luck building your API! 🚀✨


This mini-project consolidates concepts from Week 1 server lessons and prepares you for database integration in future weeks.