-
Notifications
You must be signed in to change notification settings - Fork 0
API Documentation
this section for explain API Go Postgres
- User
- Register User
- Login User
- Update User
- Delete User
- Photo
- Upload Photo
- Get Photo
- Update Photo
- Delete Photo
- Comment
- Insert Comment
- Get Comment
- Update Comment
- Delete Comment
- Social Media
- Insert Social Media
- Get Social Media
- Update Social Media
- Delete Social Media
This endpoint for register user, first hit API
Command | Method | Routes | Description |
---|---|---|---|
User Register | POST | /api/users/register |
this endpoint for user register |
this endpoint no auth
{
"email": "[email protected]",
"username": "user",
"age": 8,
"password": "password"
}
{
"email": "[email protected]",
"username": "user",
"age": 8,
"password": "password"
}
This endpoint for login user, first hit API, each endpoint must be use Token for authorization
Command | Method | Routes | Description |
---|---|---|---|
User Login | POST | /api/users/login |
this endpoint for get token and use each endpoint |
this endpoint no auth because for get token.
{
"email": "[email protected]",
"password": "password"
}
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVsCJ9.eyJlbWFpbCI6ImVtcGF0QGVtYWlsLmNvbSIsImlkIjo1fQ.VCD4Qkpez40hsuR-rYbJrwRN2eMQDg5FHvv8W_uJbrY"
}
This endpoint update detail user login use Token, will response data user email, id, age and username
Command | Method | Routes | Description |
---|---|---|---|
User Update | PUT | /api/users/:userId |
this endpoint for update user |
this endpoint using bearer auth, token will get if you login with endpoint Login User
{
"email": "[email protected]",
"username": "userupdate",
"age": 9
}
{
"age": 9,
"email": "[email protected]",
"id": 1,
"update_at": "2022-04-05T11:49:05.608785+07:00",
"username": "userupdate"
}
This endpoint for delete user, this delete is softdelete
Command | Method | Routes | Description |
---|---|---|---|
User Delete | DELETE | /api/users/:userId |
this endpoint for delete data user from table users |
this endpoint using bearer auth, token will get if you login with endpoint Login User
none
{
"message": "your account has been successfully deleted"
}
This endpoint for photo upload
Command | Method | Routes | Description |
---|---|---|---|
Upload Photo | POST | /api/photos |
this endpoint for upload photo |
this endpoint using bearer auth, token will get if you login with endpoint Login User
{
"tittle": "Test Photo",
"caption": "Upload",
"photo_url": "https://www.facebook.com/pictures/test"
}
{
"caption": "Upload",
"created_at": "2022-04-07T08:42:34.3307046+07:00",
"id": 1,
"photo_url": "https://www.facebook.com/pictures/test.jpg",
"tittle": "Test Photo",
"user_id": 1
}
This endpoint for get Photo
Command | Method | Routes | Description |
---|---|---|---|
Get Photo | POST | /api/photos |
this endpoint for get data from table photos |
this endpoint using bearer auth, token will get if you login with endpoint Login User
none
{
"caption": "Upload",
"created_at": "2022-04-06T08:19:36.502168+07:00",
"id": 1,
"photo_url": "https://www.facebook.com/pictures/test.jpg",
"tittle": "Test Photo",
"updated_at": "2022-04-06T08:19:36.502168+07:00",
"user": {
"username": "user",
"email": "[email protected]"
},
"user_id": 1
}