# API Documentation
API URL : https://rg-km.riegan.my.id/api
Atau bisa gunakan langsung dengan meng-import `API_URL` dari `src/api/config.js`
# Authentication
Untuk dapat melakukan request ke API, diperlukan authentication. Untuk mendapakannya, pengguna dapat melakukan login di https://rg-km.riegan.my.id/auth atau menggunakan function `auth` yang di-import dari `src/api/auth.js`
# Post
## List All Post
List all the post that createf by users
```HTTP
GET /post/list
```
### Response
```TS
{
message: string,
data: [
...,
{
id: string,
title: string,
content: string,
image: string,
createdAt: string,
author: {
id: string,
name: string,
image: string,
},
liked: boolean,
disliked: boolean,
likeCount: number,
dislikeCount: number,
},
...
],
}
```
## Add new post
Add new post to database
```HTTP
POST /post/create
```
### Parameters - `Request Body Parameters`
Name | Type | Description
-----|------|------------
content | `string` | caption of image
image | `File` | image file with mimetype of `'image/jpeg', 'image/png', 'image/gif'`
### RESPONSE
```TS
{
message: string,
data: {
id: string,
authorId: string,
title: string,
content: string,
createdAt: string,
image: string,
}
}
```
## Post Detail
Show the detail of the post
```HTTP
GET /post/:id/detail
```
### Parameters - `Parameter`
Name | Type | Description
-----|------|------------
id | `string` | post id
### Response
```TS
{
message: string,
data: {
title: string,
content: string,
image: string,
createdAt: string,
author: {
id: string,
name: string,
image: string,
},
isLiked: boolean,
isDisliked: boolean,
likeCount: number,
dislikeCount: number,
likes: [
...,
{
name: string,
image: string,
},
...
],
dislikes: [
...,
{
name: string,
image: string,
},
...
],
}
}
```
## Like post
Like or dislike the post
```HTTP
GET /post/:id/:command
```
### Parameters - `Parameter`
Name | Type | Description
-----|------|------------
id | `string` | post id
type | `string: 'like', 'dislike', 'unlike', 'undislike'` | command to like or dislike post
### Response
```TS
{
message: string,
data: {
id: string,
userId: string,
postId: string,
createdAt: string,
type: 'LIKE' | 'DISLIKE',
}
}
```
# Profile
## Profile Detail
Get the detail of user & all the posts that uploaded by user
```HTTP
GET /profile/:id
```
### Parameters - `Parameter`
Name | Type | Description
-----|------|------------
id | `string` | user id
### Response
```TS
{
message: string,
data: {
posts: [
...,
{
id: string,
title: string,
content: string,
image: string,
createdAt: string,
isLiked: boolean,
isDisliked: boolean,
likeCount: number,
dislikeCount: number,
},
...
],
profile: {
id: string,
name: string,
image: string,
},
}
}
```
# Search
## User Search
Search user by their name or email
```HTTP
GET /search/profile/:slug
```
### Parameters - `Parameter`
Name | Type | Description
-----|------|------------
slug | `string` | user name or email
### Response
```TS
{
message: string,
data: [
...,
{
id: string,
name: string,
image: string,
},
...
],
}
```
## Post Search
Search post by the content
```HTTP
GET /search/post/:slug
```
### Parameters - `Parameter`
Name | Type | Description
-----|------|------------
slug | `string` | content string
### Response
```TS
{
message: string,
data: [
...,
{
id: string,
title: string,
content: string,
image: string,
createdAt: string,
isLiked: boolean,
isDisliked: boolean,
likeCount: number,
dislikeCount: number,
author: {
id: string,
name: string,
image: string,
},
},
...
],
}
```