A RESTful API for a simple todo list manager, built with NestJS, TypeScript, and Prisma. This project serves as a demonstration of modern backend development practices, including JWT authentication, robust validation, and a clean, modular architecture.
- JWT-based Authentication: Secure user registration and login endpoints.
- Protected Routes: All todo-related endpoints require a valid access token.
- Full CRUD Functionality: Create, Read, Update, and Delete operations for user-specific todos.
- Validation: DTO-based validation for all incoming request bodies using
class-validator
. - API Documentation: Auto-generated and detailed API documentation with Swagger.
- Framework: NestJS
- Language: TypeScript
- ORM: Prisma
- Database: MongoDB
- Authentication: JWT with Passport.js
- Validation: class-validator & class-transformer
Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.
- Node.js (v18 or later recommended)
- npm
- A running MongoDB instance (must be running as a replica set for Prisma transactions).
-
Clone the repository:
git clone https://github.com/mohammadhasanii/NestTodo-API.git
-
Navigate to the project directory:
cd NestTodo-API
-
Install dependencies:
npm install
-
Configure environment variables: Create a
.env
file in the root of the project by copying the example file:cp .env.example .env
Then, update the
.env
file with your specific configuration.# The connection string for your MongoDB instance. # Note: ?replicaSet=rs0 is required if your MongoDB is running as a replica set. DATABASE_URL="mongodb://localhost:27017/db?replicaSet=rs0" # A strong, secret key for signing JWTs JWT_SECRET="YOUR_SUPER_SECRET_KEY" JWT_EXPIRES_IN="1h"
To run the application in development mode with hot-reloading:
npm run start:dev