The colorful notepad project is for you to put the writings that you never had a chance to send to your friends or people around here.
This is a NestJS backend application that provides CRUD APIs for managing notes. It uses Prisma as the ORM for database management and includes rate limiting functionality to protect the API from excessive requests.
- Create, read, update, and delete notes
- Pagination support for retrieving notes
- Rate limiting to prevent abuse and ensure fair usage
- Prisma integration for database management
- Node.js (version X.X.X)
- PostgreSQL database
- Prisma CLI
-
Clone the repository:
git clone https://github.com/your-username/your-repo.git
-
Install the dependencies:
cd your-repo npm install
-
Set up the database:
- Create a new PostgreSQL database
- Update the
DATABASE_URL
in the.env
file with your database connection URL
-
Run the database migrations:
npx prisma migrate dev
-
Start the application:
npm run start
The application will be running at
http://localhost:3000
.
POST /notes
: Create a new noteGET /notes
: Get all notes (supports pagination withskip
andtake
query parameters)GET /notes/:id
: Get a note by IDPUT /notes/:id
: Update a note by IDDELETE /notes/:id
: Delete a note by ID
For detailed information about the request and response formats, please refer to the requests.http
file.
The API endpoints are protected by rate limiting to prevent excessive requests. The default configuration allows a maximum of 10 requests per IP address within a 60-second time window. If a client exceeds the rate limit, they will receive a "Too Many Requests" (HTTP 429) response.
You can customize the rate limiting settings by modifying the ThrottlerModule
configuration in the app.module.ts
file.
The project follows a standard NestJS folder structure:
├── src
│ ├── note
│ │ ├── note.controller.ts
│ │ ├── note.module.ts
│ │ └── note.service.ts
│ ├── prisma
│ │ ├── prisma.service.ts
│ │ └── schema.prisma
│ ├── app.controller.ts
│ ├── app.module.ts
│ ├── app.service.ts
│ └── main.ts
│── prisma
│ ├── prisma.service.ts
│ └── schema.prisma
├── test
│ ├── app.e2e-spec.ts
│ └── jest-e2e.json
├── .env
├── .gitignore
├── nest-cli.json
├── package.json
├── README.md
└── tsconfig.json
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.