Add todo list api project

feat/projects-list
Kamran Ahmed 4 months ago
parent aab3322c1e
commit 3543cd69f1
  1. 1
      src/components/Projects/ProjectCard.tsx
  2. 39
      src/data/projects/blogging-platform-api.md
  3. 204
      src/data/projects/todo-list-api.md

@ -23,7 +23,6 @@ export function ProjectCard(props: ProjectCardProps) {
<a <a
href={`/projects/${id}`} href={`/projects/${id}`}
className="flex flex-col rounded-md border bg-white p-3 transition-colors hover:border-gray-300 hover:bg-gray-50" className="flex flex-col rounded-md border bg-white p-3 transition-colors hover:border-gray-300 hover:bg-gray-50"
target="_blank"
> >
<span className="flex justify-between gap-1.5"> <span className="flex justify-between gap-1.5">
<Badge <Badge

@ -20,7 +20,11 @@ roadmapIds:
- 'backend' - 'backend'
--- ---
You are required to create a simple RESTful API with basic CRUD operations for a personal blogging platform. CRUD stands for Create, Read, Update, and Delete. The goals of this project are to help you: You are required to create a simple RESTful API with basic CRUD operations for a personal blogging platform. CRUD stands for Create, Read, Update, and Delete.
## Goals
The goals of this project are to help you:
- Understand what the RESTful APIs are including best practices and conventions - Understand what the RESTful APIs are including best practices and conventions
- Learn how to create a RESTful API - Learn how to create a RESTful API
@ -29,19 +33,25 @@ You are required to create a simple RESTful API with basic CRUD operations for a
- Learn how to perform CRUD operations using an API - Learn how to perform CRUD operations using an API
- Learn how to work with databases - Learn how to work with databases
## Constraints ## Requirements
- You can use any programming language and framework of your choice You should create a RESTful API for a personal blogging platform. The API should allow users to perform the following operations:
- You can use any database of your choice (SQL or NoSQL)
- You can use any libraries for validation and error handling
- There is no frontend required for this project since you are building an API
- You can use any API testing tool like Postman, Insomnia, or cURL to test your API
## Requirements - Create a new blog post
- Update an existing blog post
- Delete an existing blog post
- Get a single blog post
- Get all blog posts
- Filter blog posts by a search term
Each blog post should have the following fields: Given below are the details for each API operation.
```json ### Create Blog Post
Create a new blog post using the `POST` method
```plaintext
POST /posts
{ {
"title": "My First Blog Post", "title": "My First Blog Post",
"content": "This is the content of my first blog post.", "content": "This is the content of my first blog post.",
@ -50,14 +60,9 @@ Each blog post should have the following fields:
} }
``` ```
The API should have the following endpoints: Each blog post should have the following fields:
### Create Blog Post
Create a new blog post using the `POST` method
```plaintext ```json
POST /posts
{ {
"title": "My First Blog Post", "title": "My First Blog Post",
"content": "This is the content of my first blog post.", "content": "This is the content of my first blog post.",

@ -0,0 +1,204 @@
---
title: 'Todo List API'
description: 'Build a RESTful API to allow users to manage their to-do list.'
isNew: false
sort: 7
difficulty: 'beginner'
nature: 'API'
skills:
- 'RESTful API'
- 'Database'
- 'CRUD Operations'
- 'Data Modeling'
- 'Authentication'
seo:
title: 'Todo List API Project Idea'
description: 'Build a RESTful API to allow users to manage their to-do list.'
keywords:
- 'todo list api'
- 'backend project idea'
roadmapIds:
- 'backend'
---
In this project you are required to develop a RESTful API to allow users to manage their to-do list. The previous backend projects have only focused on the CRUD operations, but this project will require you to implement user authentication as well.
## Goals
The skills you will learn from this project include:
- User authentication
- Schema design and Databases
- RESTful API design
- CRUD operations
- Error handling
- Security
## Requirements
You are required to develop a RESTful API with following endpoints
- User registration to create a new user
- Login endpoint to authenticate the user and generate a token
- CRUD operations for managing the to-do list
- Implement user authentication to allow only authorized users to access the to-do list
- Implement error handling and security measures
- Use a database to store the user and to-do list data (you can use any database of your choice)
- Implement proper data validation
- Implement pagination and filtering for the to-do list
Given below is a list of the endpoints and the details of the request and response:
### User Registration
Register a new user using the following request:
```
POST /register
{
"name": "John Doe",
"email": "john@doe.com"
"password": "password"
}
```
This will validate the given details, make sure the email is unique and store the user details in the database. Make sure to hash the password before storing it in the database. Respond with a token that can be used for authentication if the registration is successful.
```json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
}
```
The token can either be a JWT token or a random string that can be used for authentication. We leave it up to you to decide the implementation details.
### User Login
Authenticate the user using the following request:
```
POST /login
{
"email": "john@doe.com",
"password": "password"
}
```
This will validate the given email and password, and respond with a token if the authentication is successful.
```json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
}
```
### Create a To-Do Item
Create a new to-do item using the following request:
```
POST /todos
{
"title": "Buy groceries",
"description": "Buy milk, eggs, and bread"
}
```
User must send the token received from the login endpoint in the header to authenticate the request. You can use the `Authorization` header with the token as the value. In case the token is missing or invalid, respond with an error and status code 401.
```json
{
"message": "Unauthorized"
}
```
Upon successful creation of the to-do item, respond with the details of the created item.
```json
{
"id": 1,
"title": "Buy groceries",
"description": "Buy milk, eggs, and bread"
}
```
### Update a To-Do Item
Update an existing to-do item using the following request:
```
PUT /todos/1
{
"title": "Buy groceries",
"description": "Buy milk, eggs, bread, and cheese"
}
```
Just like the create todo endpoint, user must send the token received. Also make sure to validate the user has the permission to update the to-do item i.e. the user is the creator of todo item that they are updating. Respond with an error and status code `403` if the user is not authorized to update the item.
```json
{
"message": "Forbidden"
}
```
Upon successful update of the to-do item, respond with the updated details of the item.
```json
{
"id": 1,
"title": "Buy groceries",
"description": "Buy milk, eggs, bread, and cheese"
}
```
### Delete a To-Do Item
Delete an existing to-do item using the following request:
```
DELETE /todos/1
```
User must be authenticated and authorized to delete the to-do item. Upon successful deletion, respond with the status code `204`.
### Get To-Do Items
Get the list of to-do items using the following request:
```
GET /todos?page=1&limit=10
```
User must be authenticated to access the tasks and the response should be paginated. Respond with the list of to-do items along with the pagination details.
```json
{
"data": [
{
"id": 1,
"title": "Buy groceries",
"description": "Buy milk, eggs, bread"
},
{
"id": 2,
"title": "Pay bills",
"description": "Pay electricity and water bills"
}
],
"page": 1,
"limit": 10,
"total": 2
}
```
## Bonus
- Implement filtering and sorting for the to-do list
- Implement unit tests for the API
- Implement rate limiting and throttling for the API
- Implement refresh token mechanism for the authentication
<hr />
This project will help you understand how to design and implement a RESTful API with user authentication. You will also learn how to work with databases, handle errors, and implement security measures.
Loading…
Cancel
Save