Eggy Dev DocsEggy Dev Docs

Welcome

Build a simple REST API using NestJS and MongoDB.

Overview

Welcome! In this tutorial you will build a simple Task API using NestJS and MongoDB. By the end you will be able to:

  • Scaffold a NestJS project and connect it to MongoDB
  • Define a data model using @nestjs/mongoose
  • Implement CRUD (Create, Read, Update, Delete) endpoints
  • Test your API with curl, HTTPie, or Postman

Tutorial flow

  1. Foundations – learn npm basics, install tooling, and inspect the scaffold
  2. Environment & Configuration – understand environment variables and wire MongoDB
  3. Data Modeling – define the Task schema plus DTOs with Zod validation
  4. CRUD Implementation – build the service layer and expose controllers
  5. Testing & Debugging – send API requests and troubleshoot common issues
  6. Next Steps – explore advanced improvements and deployment tips

If you’re brand new to backends, read each page in order and copy the commands exactly. If something fails, the troubleshooting tips in each section should help you recover quickly.

Version control workflow

  • After Chapter 1’s setup, initialize a Git repository, create the first commit, and push it to a new GitHub repository so you have a clean main branch to build from.
  • Beginning with Chapter 2, create a feature branch for each chunk of work (for example, feature/environment-config), commit as you go, and push the branch to GitHub.
  • Open a pull request targeting main, request a teammate review, and when the changes are approved, merge with Squash and merge so the branch becomes a single, tidy commit on main.