---
# System prepended metadata

title: Z-axis API

---

# Z-axis API

# URL Path Documentation
## User
| 說明 | Method | Path | Body |
| -------- | -------- | -------- | - |
| 註冊使用者 | POST | /users/register | nickname, email, password |
| 登入使用者 | POST | /users/login | email, password |
| 取得使用者資料 | GET | /users/me | 
| 變更使用者資料 | PATCH | /users/me | nickname, email |
| 變更使用者密碼 | PATCH | /users/updatePassword | oldPassword, newPassword, againPassword |
| 刪除使用者 | DELETE | /users/me | 

## Issue
| 說明 | Method | Path | Params | Body |
| -------- | -------- | -------- | - | - |
| 創立留言箱 | POST | /issues | | title, description, beginDate, finishDate |
| 取得所有留言箱 | GET | /issues | |
| 取得單一留言箱 | GET | /issues/:issueURL | issueURL |
| 取得單一留言箱分析資料 | GET | /issues/data/:issueURL | issueURL |
| 編輯留言箱 | PATCH | /issues/:issueId | issueId | title, description, beginDate, finishDate 
| 刪除留言箱 | DELETE | /issues/:issueId | issueId |

## Comment
| 說明 | Method | Path | Params | Body |
| -------- | -------- | -------- | - | - |
| 創立留言 | POST | /issues/:issueId/comments | issueId | nickname, content |
| 取得所有留言 | GET | /issues/:issueId/comments | issueId |
| 編輯留言 | PATCH | /issues/:issueId/comments/:commentId | issueId, commentId | nickname, content |
| 編輯回覆 | PATCH | /issues/:issueId/comments/:commentId/replies | issueId, commentId | reply |
| 置頂留言 | POST | /issues/:issueId/pinCommentOnTop | issueId |
| 按讚留言 | PATCH | /issues/:issueId/comments/:commentId/likes | issueId |
| 刪除留言 | DELETE | /issues/:issueId/comments/:commentId | issueId, commentId | |

## Guest
| 說明 | Method | Path |
| -------- | -------- | -------- | 
| 註冊訪客 | POST | /guest |

## Test
開發中

## Lottery
開發中

## Questionnaire
開發中

# Request and Response
## baseURL
`https://ben6515.tw/api`

## 身份驗證
```javascript=
{
  headers: {
    'authorization': "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InpheGlzQGdtYWlsLmNvbSIsImlhdCI6MTYzMzUwNTc0MH0.MeG5g2v-fUfa4h9vLLc7zUwEGv5IgEMCYT75g3wnexY",
    'guest-token': "728v1vnb"
  }
}
```

## Users
### 註冊使用者
Request Example
```javascript=
{
  "nickname": "zaxis",
  "email": "zaxis@gmail.com",
  "password": "zaxis2021"
}
```
Response Example
```javascript=
{
  "ok": 1,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InpheGlzQGdtYWlsLmNvbSIsImlhdCI6MTYzMzUwNTc0MH0.MeG5g2v-fUfa4h9vLLc7zUwEGv5IgEMCYT75g3wnexY"
  "statusCode": 200
}
```

### 登入使用者
Request Example
```javascript=
{
  "email": "zaxis@gmail.com",
  "password": "zaxis2021"
}
```
Response Example
```javascript=
{
  "ok": 1,
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InpheGlzQGdtYWlsLmNvbSIsImlhdCI6MTYzMzUwNTc0MH0.MeG5g2v-fUfa4h9vLLc7zUwEGv5IgEMCYT75g3wnexY"
  "statusCode": 200
}
```

### 取得使用者資料
Response Example
```javascript=
{
  "ok": 1,
  "user": {
    "id": 2,
    "nickname": "angelina",
    "email": "angelina@gmail.com"
  },
  "statusCode": 200
}
```

### 變更使用者資料
Request Example
```javascript=
{
  "nickname": "zaxis",
  "email": "zaxis@gmail.com",
}
```
Response Example
```javascript=
{
  "ok": 1,
  "message": "個人資訊更新成功",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InpheGlzQGdtYWlsLmNvbSIsImlhdCI6MTYzMzUwNTc0MH0.MeG5g2v-fUfa4h9vLLc7zUwEGv5IgEMCYT75g3wnexY"
  "statusCode": 200
}
```

### 變更使用者密碼
Request Example
```javascript=
{
  "oldPassword": "zaxis2021",
  "newPassword": "zaxis2022",
  "againPassword": "zaxis2022"
}
```
Response Example
```javascript=
{
  "ok": 1,
  "message": "密碼更新成功",
  "statusCode": 200
}
```

### 刪除使用者
Response Example
```javascript=
{
  "ok": 1,
  "message": "刪除成功",
  "statusCode": 200
}
```

## Issue
### 創立留言箱
Request Example
```javascript=
{
  "title": "Z-axis 為您的演說帶來無限的可能",
  "description": "在虛擬的網路世界中，Z-axis 將連結您（代表 x）與觀眾（代表 y）的即時多人互動，三方串連打造更加自由、更加立體的互動空間",
  "beginDate": "2021-10-11",
  "finishDate": "2021-10-13"
}
```
Response Example
```javascript=
{
  "ok": 1,
  "message": "新增成功",
  "url": "fbf42f033f8db84de68bfd89b03656b4",
  "issue": {
    "UserId": 5
    "beginDate": "2021-10-11T00:00:00.000Z"
    "createdAt": "2021-10-06T07:39:00.778Z"
    "description": "在虛擬的網路世界中，Z-axis 將連結您（代表 x）與觀眾（代表 y）的即時多人互動，三方串連打造更加自由、更加立體的互動空間"
    "finishDate": "2021-10-13T00:00:00.000Z"
    "id": 5
    "title": "Z-axis 為您的演說帶來無限的可能"
    "updatedAt": "2021-10-06T07:39:00.778Z"
  }
  "statusCode": 200
}
```

### 取得所有留言箱
Response Example
```javascript=
{
  "ok": 1,
  "issuesWithURL": [{
    "issue": {
      "id": 1,
      "title": "祈念之樹留言箱",
      "description": "你相信像樟樹祈念，願望就能成真嗎？有沒有什麼思念，害怕說出來？有沒有什麼秘密，想要坦白卻無法開口？有沒有什麼歉意懊悔，已經來不及表達？如果這棵樟樹此刻在面前，你會許下什麼願望？",
      "beginDate": "2021-10-07T07:21:18.000Z",
      "finishDate": "2021-10-11T07:21:18.000Z",
      "isDeleted": false,
      "topCommentId": null,
      "createdAt": "2021-10-06T07:21:18.000Z",
      "updatedAt": "2021-10-06T07:21:18.000Z",
      "UserId": 1,
      "Comments": [
      {
        "id": 1,
        "nickname": "思念之人",
        "content": "思念親像漂流的船隻，感情親像風中的樹影，寂寞陪孤單逗陣來戲弄，笑我找無愛的人",
        "likesNum": 6,
        "reply": null,
        "replyCreateAt": null,
        "createdAt": "2021-10-06T07:21:18.000Z",
        "updatedAt": "2021-10-06T07:21:18.000Z",
        "IssueId": 1,
        "guestToken": "allen"
      },
      {
        "id": 2,
        "nickname": "Anonymous",
        "content": "如果時光倒流回到從前，你是否聽見我的許願，心和心的距離，其實並不遙遠，等待的那個人，總有一天會出現",
        "likesNum": 4,
        "reply": null,
        "replyCreateAt": null,
        "createdAt": "2021-10-06T07:21:18.000Z",
        "updatedAt": "2021-10-06T07:21:18.000Z",
        "IssueId": 1,
        "guestToken": "angelina"
      }]
    },
    "url": "0e36ddb504d5ca0cf414fe0fd16fb9bf",
    "commentCount": 2
  }],
  "statusCode": 200
}
```

### 取得單一留言箱
Response Example
```javascript=
{
  "ok": 1,
  "issue": {
    "id": 1,
    "title": "祈念之樹留言箱",
    "description": "你相信像樟樹祈念，願望就能成真嗎？有沒有什麼思念，害怕說出來？有沒有什麼秘密，想要坦白卻無法開口？有沒有什麼歉意懊悔，已經來不及表達？如果這棵樟樹此刻在面前，你會許下什麼願望？",
    "beginDate": "2021-10-07T07:21:18.000Z",
    "finishDate": "2021-10-11T07:21:18.000Z",
    "isDeleted": false,
    "topCommentId": 0,
    "createdAt": "2021-10-06T07:21:18.000Z",
    "updatedAt": "2021-10-07T13:30:32.000Z",
    "UserId": 1
  },
  "statusCode": 200
}
```

### 取得單一留言箱分析資料
Response Example
```javascript=
{
  "ok": 1,
  "data": [
  {
    "date": "2021-10-05",
    "likes": 0,
    "comments": 0,
    "replies": 0
  },{
    "date": "2021-10-06",
    "likes": 8,
    "comments": 2,
    "replies": 0
  },{
    "date": "2021-10-07",
    "likes": 1,
    "comments": 3,
    "replies" 0
  },{
    "date": "2021-10-08",
    "likes": 0,
    "comments": 0,
    "replies": 0
  },{
    "date": "2021-10-09",
    "likes": 0,
    "comments": 0,
    "replies": 0
  }],
  "statusCode": 200
}
```

### 編輯留言箱
Request Example
```javascript=
{
  "title": "Z-axis 為您的演說帶來無限的可能",
  "description": "在虛擬的網路世界中，Z-axis 將連結您（代表 x）與觀眾（代表 y）的即時多人互動，三方串連打造更加自由、更加立體的互動空間",
  "beginDate": "2021-11-13",
  "finishDate": "2021-11-15"
}
```
Response Example
```javascript=
{
  "ok": 1,
  "message": "更新成功",
  "statusCode": 200
}
```

### 刪除留言箱
Response Example
```javascript=
{
  "ok": 1,
  "message": "刪除成功",
  "statusCode": 200
}
```

## Comment
### 創立留言
Request Example
```javascript=
{
  "nickname": "夢幻旅人",
  "content": "夢幻仙境～翡翠谷，穿過古隧道後，有超美的水簾瀑布，適合拍照打卡"
}
```
Response Example
```javascript=
{
  "ok": 1,
  "message": '新增留言成功',
  "comment": {
    "id": 4,
    "nickname": "夢幻旅人",
    "content": "夢幻仙境～翡翠谷，穿過古隧道後，有超美的水簾瀑布，適合拍照打卡",
    "likesNum": 6,
    "reply": null,
    "replyCreateAt": null,
    "createdAt": "2021-10-06T07:21:18.000Z",
    "updatedAt": "2021-10-06T07:21:18.000Z",
    "IssueId": 2,
    "guestToken": "angelina"
  },
  "statusCode": 200
}
```

### 取得所有留言
Response Example
```javascript=
{ "ok": 1,
  "comments": [
  {
    "id": 3,
    "nickname": "秘境遊俠",
    "content": "清水斷崖，可以體驗立槳 SUP，享受徜徉在太平洋上的壯闊景色","likesNum":2,"reply":"上個月剛好有去玩，立槳超好玩，教練很會拍照",
    "replyCreateAt": "2021-10-06T07:21:18.000Z",
    "createdAt": "2021-10-06T07:21:18.000Z",
    "updatedAt": "2021-10-07T13:02:32.000Z",
    "IssueId": 2,
    "guestToken": "didi"
  },{
    "id": 4,
    "nickname": "夢幻旅人",
    "content": "夢幻仙境～翡翠谷，穿過古隧道後，有超美的水簾瀑布，適合拍照打卡",
    "likesNum": 6,
    "reply": null,
    "replyCreateAt": null,
    "createdAt": "2021-10-06T07:21:18.000Z",
    "updatedAt": "2021-10-07T13:02:33.000Z",
    "IssueId": 2,
    "guestToken": "angelina"
  }],
  "statusCode": 200
}
```

### 編輯留言
Request Example
```javascript=
{
  "nickname": "Octopus",
  "content": "Swimming is great."
}
```
Response Example
```javascript=
{
  "ok": 1,
  "message": "編輯留言成功",
  "statusCode": 200
}
```

### 編輯回覆
Request Example
```javascript=
{
  "reply": "動物星球頻道很棒"
}
```
Response Example
```javascript=
{
  "ok": 1,
  "message": "編輯回覆成功",
  "statusCode": 200
}
```

### 置頂留言
Response Example
```javascript=
{
  "ok": 1,
  "message": "置頂成功",
  "statusCode": 200
}
```

### 按讚留言
Response Example
```javascript=
{
  "ok": 1,
  "message": "按讚成功",
  "statusCode": 200
}
```

### 刪除留言
Response Example
```javascript=
{
  "ok": 1,
  "message": "刪除留言成功",
  "statusCode": 200
}
```

## Guest
### 註冊訪客
Response Example
```javascript=
{
  "ok": 1,
  "message": "新增 guest 成功",
  "guest":{
    "id": 5,
    "guestToken": "728v1vnb",
    "updatedAt": "2021-10-06T08:04:03.236Z",
    "createdAt": "2021-10-06T08:04:03.236Z"
  },
  "statusCode": 200
}
```
