This guide will walk you through the steps needed to get this project up and running on your local machine.
Before you begin, ensure you have the following installed:
- Docker
- Docker Compose
Build and start the containers:
docker-compose up -d --build
docker-compose exec app sh
composer install
Set up the database:
bin/cake migrations migrate
The application should now be accessible at http://localhost:34251
Use JWT authentication for the authentication function. API to obtain a token:
curl --location --request POST 'http://localhost:34251/users/login.json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'email=minhnd1@gmail.com' \
--data-urlencode 'password=123qweASD'
Add bearer token to APIs requiring authentication.
TODO: pls summarize how to check "Authentication" bahavior
Article Management includes functionalities such as add, edit, and delete. The functionalities to view the list and details of articles do not require authentication.
curl --location --request GET 'http://localhost:34251/articles.json'
curl --location --request GET 'http://localhost:34251/articles/2.json'
curl --location --request POST 'http://localhost:34251/articles.json' \
--header 'Authorization: xxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"user_id": 1,
"title": "test",
"body": "today, I'\''m working in haposoft.",
"created_at": "2024-02-03T00:00:00",
"updated_at": "2024-02-26T00:00:00"
}'
curl --location --request PUT 'http://localhost:34251/articles/2.json' \
--header 'Content-Type: application/json' \
--data-raw '{
"user_id": 1,
"title": "test",
"body": "today, I'\''m working in haposoft.",
"created_at": "2024-02-03T00:00:00",
"updated_at": "2024-02-26T00:00:00"
}'
curl --location --request DELETE 'http://localhost:34251/articles/1.json' \
--header 'Authorization: xxx' \
--header 'Content-Type: application/json' \
TODO: pls summarize how to check "Article Management" bahavior
Create a likes table to establish a relationship between user_id and article_id, ensuring that one article can
only have one like. Add a likes function in the ArticlesController.
curl --location --request POST 'http://localhost:34251/articles/like/2.json' \
--header 'Authorization: xxx' \
In the get list and get detail article functions, add the like_count field to display the number of likes for each article.
TODO: pls summarize how to check "Like Feature" bahavior