|
1 |
| -<p align="center"> |
2 |
| - <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a> |
3 |
| -</p> |
4 |
| - |
5 |
| -[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 |
6 |
| -[circleci-url]: https://circleci.com/gh/nestjs/nest |
7 |
| - |
8 |
| - <p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p> |
9 |
| - <p align="center"> |
10 |
| -<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a> |
11 |
| -<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a> |
12 |
| -<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a> |
13 |
| -<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a> |
14 |
| -<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a> |
15 |
| -<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a> |
16 |
| -<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a> |
17 |
| - <a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a> |
18 |
| - <a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a> |
19 |
| - <a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a> |
20 |
| -</p> |
21 |
| - <!--[](https://opencollective.com/nest#backer) |
22 |
| - [](https://opencollective.com/nest#sponsor)--> |
23 |
| - |
24 |
| -## Description |
25 |
| - |
26 |
| -[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. |
27 |
| - |
28 |
| -## Project setup |
| 1 | +# NestJS Todo API |
29 | 2 |
|
30 |
| -```bash |
31 |
| -$ npm install |
32 |
| -``` |
| 3 | +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. |
33 | 4 |
|
34 |
| -## Compile and run the project |
| 5 | + |
35 | 6 |
|
36 |
| -```bash |
37 |
| -# development |
38 |
| -$ npm run start |
| 7 | +--- |
39 | 8 |
|
40 |
| -# watch mode |
41 |
| -$ npm run start:dev |
| 9 | +## Features |
42 | 10 |
|
43 |
| -# production mode |
44 |
| -$ npm run start:prod |
45 |
| -``` |
| 11 | +- **JWT-based Authentication**: Secure user registration and login endpoints. |
| 12 | +- **Protected Routes**: All todo-related endpoints require a valid access token. |
| 13 | +- **Full CRUD Functionality**: Create, Read, Update, and Delete operations for user-specific todos. |
| 14 | +- **Validation**: DTO-based validation for all incoming request bodies using `class-validator`. |
| 15 | +- **API Documentation**: Auto-generated and detailed API documentation with Swagger. |
46 | 16 |
|
47 |
| -## Run tests |
| 17 | +--- |
48 | 18 |
|
49 |
| -```bash |
50 |
| -# unit tests |
51 |
| -$ npm run test |
| 19 | +## Tech Stack |
52 | 20 |
|
53 |
| -# e2e tests |
54 |
| -$ npm run test:e2e |
| 21 | +- **Framework**: [NestJS](https://nestjs.com/) |
| 22 | +- **Language**: [TypeScript](https://www.typescriptlang.org/) |
| 23 | +- **ORM**: [Prisma](https://www.prisma.io/) |
| 24 | +- **Database**: [MongoDB](https://www.mongodb.com/) |
| 25 | +- **Authentication**: [JWT](https://jwt.io/) with [Passport.js](http://www.passportjs.org/) |
| 26 | +- **Validation**: [class-validator](https://github.com/typestack/class-validator) & [class-transformer](https://github.com/typestack/class-transformer) |
55 | 27 |
|
56 |
| -# test coverage |
57 |
| -$ npm run test:cov |
58 |
| -``` |
| 28 | +--- |
59 | 29 |
|
60 |
| -## Deployment |
| 30 | +## Getting Started |
61 | 31 |
|
62 |
| -When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information. |
| 32 | +Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes. |
63 | 33 |
|
64 |
| -If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps: |
| 34 | +### Prerequisites |
65 | 35 |
|
66 |
| -```bash |
67 |
| -$ npm install -g @nestjs/mau |
68 |
| -$ mau deploy |
69 |
| -``` |
| 36 | +- [Node.js](https://nodejs.org/en/) (v18 or later recommended) |
| 37 | +- [npm](https://www.npmjs.com/) |
| 38 | +- A running [MongoDB](https://www.mongodb.com/try/download/community) instance (must be running as a replica set for Prisma transactions). |
70 | 39 |
|
71 |
| -With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure. |
| 40 | +### Installation & Setup |
72 | 41 |
|
73 |
| -## Resources |
| 42 | +1. **Clone the repository:** |
| 43 | + ```bash |
| 44 | + git clone https://github.com/mohammadhasanii/NestTodo-API.git |
| 45 | + ``` |
74 | 46 |
|
75 |
| -Check out a few resources that may come in handy when working with NestJS: |
| 47 | +2. **Navigate to the project directory:** |
| 48 | + ```bash |
| 49 | + cd NestTodo-API |
| 50 | + ``` |
76 | 51 |
|
77 |
| -- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework. |
78 |
| -- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy). |
79 |
| -- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/). |
80 |
| -- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks. |
81 |
| -- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com). |
82 |
| -- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com). |
83 |
| -- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs). |
84 |
| -- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com). |
| 52 | +3. **Install dependencies:** |
| 53 | + ```bash |
| 54 | + npm install |
| 55 | + ``` |
85 | 56 |
|
86 |
| -## Support |
| 57 | +4. **Configure environment variables:** |
| 58 | + Create a `.env` file in the root of the project by copying the example file: |
| 59 | + ```bash |
| 60 | + cp .env.example .env |
| 61 | + ``` |
| 62 | + Then, update the `.env` file with your specific configuration. |
87 | 63 |
|
88 |
| -Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). |
| 64 | + ```env |
| 65 | + # The connection string for your MongoDB instance. |
| 66 | + # Note: ?replicaSet=rs0 is required if your MongoDB is running as a replica set. |
| 67 | + DATABASE_URL="mongodb://localhost:27017/db?replicaSet=rs0" |
89 | 68 |
|
90 |
| -## Stay in touch |
| 69 | + # A strong, secret key for signing JWTs |
| 70 | + JWT_SECRET="YOUR_SUPER_SECRET_KEY" |
| 71 | + JWT_EXPIRES_IN="1h" |
| 72 | + ``` |
91 | 73 |
|
92 |
| -- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec) |
93 |
| -- Website - [https://nestjs.com](https://nestjs.com/) |
94 |
| -- Twitter - [@nestframework](https://twitter.com/nestframework) |
| 74 | +### Running the Application |
95 | 75 |
|
96 |
| -## License |
| 76 | +To run the application in development mode with hot-reloading: |
97 | 77 |
|
98 |
| -Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE). |
| 78 | +```bash |
| 79 | +npm run start:dev |
0 commit comments