C Module Server Side Final
C Module Server Side Final
INTRODUCTION
In this module, you are asked to create a social media website called “Facegram” where in the
website a user can see other user's posts by following the user. Users can also register as a private
account so other users who are not following could not see posts. The detailed description and tools
that you can use will be described below.
Endpoint /api/v1/auth/register
Method POST
Request Body:
full_name (required)
bio (required, max 100 chars)
username (required, min 3 chars, unique, only alphanumeric, dot “.” or underscore “_”
allowed)
LKS PROVINSI WEB TECHNOLOGIES 2024
b. Login
Endpoint /api/v1/auth/login
Method POST
Request Body:
username
password
c. Logout
Endpoint /api/v1/auth/logout
Method POST
Request Headers:
Authorization: Bearer <token>
Body:
username
password
2. Post
a. Create new post
Endpoint /api/v1/posts
Method POST
Request Headers:
Authorization: Bearer <token>
Content-type: multipart/form-data
Body:
caption (required)
attachments (required, array of image files jpg, jpeg, webp, png or gif)
Response Body:
{
Invalid Field "message": "Invalid field",
LKS PROVINSI WEB TECHNOLOGIES 2024
"errors": {
"caption": [
"The caption field is required."
],
"attachments.0": [
"The attachments.0 field must be a file of type: png, jpg,
jpeg, webp."
]
}
}
b. Delete post
Endpoint /api/v1/posts/:id
Method DELETE
Request Headers:
Authorization: Bearer <token>
c. Get posts
Endpoint /api/v1/posts
Method GET
Request Headers:
Authorization: Bearer <token>
Params:
page (integer, minimum 0 and default 0)
size (integer, minimum 1 and default 10)
3. Following
a. Follow a user
Endpoint /api/v1/users/:username/follow
Method POST
Request Headers:
Authorization: Bearer <token>
b. Unfollow a user
Endpoint /api/v1/users/:username/unfollow
Method DELETE
Request Headers:
Authorization: Bearer <token>
Response
HTTP Status Code: 204
Success
Endpoint /api/v1/following
Method GET
Request Headers:
Authorization: Bearer <token>
4. Followers
a. Accept follow request
Endpoint /api/v1/users/:username/accept
Method PUT
Request Headers:
Authorization: Bearer <token>
Endpoint /api/v1/users/:username/followers
Method GET
Request Headers:
Authorization: Bearer <token>
5. User
a. Get users
Endpoint /api/v1/users
Method GET
Description Get all users that are not followed by logged in users. Logged in users should
be hidden in the list.
Request Headers:
Authorization: Bearer <token>
Endpoint /api/v1/users/:username
Method GET
Description For users to get detailed user data. Field posts should be hidden if the user is a
private user and the follow status is not following or is requested.
Request Headers:
Authorization: Bearer <token>
Register - If user logged in, the page will be redirected to own user profile page
- User can register account
- If register fails, display all of errors message
- If logged in user try to access this page, the page should be
redirected to own user profile page
Login - If user logged in, the page will be redirected to own user profile page
- User can login with existing credentials
- If login fails, display all of errors message
- If logged in user try to access this page, the page should be redirected
to own user profile page
Homepage - If user not logged in, the page will be redirected to login page
User information:
- See profile (full_name, username, bio)
- See posts list and count
- See followers list and count
- See following list and count
Follow/unfollow:
- User can follow another user
- User can unfollow a followed user
Posts section:
- Display user’s posts where the visited user is not a private account or
following account
- Users can delete their posts
- Display “The account is private” if logged in user is not following the
visited private user profile page
LKS PROVINSI WEB TECHNOLOGIES 2024
Create new - If user not logged in, the page will be redirected to login page
post - User can create new post with following fields:
- caption (text, required)
- attachments (file, can attach multiple files)
- If create new post fails, display all of errors message
ER DIAGRAM
ADDITIONAL EXPLANATION
MEDIA FILES
- Frameworks (laravel, react and vue)
LKS PROVINSI WEB TECHNOLOGIES 2024