untuk admin kita menyediakan akun admin untuk akses membuat, mengedit, menghapus user dan artikel diharapkan login sebagai admin terlebih dahulu setelah memasukan kode tokennya berikut username dan password adminnya, setelah login masukan token authorization lalu pilih Bearer Token
{
"email": "[email protected]",
"password": "admin"
}
Field Name | Type |
---|---|
id | ObjectId |
name | string |
string | |
password | string |
refresh_token | string |
Request :
- Method : POST
- Endpoint :
API/login
- Header :
- Content-Type: application/json
- Accept: application/json
Body :
{
"email": "[email protected]",
"password": "passwoRd123!@#"
}
Response :
{
"message": "Authentication successful!",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsIm5hbWUiOiJhZG1pbiIsImVtYWlsIjoiYWRtaW5AZ21haWwuY29tIiwiaWF0IjoxNjY5ODMyMzAwLCJleHAiOjE2Njk4MzU5MDB9.Ggjrd0mbCBUnaJ6pi6_KU50uvkwvCZKJAcitc0IXbvA"
}
Request :
- Method : POST
- Endpoint :
API/register
- Header :
- Content-Type: application/json
- Accept: application/json
Body :
{
"name": "name",
"email": "[email protected]",
"password": "passwoRd123!@#",
"confPassword": "passwoRd123!@#"
}
Response :
{
"message": "User created successfully"
}
Request :
- Method : GET
- Endpoint :
API/users
- Header :
- Accept: application/json
- Authorization : Bearer token
Response :
{
{
"id": 1,
"name": "contoh1",
"email": "[email protected]",
"password": "password1",
"refresh_token": "token1"
},
{
"id": 2,
"name": "contoh2",
"email": "[email protected]",
"password": "password2",
"refresh_token": "token2"
}
}
Request :
- Method : GET
- Endpoint :
API/users/:id
- Header :
- Accept: application/json
- Authorization : Bearer token
Response :
{
"id": 1,
"name": "contoh1",
"email": "[email protected]",
"password": "password1",
"refresh_token": "token1"
}
Request :
- Method : PATCH
- Endpoint :
API/users/:id
- Header :
- Content-Type: application/json
- Accept: application/json
- Authorization : Bearer token
Body :
{
"name": "contoh2",
"email": "[email protected]"
}
Response :
{
"message": "User updated"
}
Request :
- Method : GET
- Endpoint :
API/token
- Header :
- Accept: application/json
Response :
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsIm5hbWUiOiJhZG1pbiIsImVtYWlsIjoiYWRtaW5AZ21haWwuY29tIiwiaWF0IjoxNjY5ODMyMzAwLCJleHAiOjE2Njk4MzU5MDB9.Ggjrd0mbCBUnaJ6pi6_KU50uvkwvCZKJAcitc0IXbvA"
}
Request :
- Method : DELETE
- Endpoint :
API/users/:id
- Header :
- Accept: application/json
- Authorization : Bearer token
Response :
{
"message": "User Deleted"
}
Request :
- Method : DELETE
- Endpoint :
API/logout
- Header :
- Accept: application/json
Response :
{
"message": "Logout Successful!"
}
Field Name | Type |
---|---|
id | ObjectId |
title | string |
authorName | string |
postDescription | text |
postContent | text |
tags_1 | string |
tags_1 | string |
tags_1 | string |
imageUrl | string |
Request :
- Method : POST
- Endpoint :
API/articles
- Header :
- Content-Type: application/json
- Accept: application/json
- Authorization : Bearer token
Body :
{
"id": 1,
"title": "tittle",
"authorName": "author",
"postDescription": "description",
"postContent": "content",
"tags_1": "tag1",
"tags_2": "tag2",
"tags_3": "tag3",
"imageUrl": "url"
}
Response :
{
"message": "Artikel Created"
}
Request :
- Method : GET
- Endpoint :
API/articles
- Header :
- Accept: application/json
Response :
{
{
"id": 1,
"title": "tittle",
"authorName": "author",
"postDescription": "description",
"postContent": "content",
"tags_1": "tag1",
"tags_2": "tag2",
"tags_3": "tag3",
"imageUrl": "url"
},
{
"id": 2,
"title": "tittle2",
"authorName": "author2",
"postDescription": "description2",
"postContent": "content2",
"tags_1": "tag1_2",
"tags_2": "tag2_2",
"tags_3": "tag3_2",
"imageUrl": "url2"
}
}
Request :
- Method : GET
- Endpoint :
API/articles/:id
- Header :
- Accept: application/json
Response :
{
"id": 1,
"title": "tittle",
"authorName": "author",
"postDescription": "description",
"postContent": "content",
"tags_1": "tag1",
"tags_2": "tag2",
"tags_3": "tag3",
"imageUrl": "url"
}
Request :
- Method : PATCH
- Endpoint :
API/articles/:id
- Header :
- Content-Type: application/json
- Accept: application/json
- Authorization : Bearer token
Body :
{
"title": "tittle3",
"authorName": "author3",
"postDescription": "description3",
"postContent": "content3"
}
Response :
{
"message": "Artikel updated"
}
Request :
- Method : DELETE
- Endpoint :
API/articles/:id
- Header :
- Accept: application/json
- Authorization : Bearer token
Response :
{
"message": "User Deleted"
}