The API and other necessary services has been set up as a multi-container app. To get the up running locally, the following steps must be performed:
- Install Docker Compose if not already installed. Instructions for your operating system can be found here.
- If running Windows, it is recommended to run Docker Desktop in WSL2 mode. Follow the guide here.
-
Open a new terminal window and change the directory to where the application files have been downloaded
-
Run the following commands:
docker compose build docker compose up -d
-
Run
docker ps
to see a list of all running containers. The following should now be running:- test-app
- test-db
- test-nginx
-
Next, we have to set up the Laravel dependencies and app key. Run the following in the same terminal:
docker compose exec app bash # Install dependancies composer install # Generate the app key and cache app config and settings php artisan key:generate php artisan optimize:clear php artisan optimize # Seed the DB with mock data php artisan migrate:fresh --seed
-
Go to http://localhost:8001/. The Laravel Welcome Page should now be loaded.
There are 4 request groups namely Auth, Posts, Comments, Stats. The request can be found in the PostMan export.
Handles all the authentication logic:
- Register: Registers a new Normal type user
- Login: Logs an exiting user into the system
- Logout: Logs the currently logged-in user out
Handles all the post logic:
- All: Retrieves all posts.
- User does not have to be authenticated for this endpoint.
- User can specify an order_by_occurrence request parameter to sort the posts by the number of occurrences.
- View: Views a specific post.
- Once viewed it will set an environment variable named post_id.
- Create: Creates a new post.
- Once created it will set an environment variable named post_id.
- A content body parameter also needs to be specified. It needs to be between 150 and 1500 characters.
- Like: Likes a post.
- A post_id needs to be specified in the url. By default, it uses the post_id environment variable.
- Flag: Flags a post.
- User needs to be an Admin type user to flag posts.
- A post_id needs to be specified in the url. By default, it uses the post_id environment variable.
Handles all the comment logic:
- All: Retrieves all comments.
- View: Views a specific comment.
- A comment_id needs to be specified in the url. By default, it uses the comment_id environment variable.
- Once viewed it will set the comment_id environment variable.
- Create: Creates a new comment.
- A post_id needs to be specified in the request body. By default, it uses the post_id environment variable
- A content body parameter also needs to be specified. It needs to be between 20 and 150 characters.
- Once created it will set an environment variable named comment_id.
Handles all the stats logic:
- All: Retrieves the post and comments stats grouped by hour.