> For the complete documentation index, see [llms.txt](https://simple-twitter-api.gitbook.io/api/HDZXvOJdS0oEs3mTdu7w/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simple-twitter-api.gitbook.io/api/HDZXvOJdS0oEs3mTdu7w/user-api.md).

# User API

## 使用者能編輯自己的 account、name、email 和 password

<mark style="color:orange;">`PUT`</mark> `hostname/api/users/:id/setting`

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | String | 要編輯的使用者ID   |

#### Request Body

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| account<mark style="color:red;">\*</mark>       | String | 帳號          |
| checkPassword<mark style="color:red;">\*</mark> | String | 確認密碼        |
| password<mark style="color:red;">\*</mark>      | String | 密碼          |
| name<mark style="color:red;">\*</mark>          | String | 暱稱/名稱       |
| email<mark style="color:red;">\*</mark>         | String | 電子郵件        |

{% tabs %}
{% tab title="200: OK 修改成功，更新使用者帳號資訊" %}

```javascript
{
    "status": "success",
    "message": "修改成功",
    "data": {
        "name": "user1123",
        "account": "us23r11223",
        "email": "us2r1@example.com"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 使用者只能修改自己的資料" %}

```
{
    "code": 400,
    "status": "error", 
    "message": "只能修改自己的資料"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="400: Bad Request 所有欄位都要填寫" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "所有欄位都要填寫",
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 請求參數有誤(名稱超出50字)" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "名字上限 50 字",
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 密碼和確認密碼不一致" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "密碼和確認密碼必須一致",
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 電子郵件不是正確格式" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "電子郵件不是正確格式",
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 存取被拒(email已重複註冊)" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "email 已重複註冊！",
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 存取被拒(account已重複註冊)" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "account 已重複註冊！",
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="404: Not Found 對應使用者ID不存在" %}

```javascript
{
    "code": 404,
    "status": "error", 
    "message": "對應使用者不存在"
}
```

{% endtab %}
{% endtabs %}

## 取得當前登入者個人資料

<mark style="color:blue;">`GET`</mark> `hostname/api/current_user`

{% tabs %}
{% tab title="200: OK 獲取成功，回傳指定使用者資料" %}

```javascript
{
    "status": "success",
    "message": "成功獲取",
    "data": {
        "id": 2,
        "account": "user1",
        "email": "user1@example.com",
        "name": "user1",
        "avatar": "https://loremflickr.com/240/240?lock=30.005523637159648",
        "role": "user",
        "cover": "https://loremflickr.com/720/240?lock=89.83133257495717",
        "followerCount": 0,
        "followingCount": 0,
        "tweetCount": 10,
        "isExpiredToken": false
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}
{% endtabs %}

## 獲取前十名followers較多的使用者

<mark style="color:blue;">`GET`</mark> `hostname/api/users/top`

{% tabs %}
{% tab title="200: OK 獲取成功，回傳指定使用者資料" %}

```javascript
{
    "status": "success",
    "message": "成功獲取",
    "data": [
        {
            "id": 3,
            "name": "user2",
            "avatar": "https://loremflickr.com/240/240?lock=70.5829761695203",
            "account": "user2",
            "followerCount": 2,
            "Followers": [
                {
                    "id": 2,
                    "account": "user1",
                    "email": "user1@example.com",
                    "name": "user1",
                    "avatar": "https://loremflickr.com/240/240?lock=30.005523637159648",
                    "cover": "https://loremflickr.com/720/240?lock=89.83133257495717",
                    "introduction": "rerum",
                    "role": "user",
                    "likeCount": 0,
                    "tweetCount": 10,
                    "followingCount": 0,
                    "followerCount": 0,
                    "createdAt": "2022-02-25T22:18:10.000Z",
                    "updatedAt": "2022-02-25T22:18:10.000Z",
                    "Followship": {
                        "id": 1,
                        "followerId": 2,
                        "followingId": 3,
                        "createdAt": "2022-02-25T22:18:10.000Z",
                        "updatedAt": "2022-02-25T22:18:10.000Z"
                    }
                },
                {
                    "id": 4,
                    "account": "user3",
                    "email": "user3@example.com",
                    "name": "user3",
                    "avatar": "https://loremflickr.com/240/240?lock=15.352250709560565",
                    "cover": "https://loremflickr.com/720/240?lock=97.46697388063966",
                    "introduction": "quae dolorum non",
                    "role": "user",
                    "likeCount": 0,
                    "tweetCount": 10,
                    "followingCount": 0,
                    "followerCount": 1,
                    "createdAt": "2022-02-25T22:18:10.000Z",
                    "updatedAt": "2022-02-25T22:18:10.000Z",
                    "Followship": {
                        "id": 3,
                        "followerId": 4,
                        "followingId": 3,
                        "createdAt": "2022-02-25T22:18:10.000Z",
                        "updatedAt": "2022-02-25T22:18:10.000Z"
                    }
                }
            ],
            "isFollowed": true
        },
        {
            "id": 4,
            "name": "user3",
            "avatar": "https://loremflickr.com/240/240?lock=15.352250709560565",
            "account": "user3",
            "followerCount": 1,
            "Followers": [
                {
                    "id": 2,
                    "account": "user1",
                    "email": "user1@example.com",
                    "name": "user1",
                    "avatar": "https://loremflickr.com/240/240?lock=30.005523637159648",
                    "cover": "https://loremflickr.com/720/240?lock=89.83133257495717",
                    "introduction": "rerum",
                    "role": "user",
                    "likeCount": 0,
                    "tweetCount": 10,
                    "followingCount": 0,
                    "followerCount": 0,
                    "createdAt": "2022-02-25T22:18:10.000Z",
                    "updatedAt": "2022-02-25T22:18:10.000Z",
                    "Followship": {
                        "id": 2,
                        "followerId": 2,
                        "followingId": 4,
                        "createdAt": "2022-02-25T22:18:10.000Z",
                        "updatedAt": "2022-02-25T22:18:10.000Z"
                    }
                }
            ],
            "isFollowed": true
        },
        {
            "id": 2,
            "name": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=30.005523637159648",
            "account": "user1",
            "followerCount": 0,
            "Followers": [],
            "isFollowed": false
        },
        .
        .
}
```

{% endtab %}

{% tab title="401: Unauthorized 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(管理員不能使用前台功能)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "存取被拒"
}
```

{% endtab %}
{% endtabs %}

## 登入使用者

<mark style="color:green;">`POST`</mark> `hostname/api/login`

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| account<mark style="color:red;">\*</mark>  | String | 使用者帳號(登入用的) |
| password<mark style="color:red;">\*</mark> | String | 密碼          |

{% tabs %}
{% tab title="200: OK 登入成功，回傳指定使用者資料" %}

```javascript
{ 
    "status": "success",
    "token": string, 
    "data": { 
        "id": integer,
        "name": string,
        "email": string,
        "account": string,
        "password": string,
        "role": "user",
        "introduction": string,
        "avatar": string,
        "cover": string,
        "tweet_count": integer,
        "follower_count": integer,
        "following_count": integer,
        "like_count": integer,
        "updated_at": timestamp,
        "created_at": timestamp
    }, 
    "message": null 
}
```

{% endtab %}

{% tab title="400: Bad Request 請求參數有誤(有欄位沒填寫到)" %}

```
{
    "code": 400,
    "status": "error", 
    "message": "所有欄位都要填寫"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(帳號正確，但密碼錯誤)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "帳號或密碼錯誤"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(帳號不存在)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "帳號不存在"
}
```

{% endtab %}
{% endtabs %}

## 註冊使用者

<mark style="color:green;">`POST`</mark> `hostname/api/users`

#### Request Body

| Name                                            | Type   | Description |
| ----------------------------------------------- | ------ | ----------- |
| name<mark style="color:red;">\*</mark>          | String | 使用者暱稱/使用者名稱 |
| account<mark style="color:red;">\*</mark>       | String | 使用者帳號(登入用的) |
| email<mark style="color:red;">\*</mark>         | String | 電子郵件        |
| password<mark style="color:red;">\*</mark>      | String | 密碼          |
| checkPassword<mark style="color:red;">\*</mark> | String | 確認密碼        |

{% tabs %}
{% tab title="200 獲取成功，回傳指定使用者資料" %}

```javascript
{
    "status": "success",
    "message": "註冊成功",
    "data": {
        "likeCount": 0,
        "tweetCount": 0,
        "followingCount": 0,
        "followerCount": 0,
        "id": 24,
        "name": "user1",
        "account": "user12345",
        "email": "user12345@example.com",
        "role": "user",
        "avatar": "https://res.cloudinary.com/dqfxgtyoi/image/upload/v1644154630/github/defaultAvatar_uapauy.png",
        "cover": "https://res.cloudinary.com/dqfxgtyoi/image/upload/v1645696452/github/defaultCover_uhyyds.jpg",
        "updatedAt": "2022-02-27T20:30:54.609Z",
        "createdAt": "2022-02-27T20:30:54.609Z"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 所有欄位都要填寫，會回傳使用者填過的欄位" %}

```
{
    "code": 400,
    "status": "error", 
    "message": "所有欄位都要填寫"
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="400: Bad Request 請求參數有誤(名稱超出50字)" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "名稱超出50字"
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 密碼和確認密碼不一致，會回傳使用者填過的欄位" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "密碼和確認密碼不一致"
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 存取被拒(account已重複註冊)" %}

```javascript
{ 
    "code": 400,
    "status": "error", 
    "message": "account已重複註冊"
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 存取被拒(email已重複註冊)" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "email已重複註冊"
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 請求參數有誤(電子郵件不是正確格式)" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "電子郵件不是正確格式"
    "data": {
               "name": string,
               "account": string,
               "email": string,
               "password": string,
               "checkPassword": string
    }
}
```

{% endtab %}
{% endtabs %}

## 獲取指定使用者的個人資料

<mark style="color:blue;">`GET`</mark> `hostname/api/users/:id`

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | 使用者ID       |

{% tabs %}
{% tab title="200: OK 獲取成功，回傳指定使用者資料" %}

```javascript
{
    "status": "success",
    "message": "修改成功",
    "data": {
        "id": 3,
        "account": "user2",
        "email": "user2@example.com",
        "name": "556699erewrwre",
        "avatar": "0",
        "cover": "0",
        "introduction": "8799",
        "role": "user",
        "likeCount": 0,
        "tweetCount": 10,
        "followingCount": 0,
        "followerCount": 0,
        "createdAt": "2022-02-26T18:10:09.000Z",
        "updatedAt": "2022-02-26T22:56:41.000Z"
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="404: Not Found 對應使用者ID不存在" %}

```javascript
{
    "code": 404,
    "status": "error", 
    "message": "對應使用者不存在"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(管理員不能使用前台功能)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "存取被拒"
}
```

{% endtab %}
{% endtabs %}

## 獲取使用者寫過的所有推文&#x20;

<mark style="color:blue;">`GET`</mark> `hostname/api/users/:id/tweets`

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | 使用者ID       |

{% tabs %}
{% tab title="200: OK 獲取成功，回傳指定使用者的所有推文" %}

```javascript
[
    {
        "id": 1,
        "UserId": 2,
        "description": "Voluptatem repellendus tenetur quis. Vel eveniet saepe exercitationem. Delectus beatae amet dolor nulla et consectetur veniam. Qui distincti",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 2,
        "UserId": 2,
        "description": "Ab eos est quas ut et quo tenetur. Eum quia doloremque iure. Eos harum illo possimus quaerat est.",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 3,
        "UserId": 2,
        "description": "quam sed architecto",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 4,
        "UserId": 2,
        "description": "Aut quo odio in nobis. Sit quisquam quam aut. Ullam et perspiciatis odio ratione. Ut maxime eveniet non facere quasi autem facilis.",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 5,
        "UserId": 2,
        "description": "Et autem qui non.",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 6,
        "UserId": 2,
        "description": "Laborum dolor fugit ea sunt et et temporibus.\nRecusandae nihil quis velit.\nRepellendus ullam atque expedita voluptatem voluptatem saepe dolo",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 7,
        "UserId": 2,
        "description": "Voluptates optio assumenda vel sit eos praesentium. Et pariatur consequatur eum et consectetur eius consequatur. Hic rerum aut facilis fugit",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 8,
        "UserId": 2,
        "description": "Quia dolorem minima deserunt ipsam et.",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 9,
        "UserId": 2,
        "description": "Rem consequuntur eaque voluptate officiis nesciunt provident ea facilis ea. Molestias aut ut est. Laborum aliquam consequuntur aperiam cupid",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    },
    {
        "id": 10,
        "UserId": 2,
        "description": "Tempore velit temporibus aut harum nisi iusto.",
        "createdAt": "2022-02-26T23:25:09.000Z",
        "updatedAt": "2022-02-26T23:25:09.000Z",
        "likeCount": 0,
        "replyCount": 3,
        "TweetAuthor": {
            "id": 2,
            "name": "user1",
            "account": "user1",
            "avatar": "https://loremflickr.com/240/240?lock=93.62407901541158"
        }
    }
]
```

{% endtab %}

{% tab title="401: Unauthorized 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="404: Not Found 對應使用者ID不存在" %}

```javascript
{
    "code": 404,
    "status": "error", 
    "message": "對應使用者不存在"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(管理員不能使用前台功能)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "存取被拒"
}
```

{% endtab %}
{% endtabs %}

## 獲取對應使用者所回覆的推文(包含回覆內容，會標記哪些推文是目前使用者喜歡和回覆)

<mark style="color:blue;">`GET`</mark> `hostname/api/users/:id/replied_tweets`

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | 使用者ID       |

{% tabs %}
{% tab title="200 獲取成功，回傳指定使用者所回覆的推文和內容" %}

```javascript
[
    {
        "id": 41,
        "UserId": 3,
        "TweetId": 14,
        "comment": "Nesciunt rerum et.\nAnimi qui ut suscipit earum vitae eius doloribus voluptatem qui.\nVeritatis ad et qui nisi sed voluptate.\nTemporibus nihil",
        "createdAt": "2022-03-03T23:29:03.000Z",
        "updatedAt": "2022-02-26T20:29:03.000Z",
        "isLikedTweet": false,
        "isRepliedTweet": true,
        "ReplyAuthor": {
            "id": 3,
            "account": "user2",
            "name": "user2",
            "cover": "https://loremflickr.com/720/240?lock=93.3205333349494",
            "avatar": "https://loremflickr.com/240/240?lock=53.35063209756541"
        },
        "TargetTweet": {
            "id": 14,
            "UserId": 2,
            "description": "Blanditiis qui labore ex aspernatur.",
            "likeCount": 0,
            "replyCount": 3,
            "createdAt": "2022-02-26T20:29:03.000Z",
            "updatedAt": "2022-02-26T20:29:03.000Z",
            "TweetAuthor": {
                "id": 2,
                "name": "user1",
                "account": "user1",
                "avatar": "https://loremflickr.com/240/240?lock=3.5899861119462297",
                "cover": "https://loremflickr.com/720/240?lock=81.9795525651643"
            }
        }
    },
    {
        "id": 56,
        "UserId": 3,
        "TweetId": 19,
        "comment": "dignissimos rem fugiat",
        "createdAt": "2022-03-03T20:29:03.000Z",
        "updatedAt": "2022-02-26T20:29:03.000Z",
        "isLikedTweet": true,
        "isRepliedTweet": true,
        "ReplyAuthor": {
            "id": 3,
            "account": "user2",
            "name": "user2",
            "cover": "https://loremflickr.com/720/240?lock=93.3205333349494",
            "avatar": "https://loremflickr.com/240/240?lock=53.35063209756541"
        },
        "TargetTweet": {
            "id": 19,
            "UserId": 2,
            "description": "Facilis quo a est enim a molestiae. Iure eos totam nihil. Voluptatum dolor vero omnis at provident.\n \rEt sed vero. Omnis commodi molestiae s",
            "likeCount": 0,
            "replyCount": 3,
            "createdAt": "2022-02-26T20:29:03.000Z",
            "updatedAt": "2022-02-26T20:29:03.000Z",
            "TweetAuthor": {
                "id": 2,
                "name": "user1",
                "account": "user1",
                "avatar": "https://loremflickr.com/240/240?lock=3.5899861119462297",
                "cover": "https://loremflickr.com/720/240?lock=81.9795525651643"
            }
        }
    },
    {
        "id": 46,
        "UserId": 3,
        "TweetId": 16,
        "comment": "dicta unde et",
        "createdAt": "2022-03-02T22:29:03.000Z",
        "updatedAt": "2022-02-26T20:29:03.000Z",
        "isLikedTweet": false,
        "isRepliedTweet": false,
        "ReplyAuthor": {
            "id": 3,
            "account": "user2",
            "name": "user2",
            "cover": "https://loremflickr.com/720/240?lock=93.3205333349494",
            "avatar": "https://loremflickr.com/240/240?lock=53.35063209756541"
        },
        "TargetTweet": {
            "id": 16,
            "UserId": 2,
            "description": "quas",
            "likeCount": 0,
            "replyCount": 3,
            "createdAt": "2022-02-26T20:29:03.000Z",
            "updatedAt": "2022-02-26T20:29:03.000Z",
            "TweetAuthor": {
                "id": 2,
                "name": "user1",
                "account": "user1",
                "avatar": "https://loremflickr.com/240/240?lock=3.5899861119462297",
                "cover": "https://loremflickr.com/720/240?lock=81.9795525651643"
            }
        }
    },
    .
    .
]
```

{% endtab %}

{% tab title="401 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="404: Not Found 對應使用者ID不存在" %}

```javascript
{
    "code": 404,
    "status": "error", 
    "message": "對應使用者不存在"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(管理員不能使用前台功能)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "存取被拒"
}
```

{% endtab %}
{% endtabs %}

## 獲取對應使用者所喜歡的所有推文(標記目前推文是否被登入者喜歡或者回覆過)

<mark style="color:blue;">`GET`</mark> `hostname/api/users/:id/likes`

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | 使用者ID       |

{% tabs %}
{% tab title="200: OK 獲取成功，回傳指定使用者所喜歡的推文" %}

```javascript
[
    {
        "id": 4,
        "UserId": 2,
        "TweetId": 2,
        "createdAt": "2022-02-27T19:15:24.000Z",
        "updatedAt": "2022-02-27T19:15:24.000Z",
        "LikedTweet": {
            "id": 2,
            "UserId": 3,
            "description": "quia architecto voluptas",
            "createdAt": "2022-02-27T19:15:24.000Z",
            "updatedAt": "2022-02-27T19:15:24.000Z",
            "replyCount": 3,
            "likeCount": 3,
            "isLiked": true,
            "isReplied": false,
            "TweetAuthor": {
                "id": 3,
                "account": "user2",
                "name": "user2",
                "email": "user2@example.com",
                "avatar": "https://loremflickr.com/240/240?lock=72.43383079474094",
                "cover": "https://loremflickr.com/720/240?lock=10.63680700768441"
            }
        }
    },
    {
        "id": 7,
        "UserId": 2,
        "TweetId": 3,
        "createdAt": "2022-02-27T19:15:24.000Z",
        "updatedAt": "2022-02-27T19:15:24.000Z",
        "LikedTweet": {
            "id": 3,
            "UserId": 3,
            "description": "Vero hic asperiores expedita et.",
            "createdAt": "2022-02-27T19:15:24.000Z",
            "updatedAt": "2022-02-27T19:15:24.000Z",
            "replyCount": 3,
            "likeCount": 3,
            "isLiked": true,
            "isReplied": false,
            "TweetAuthor": {
                "id": 3,
                "account": "user2",
                "name": "user2",
                "email": "user2@example.com",
                "avatar": "https://loremflickr.com/240/240?lock=72.43383079474094",
                "cover": "https://loremflickr.com/720/240?lock=10.63680700768441"
            }
        }
    },
    .
    .
]
```

{% endtab %}

{% tab title="401: Unauthorized 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="404: Not Found 對應使用者ID不存在" %}

```javascript
{
    "code": 404,
    "status": "error", 
    "message": "對應使用者不存在"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(管理員不能使用前台功能)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "存取被拒"
}
```

{% endtab %}
{% endtabs %}

## 看見某使用者跟隨中的人(會標記哪些使用者是目前使用者所追隨的)

<mark style="color:blue;">`GET`</mark> `hostname/api/users/:id/followings`

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | 使用者ID       |

{% tabs %}
{% tab title="200: OK 獲取成功，回傳指定使用者所跟隨的使用者" %}

```javascript
[
    {
        "followingId": 4,
        "name": "user3",
        "account": "user3",
        "introduction": "Excepturi porro quis ex consequatur eos voluptates. Nulla hic sunt dolor atque repellat aut. Numquam quibusdam earum natus a consequatur. Eos tempore modi volup",
        "cover": "https://loremflickr.com/720/240?lock=68.61269720187437",
        "avatar": "https://loremflickr.com/240/240?lock=86.7250929413381",
        "isFollowed": true,
        "Followship": {
            "id": 2,
            "followerId": 3,
            "followingId": 4,
            "createdAt": "2022-02-28T15:25:04.000Z",
            "updatedAt": "2022-02-28T15:25:04.000Z"
        }
    },
    {
        "followingId": 5,
        "name": "user4",
        "account": "user4",
        "introduction": "eum aut asperiores",
        "cover": "https://loremflickr.com/720/240?lock=2.113564844736392",
        "avatar": "https://loremflickr.com/240/240?lock=23.357860923180617",
        "isFollowed": false,
        "Followship": {
            "id": 3,
            "followerId": 3,
            "followingId": 5,
            "createdAt": "2022-02-27T15:25:04.000Z",
            "updatedAt": "2022-02-27T15:25:04.000Z"
        }
    },
    {
        "followingId": 6,
        "name": "user5",
        "account": "user5",
        "introduction": "maxime maxime iste",
        "cover": "https://loremflickr.com/720/240?lock=79.92451816607537",
        "avatar": "https://loremflickr.com/240/240?lock=73.34417809356532",
        "isFollowed": false,
        "Followship": {
            "id": 4,
            "followerId": 3,
            "followingId": 6,
            "createdAt": "2022-02-26T15:25:04.000Z",
            "updatedAt": "2022-02-26T15:25:04.000Z"
        }
    }
]
```

{% endtab %}

{% tab title="401: Unauthorized 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="404: Not Found 對應使用者ID不存在" %}

```javascript
{
    "code": 404,
    "status": "error", 
    "message": "對應使用者不存在"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(管理員不能使用前台功能)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "存取被拒"
}
```

{% endtab %}
{% endtabs %}

## 看見某使用者的跟隨者(會標記哪些使用者是目前使用者所追隨的)

<mark style="color:blue;">`GET`</mark> `hostname/api/users/:id/followers`

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK 獲取成功，回傳跟隨指定使用者的所有使用者" %}

```javascript
[
    {
        "followerId": 9,
        "name": "user2",
        "account": "user2",
        "introduction": "Veniam porro sapiente.\nPerferendis non aliquid earum aspernatur atque vel unde beatae.\nQuia ex facere.\nVel consequatur iusto ab.\nEum at numquam ipsum magnam et ",
        "cover": "https://loremflickr.com/720/240?lock=100.59738129015452",
        "avatar": "https://loremflickr.com/240/240?lock=20.16533509754197",
        "isFollowed": true,
        "Followship": {
            "id": 2,
            "followerId": 9,
            "followingId": 10,
            "createdAt": "2022-02-28T15:56:08.000Z",
            "updatedAt": "2022-02-28T15:56:08.000Z"
        }
    },
    {
        "followerId": 8,
        "name": "user1",
        "account": "user1",
        "introduction": "Fugit ut quaerat voluptatem consequatur sunt. Qui molestiae rerum natus assumenda non. Cumque non amet placeat quo reiciendis et laudantium omnis modi. Expedita",
        "cover": "https://loremflickr.com/720/240?lock=17.75232230027939",
        "avatar": "https://loremflickr.com/240/240?lock=81.76069650320224",
        "isFollowed": false,
        "Followship": {
            "id": 1,
            "followerId": 8,
            "followingId": 10,
            "createdAt": "2022-02-26T15:56:08.000Z",
            "updatedAt": "2022-02-26T15:56:08.000Z"
        }
    },
    {
        "followerId": 11,
        "name": "user4",
        "account": "user4",
        "introduction": "Et id sint. Laborum non velit autem facilis est inventore. Nemo inventore ut enim unde voluptatem. Ut excepturi maxime non eius est expedita laudantium iste. Am",
        "cover": "https://loremflickr.com/720/240?lock=39.44557003313784",
        "avatar": "https://loremflickr.com/240/240?lock=37.77200372061999",
        "isFollowed": false,
        "Followship": {
            "id": 3,
            "followerId": 11,
            "followingId": 10,
            "createdAt": "2022-02-25T15:56:08.000Z",
            "updatedAt": "2022-02-25T15:56:08.000Z"
        }
    }
]
```

{% endtab %}

{% tab title="401: Unauthorized 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="404: Not Found 對應使用者ID不存在" %}

```javascript
{
    "code": 404,
    "status": "error", 
    "message": "對應使用者不存在"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(管理員不能使用前台功能)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "存取被拒"
}
```

{% endtab %}
{% endtabs %}

## 更新個人資料表單(可上傳圖片、封面、更新自我介紹/暱稱)

<mark style="color:orange;">`PUT`</mark> `hostname/api/users/:id`

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | 使用者ID       |

#### Request Body

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| introduction                           | String | 自我介紹        |
| avatar                                 | String | 頭像(檔案位置)    |
| cover                                  | String | 封面(檔案位置)    |
| name<mark style="color:red;">\*</mark> | String | 暱稱/名稱       |

{% tabs %}
{% tab title="200: OK 編輯成功，回傳指定使用者資料" %}

```javascript
{
    "status": "success",
    "message": "修改成功",
    "data": {
        "account": "us23r11223",
        "name": "123",
        "introduction": "HII",
        "avatar": "https://i.imgur.com/bD2jgsY.png",
        "cover": "https://i.imgur.com/5lNMek9.png"
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized 使用者未從登入驗證獲取憑證不予使用" %}

```
{
    "code": 401,
    "status": "error", 
    "message": "使用者未從登入驗證獲取憑證不予使用"
}
```

{% endtab %}

{% tab title="500: Internal Server Error 系統出錯" %}

```javascript
{
    "code": 500,
    "status": "error",
    "message": "系統出錯"
}
```

{% endtab %}

{% tab title="400: Bad Request 名稱不允許為空" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "名稱不允許為空"
    "data":  {
            "name": string,
            "introduction": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 請求參數有誤(暱稱上限 50 字)" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "暱稱上限 50 字"
    "data":  {
            "name": string,
            "introduction": string
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 請求參數有誤(自我介紹數字上限 160 字)" %}

```javascript
{
    "code": 400,
    "status": "error", 
    "message": "自我介紹數字上限 160 字"
    "data":  {
            "name": string,
            "introduction": string
    }
}
```

{% endtab %}

{% tab title="404: Not Found 對應使用者ID不存在" %}

```javascript
{
    "code": 404,
    "status": "error", 
    "message": "對應使用者不存在"
}
```

{% endtab %}

{% tab title="400: Bad Request 不允許修改他人資料" %}

```javascript
{
    "code": 400,
    "status": "400",
    "message": "只能修改自己的資料"
}
```

{% endtab %}

{% tab title="403: Forbidden 存取被拒(管理員不能使用前台功能)" %}

```javascript
{
    "code": 403,
    "status": "error", 
    "message": "存取被拒"
}
```

{% endtab %}
{% endtabs %}
