這裡是所有API的測試文件

開發環境 http://localhost:3000

正式環境

測試端點如下

Admin:

GET /admin/users- 管理者查看使用者資料

- **Description**
    Get all users data including their social activeness
- **Response**
    - 200:Successfully retrieved an array of user objects

[ { "id": 3, "name": "user2", "account": "user2", "profilePic": "/image/profilePic.png", "cover": "/image/cover.png", "postCount": 50, "likeCount": 0, "followersCount": 1, "followingsCount": 0 } ]

    - 401:Access token is invalid

DELETE /admin/posts/:id- 刪除使用者的貼文

- **Description**
    - Delete a post by its id
- **Parameter**
    - id: The id of the post you want to delete
- **Response**
    - 200:Successfully deleted a post

{ "status": "success", "message": "Post deleted successfully" }

    - 401:Access token is invalid

User:

POST/ users/signin- 使用者登入 (參數: account, password)

- **Description**
    - login to user's account
- **Request Body**
    - account: The user's account
    - password: The user's password
- **Response**
    - 200:Successfully logged in to user's account

{ "status": "success", "message": "User logged in successfully", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwiaWF0IjoxNzQwOTcyMjcwfQ.2YcXmB-adCjldYHOzvrYu34DXyA_nJThtMItjy8zHcQ", "user": { "id": 2, "name": "user1", "email": "[email protected]", "account": "user1", "profilePic": "/image/profilePic.png", "introduction": "Minus trepide vesco repudiandae abutor. Agnitio ad", "cover": "/image/cover.png", "role": "user" } }

    - 401:Password is incorrect

{ "status": "error", "message": "Invalid credentials" }

    - 404:User not found

{ "status": "error", "message": "User not found" }

    - 400:required parameters

{ "status": "error", "message": "account and password are required" }

POST/ users/signup- 使用者註冊 (參數: account, name, email, password, checkPassword, introduction, profilePic, cover)

- **Description**
    - create a new user
- **Request Body**
    - account
    - name
    - email
    - password
    - checkPassword
- **Response**
    - 200:Successfully create a account

{ "status": "success", "message": "test1 register successfully! Please login." }

    - 400:User already exists.

{ "status": "error", "message": "A user already exists. Choose a different account or email." }

    - 400:Did not fill out all fields

{ "status": "error", "errors": [ { "message": "Please fill out all fields." }, { "message": "Password and checkPassword do not match." } ], "userInput": { "account": "test1", "name": "test1", "email": "[email protected]", "password": "123456789", "checkPassword": "" } }

GET /users/top- 取得10位最多人追蹤的使用者