scwang0519
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # FoodieDate Backend API ## 前端可以在這裡提出需要的 API: (GET) `/fInvite/:inviteTo` 發送交友邀請(輸入對方學號) (GET) `/fInvite/:inviteTo/confirm` 確認交友邀請 (GET) `/fInvite/:inviteTo/delete` 刪除交友邀請 (GET) `/fInvite/:inviteTo/unFriend` 刪除好友 (GET) `/listFinvites` 交友邀請列表 (POST)`/rInvite/join` 加入邀約 (GET) `/myRInvite/:rInviteId/delete` 刪除自己發起的邀約 (POST) `/editProfile` 修改個人資訊 更新完成 ---------0602 更新--------- (GET) `/getUsername` 回傳自己的學號(=response.data) (DELETE) `/rInvite/:rInviteId/dismiss` 取消加入邀約(guest進來等於退出,master進來就會刪除邀約)考慮刪掉 刪除自己的邀約? insertRestToDB 的 Rinvite 現在會從 user 裡面找人的 id 出來(好像都會找到第一筆也就是自己),應該會比較好弄、餐廳data有些小更新 ---------0604 更新--------- 餐廳邀約中新增了dued這個屬性(true代表失效),給前端判斷是否為失效的邀約 ---------0615 更新--------- 新增取得題目和新增題目兩個route 記得先跑gameQuestion.js這個檔案(node gameQuestion.js) [TOC] ### (GET) `/messageList` #### 功能 得到目前使用者的訊息列表 #### 回傳值 - 成功 - `avatar`:對方的頭貼 - `name`:與誰的對話 - `time`:最近一則訊息的時間 - `count`:未讀訊息數量 - 失敗 - 回傳 404 及 User's friends are not found - (回傳的內容有需要可以再討論) #### 範例 ```json= [ { "avatar": "1", "name": "Aoo", "time": "4/20 09:20", "count": 0 }, { "avatar": "2", "name": "Boo", "time": "4/18 09:20", "count": 3 }, { "avatar": "3", "name": "Coo", "time": "4/16 09:20", "count": 1 } ] ``` ### (POST) `/messageAll` #### 功能 得到對某特定使用者的所有訊息內容 #### Body - whom:與誰的對話 #### 回傳值 - 成功 - `isMe`:是否為由自己傳出的訊息 - `time`:傳送此訊息的時間 - `msg`:訊息內容 - 失敗 - 回傳 404 及 User not found - (回傳的內容有需要可以再討論) #### 範例 ```json= [ { "isMe": true, "time": "4/18 09:20", "msg": 'Hey!' }, { "isMe": false, "time": "4/16 09:20", "msg": 'How are you?' }, { "isMe": true, "time": "4/14 09:20", "msg": 'Not Bad!' } ] ``` ## (POST) `/signup` #### 功能 註冊頁面 #### Body - `name`: 使用者設定的名稱 - `username`:使用者的學號 - `password`: 使用者設定的密碼 - `password2`:確認使用者的密碼 #### 回傳值 - 成功:回傳 `Sign in success` 訊息 - 失敗:回傳 `401` 狀態及 `Username or password is incorrect` 訊息 #### 範例 ```json= { "name":"使用者名稱", "username": "學號", "password": "123456", "password2":"123456" } ``` <br /> 使用者的學號 ## (POST) `/verify/:username` #### 功能 確認驗證碼是否正確 #### body - `verifyCode`: 使用者輸入我們寄到信箱的驗證碼 #### 回傳值 - 成功:回傳 `success` 訊息 - 失敗:回傳 `verifyCode incorrect` 訊息 #### 範例 ```json= { "verifyCode":"ABCD" } ``` <br /> ## (POST) `/login` #### 功能 登入頁面 #### Body * `username`:使用者輸入的學號 * `Password`:使用者輸入的密碼 #### 回傳值 - 成功:導向主頁 - 失敗:回傳 `登入失敗` 訊息 #### 範例 ```json= { "username": "學號", "password": "123456" } ``` <br /> ## (POST) `/upload` #### 功能 上傳圖片、選擇餐廳類別、餐廳名稱、填貼文內容 #### Body - `upload`:檔案 - `type`:餐廳類型 - `name`:餐廳名稱 - `content`:貼文內容 #### 回傳值 - 成功:回傳 "success" 訊息 - 失敗:回傳 "upload failed" 訊息 #### 前端使用 ```ejs= <form action="/upload" enctype="multipart/form-data" method="post"> <div class="form-group"> <input type="file" class="form-control-file" name="avatar"> <input type="submit" value="Get me the post!" class="btn btn-default"> </div> </form> ``` <br /> ## (GET) `/profile` #### 功能 個人頁面(系級、自我介紹⋯⋯) #### 回傳值範例 ```json= { "verifyCode":"$2b$10$eHjeqEoq5GFkPrLNG1c.Y.cofxL2vGhaWvJsEJCHwMZGmzEdNEbNa", "activated":true, "rinvited":["609fed71fe97b928ea84e13e", "609fed71fe97b928ea84e13f"], "post":[], "createdTime":"2021-05-15T15:32:34.934Z", "timer":"2021-05-15T16:10:27.001Z", "collections":[], "finvite":[], "friends":["609feb7ccb6a4f287681ba0e", "609feb76cb6a4f287681ba0d"], "grade":"NCKU ID111", "intro":"Lorem ipsum", "_id":"609feb6bcb6a4f287681ba0c", "name":"dobby", "username":"dobby", "__v":2 } ``` <br /> ## (GET) `/profile/:username` #### 功能 其他人的個人頁面(系級、自我介紹⋯⋯) <br /> ## (POST) `/editProfile` #### 功能 更新個人頁面(系級、自我介紹)(若要更新大頭照直接用"/avatar"覆寫) #### Body - `name`: 名字 - `grade`: 系級(預設 NCKU ID111) - `intro`: 自我介紹(預設 Lorem ipsum) #### File - `avatar`: 大頭照 #### html範例 ```html= <form action="/editProfile" enctype="multipart/form-data" method="post"> <div class="form-group"> <input type="file" class="form-control-file" name="avatar"> <input type="text" class="form-control" placeholder="name" name="name"> <input type="text" class="form-control" placeholder="intro" name="intro"> <input type="text" class="form-control" placeholder="grade" name="grade"> <input type="submit" value="edit!" class="btn btn-default"> </div> </form> ``` <br /> ## (GET) `/myPosts` #### 功能 個人貼文(不要被九宮格搞混了、現在的版本沒有九宮格) #### 回傳值範例 ```json= { "verifyCode":"$2b$10$Xh18HLu62o50LSHLu0u/YOaB.XKvHo9cdTeIgywV7BLen2KUfCDiO", "activated":true, "rinvited":[], "post":[{"content":"好吃!","time":"2021-05-16T13:48:45.500Z","_id":"60a12374feaa5e4a375168a7","user":"60a113e2e0b07b45dd33640a","image":"","restaurant":"60a1096b0975ce430e2b1af8","__v":0}], "createdTime":"2021-05-16T12:45:09.898Z", "timer":"2021-05-16T14:24:26.355Z", "collections":[], "finvite":[], "friends":[], "grade":"NCKU ID111", "intro":"Lorem ipsum", "_id":"60a113e2e0b07b45dd33640a", "name":"dobby", "username":"dobby", "__v":0, "image":"" } ``` <br /> ## (GET) `/allPosts` #### 功能 貼文牆(主頁)(顯示所有貼文) #### 回傳值範例 ```json= [ { "content":"好吃!", "time":"2021-05-16T13:48:45.500Z", "_id":"60a12374feaa5e4a375168a7", "user":{"verifyCode":"$2b$10$Xh18HLu62o50LSHLu0u/YOaB.XKvHo9cdTeIgywV7BLen2KUfCDiO","activated":true,"rinvited":[],"post":["60a12374feaa5e4a375168a7","60a1239dfeaa5e4a375168a8","60a123b5feaa5e4a375168a9","60a123e2feaa5e4a375168aa","60a123f7feaa5e4a375168ab"],"createdTime":"2021-05-16T12:45:09.898Z","timer":"2021-05-16T14:15:10.456Z","collections":[],"finvite":[],"friends":[],"grade":"NCKU ID111","intro":"Lorem ipsum","_id":"60a113e2e0b07b45dd33640a","name":"dobby","username":"dobby","__v":0,"image":""}, "image":"", "restaurant":{"openHour":[" 11:30 – 15:00, 17:30 – 22:00 "," 11:30 – 15:00, 17:30 – 22:00 "," 11:30 – 15:00, 17:30 – 22:00 "," 11:30 – 15:00, 17:30 – 22:00 "," 11:30 – 15:00, 17:30 – 22:00 "," 11:30 – 15:00, 17:30 – 22:00 "," 11:30 – 15:00, 17:30 – 22:00 "],"_id":"60a1096b0975ce430e2b1af8","name":"轉角餐廳","foodType":"W","address":"大學路22巷12號","photo":"ATtYBwI_QU9JrNN0j45WfkRV4gLd-5webWsIzEYK8wpiFigToJLIP_hRmZ-_O9v2om9Ur8G5SkIkiJ2KvnerDPqFvJ0kTW2WQ6N7rdtKRcqNS0fzEXo6jnNk5rCaiUIVcUag8pGrkJkSpvkjyi6AndUVVneMcLDYGn3ExduaYMMQdHEELtbq","__v":0},"__v":0}, "__v":0 }, ] ``` <br /> ## (GET) `/rInvite` #### 功能 展示公開邀請(主頁的) #### 回傳值範例 ```json= [ { "guests":["60a113e2e0b07b45dd33640a","60a11404e0b07b45dd33640b","60a1143ae0b07b45dd33640c","60a11443e0b07b45dd33640d","60a1144ce0b07b45dd33640e"], "date":"", "hour":"", "limit":0, "text":"", "_id":"60a12df5bfd1704ba80a2837", "master":{"verifyCode":"$2b$10$Xh18HLu62o50LSHLu0u/YOaB.XKvHo9cdTeIgywV7BLen2KUfCDiO","activated":true,"rinvited":["60a12df5bfd1704ba80a2837"],"post":["60a12374feaa5e4a375168a7","60a1239dfeaa5e4a375168a8","60a123b5feaa5e4a375168a9","60a123e2feaa5e4a375168aa","60a123f7feaa5e4a375168ab"],"createdTime":"2021-05-16T12:45:09.898Z","timer":"2021-05-16T14:46:31.909Z","collections":[],"finvite":[],"friends":[],"grade":"NCKU ID111","intro":"Lorem ipsum","_id":"60a113e2e0b07b45dd33640a","name":"dobby","username":"dobby","__v":1,"image":""}, "restaurant":{"openHour":[" 09:30 – 20:00 "," 09:30 – 20:00 "," 09:30 – 20:00 "," 09:30 – 20:00 "," 09:30 – 20:00 "," 休息 "," 09:30 – 20:00 "], "_id":"60a1096b0975ce430e2b1ab4","name":"港記燒臘便當","foodType":"T","address":"東安路97號","photo":"ATtYBwI3n1jWZvkub7A9VPI2v71Uo8GmdgOkztE8817hhC4kIA7rf4kKCa94SJKyfHAjC5s_D4_nUBF4elU34c61hM3N2icnFUgfcW7KkF0yUgauggSHXETIxUlyB-EX_Sga1RS_3U_NQQEACHXMLrmp-9io-2cCbPeHGCUm02b_2gAPqpJf","__v":0}, "Types":"public", "__v":0 } ] ``` <br /> ## (POST) `/rInvite/join` #### body `rInviteId`, `Types` <font color="ff0000">type 需為 ["random", "public", "friend"] 其中一個</font> #### 功能 加入公開的邀請 #### 回傳值 - 成功 `success` - 失敗 `access denial` <br /> ## (DELETE) `/rInvite/:rInviteId/dismiss` #### 功能 取消加入邀約(guest進來等於退出,master進來就會刪除邀約) #### 回傳值 - 成功 `deleted` `success` - 失敗 `access denial` <br /> ## (GET) `/rInvite/:rinviteId` 取得特定一個邀請的細節 #### 回傳值 rInvite object ```json= { "guests":["","60a113e2e0b07b45dd33640a","60a113e2e0b07b45dd33640a"], "date":"", "hour":"", "limit":0, "text":"", "_id":"60a12df5bfd1704ba80a2837", "master":{"verifyCode":"$2b$10$Xh18HLu62o50LSHLu0u/YOaB.XKvHo9cdTeIgywV7BLen2KUfCDiO","activated":true,"rinvited":["60a12df5bfd1704ba80a2837"],"post":["60a12374feaa5e4a375168a7","60a1239dfeaa5e4a375168a8","60a123b5feaa5e4a375168a9","60a123e2feaa5e4a375168aa","60a123f7feaa5e4a375168ab","60a2a0b3ae03ac6dbef5cd0a","60a2a0ceae03ac6dbef5cd0b"],"createdTime":"2021-05-16T12:45:09.898Z","timer":"2021-05-18T15:23:58.829Z","collections":["60a1096b0975ce430e2b1af8"],"finvite":[],"friends":["60a11404e0b07b45dd33640b","60a1143ae0b07b45dd33640c","60a11443e0b07b45dd33640d","60a1144ce0b07b45dd33640e"],"grade":"NCKU ID111","intro":"Lorem ipsum","_id":"60a113e2e0b07b45dd33640a","name":"dobby","username":"dobby","__v":1,"image":""}, "restaurant":null, "Types":"public", "__v":0 } ``` <br /> ## (GET) `/myRInvite/:rInviteId/delete` #### 功能 刪除自己發起的邀約(輸入餐廳ID) <br /> ## (PATCH) `/myInvite/edit` #### 功能 編輯邀約 #### body let { restId, date, hour, n, type, text } = req.body `restId` : 餐廳的_id `date` : 聚餐日期 `hour` : 聚餐時間 `n` : 限制人數 `type` : 邀約類型 `text` : 備註 <font color="ff0000">type 需為 ["random", "public", "friend"] 其中一個</font> #### 回傳 `success` `something is broken` <br /> ## (GET) `/myRInvite` #### 功能 取得自己發送過的所有邀約 #### 回傳 ```json= { "guests":["","60a113e2e0b07b45dd33640a","60a113e2e0b07b45dd33640a"], "date":"", "hour":"", "limit":3, "text":"", "_id":"60a12df5bfd1704ba80a2837", "master":{"name":"dobby","username":"dobby","verifyCode":"$2b$10$Xh18HLu62o50LSHLu0u/YOaB.XKvHo9cdTeIgywV7BLen2KUfCDiO","activated":true,"rinvited":["60a12df5bfd1704ba80a2837"],"post":["60a12374feaa5e4a375168a7","60a1239dfeaa5e4a375168a8","60a123b5feaa5e4a375168a9","60a123e2feaa5e4a375168aa","60a123f7feaa5e4a375168ab","60a2a0b3ae03ac6dbef5cd0a","60a2a0ceae03ac6dbef5cd0b"],"image":"","createdTime":"2021-05-16T12:45:09.898Z","timer":"2021-05-19T15:20:20.955Z","collections":["60a1096b0975ce430e2b1af8"],"finvite":[],"friends":["60a11404e0b07b45dd33640b","60a1143ae0b07b45dd33640c","60a11443e0b07b45dd33640d","60a1144ce0b07b45dd33640e"],"grade":"NCKU ID111","intro":"Lorem ipsum","_id":"60a113e2e0b07b45dd33640a","__v":1}, "restaurant":null, "Types":"public", "__v":0 } ``` <br /> ## (GET) `/friendRinvite` #### 功能 取得朋友發起的邀約(事實上目前的random邀約也會在這裡) #### 回傳 同上 <br /> ## (GET) `/allRInvite` #### 功能 取得所有邀約 #### 回傳 同上 <br /> ## (POST) `/random` #### 功能 選餐廳種類、隨機推薦人 #### Body `foodType`:餐廳種類 `n`:人數限制 #### 回傳值範例 ```json= { "restaurant": { name: "永林綜合料理", foodType: "T", address: "東豐路411號", openHour: [ " 11:00 – 23:30 ", " 11:00 – 23:30 ", " 11:00 – 23:30 ", " 11:00 – 23:30 ", " 11:00 – 23:30 ", " 11:00 – 23:30 ", " 11:00 – 23:30 ", ], photo: "ATtYBwL7BO9YwlBS47mdcL0ilIQ6oIEbkKtXPDWIE0Cadn1u7HUVDBuMYtYENIpyuMYaU43UyTjgK1qjtRFcNYBWjxTcCZrPkBW_zOAm2nNP_7Q2-Enlt0AsFSi90HUwzgrd2E86Fc2MBwh9bz7jvAQWw9XocmOr2i-I4RzR7Meie39qL88y", }, "people": [{ verifyCode: "$2b$10$Xh18HLu62o50LSHLu0u/YOaB.XKvHo9cdTeIgywV7BLen2KUfCDiO", activated: true, rinvited: [], post: [], image: "", createdTime: Date("2021-05-16T12:45:09.898Z"), timer: Date("2021-05-17T05:57:24.044Z"), collections: ["60a1096b0975ce430e2b1af8"], finvite: [], friends: [], grade: "NCKU ID111", intro: "Lorem ipsum", name: "dobby", username: "dobby", },{...},...] } ``` <br /> ## (POST) `/sendInvitation` #### 功能 儲存、發送公開或私人邀約 #### body let { peopleId, restId, date, hour, n, type, text } = req.body `peopleId` : 隨機推薦中 , 所要邀約的人的_id `restId` : 餐廳的_id `date` : 聚餐日期 `hour` : 聚餐時間 `n` : 限制人數 `type` : 邀約類型 `text` : 備註 <font color="ff0000">type 需為 ["random", "public", "friend"] 其中一個</font> #### 回傳 `success` `something is broken` <br /> ## (POST) `/avatar` #### 功能 上傳大頭貼照 #### 回傳值 `success` `failed` #### 前端使用 ```ejs= <form action="/avatar" enctype="multipart/form-data" method="post"> <div class="form-group"> <input type="file" class="form-control-file" name="avatar"> <input type="submit" value="Get me the post!" class="btn btn-default"> </div> </form> ``` <br /> ## (GET) `/getAvatar` #### 功能 拿到大頭貼。(測試用,應該用不到)(實際上大頭照會從user物件提取) ### 圖片解碼方式 後端使用 ```ejs= res.render("getAvatar", { pics: foundUser.image.toString("base64"), //這裡將圖片decode }); ``` 前端使用 ```ejs= <img src="data:image/png;base64,<%- pics %>" /> ``` 但這個範例是後端負責解碼,實際使用上,大部分時候是要從user物件裡面直接user.image把大頭照(base64 string)拿出來,應該會在前端解碼 <br /> ## (GET) `/restaurants/:foodType` #### 功能 顯示特定類別的餐廳 #### Body 透過 req.query.foodType 拿到類別。 #### 回傳值 `餐廳物件陣列` `failed` #### 範例 ```json= [ { "openHour":[" 11:00 – 20:30 "], "_id":"6096330db5d4331ee4826e68", "name":"半雞洋行東寧店", "class":"W", "address":"東寧路42號", "photo":"ATtYBwKVShjASmcrYVRDcnTEGuPm8NsnDi2dELS6A1doeT1TUnH_fF8e--FaAa6RVNkxoOEvBFthnX19GClP6WdAV2aKcEHCBhDy0-qCEunqRdy_FRky-CHIRzrl6-yHMCHVZyGMyIPmGli0I6iSGdurdVLqVm4KDFayylpW77wQecZ-0ug8", "__v":0 }, ... ] ``` ### 圖片解碼方式 餐廳的照片因為是固定的,還是用存路徑的方式,前端使用 ```ejs= <img src="../restaurant_images/<%-restaurants[idx].photo %>.jpg" /> ``` 即可取得,注意user, post物件底下的照片是放在(.image),但restaurant物件底下的照片是放在(.photo) <br /> ## (GET) `/restaurants/:restID/posts` #### 功能 找到一個餐廳的所有貼文 #### 回傳值 貼文(post)物件陣列 ```json= [ { "content": "elf", "time": "2021-05-15T13:37:39.657Z", "restaurant": "6096330db5d4331ee4826e5a", "_id": "609fcf3439c593200349f051", "username": "dobby", "image": "超大字串" "__v": 0 }, ... ] ``` <br /> ## (GET) `/restaurants/:restID/collections` #### 功能 加入收藏與取消收藏。 #### Body restID: restaurant 的 _id #### 回傳值 ```json= [ { "openHour":[" 休息 "," 15:00 – 21:00 "," 15:00 – 21:00 "," 15:00 – 21:00 "," 15:00 – 21:00 "," 15:00 – 21:00 "," 15:00 – 20:00 "], "_id":"6096330db5d4331ee4826e71", "name":"鴻達臭豆腐", "class":"T", "address":"東安路84號", "photo":"ATtYBwLLETu18zI9QVYXsXaGmOjWRjpbWfVfhT2WSvrRaKNVsEOMz35D8volf_JzV1fGwtW1jtcUkqpVBdcSiucjOA3ZsV5_Kau2BcwYH_wh2Zlma2DMytO9A9VVogo3n6RYFzTVo3on7IDjmS4YGTi3jeCd_Drt42u0sp0F0X-WgPc-Q7PO", "__v":0 }, ... ] ``` `no such restaurant ID` <br /> ## (GET) `/listCollections/:username` #### 功能 列出某人的收藏清單 #### Body username: student's ID #### 回傳值 `收藏清單(餐廳物件陣列)` `no such username` ```json= [ { "openHour":[" 休息 "," 15:00 – 21:00 "," 15:00 – 21:00 "," 15:00 – 21:00 "," 15:00 – 21:00 "," 15:00 – 21:00 "," 15:00 – 20:00 "], "_id":"6096330db5d4331ee4826e71", "name":"鴻達臭豆腐", "class":"T", "address":"東安路84號", "photo":"ATtYBwLLETu18zI9QVYXsXaGmOjWRjpbWfVfhT2WSvrRaKNVsEOMz35D8volf_JzV1fGwtW1jtcUkqpVBdcSiucjOA3ZsV5_Kau2BcwYH_wh2Zlma2DMytO9A9VVogo3n6RYFzTVo3on7IDjmS4YGTi3jeCd_Drt42u0sp0F0X-WgPc-Q7PO", "__v":0 }, ... ] ``` <br /> ## (GET) `/restaurants/:restID/isCollected` #### 功能 查看使用者是否有收藏此餐廳 #### 回傳值 - 成功 - isCollected:true or false - 失敗 <br /> ## (GET) `/fInvite/:inviteTo` #### 功能 發送交友邀請(輸入對方學號) #### 回傳值 `success` `already friends` or `already inviting` or `no such username` <br /> ## (GET) `/fInvite/:inviteTo/confirm` #### 功能 確認交友邀請(輸入對方學號) #### 回傳值 `success` `already friends` or `no such username` or `no such invite` <br /> ## (GET) `/fInvite/:inviteTo/unFriend` #### 功能 刪除好友(輸入對方學號) #### 回傳值 `success` `no such friend` 或 `no such username` <br /> ## (GET) `/fInvite/:inviteTo/delete` #### 功能 刪除交友邀請(輸入對方學號) #### 回傳值 `success` `no such finvite` 或 `no such username` <br /> ## (GET) `/listFinvites` #### 功能 交友邀請列表 #### 回傳值 ```json= [ {"name":"dobby","username":"dobby","verifyCode":"$2b$10$Xh18HLu62o50LSHLu0u/YOaB.XKvHo9cdTeIgywV7BLen2KUfCDiO","activated":true,"rinvited":["60a503c4afec19a771558a95","60a503cdd5628aa77a7fe763"],"post":["60a12374feaa5e4a375168a7","60a1239dfeaa5e4a375168a8","60a123b5feaa5e4a375168a9","60a123e2feaa5e4a375168aa","60a123f7feaa5e4a375168ab","60a2a0b3ae03ac6dbef5cd0a","60a2a0ceae03ac6dbef5cd0b"],"image":"","createdTime":"2021-05-16T12:45:09.898Z","timer":"2021-05-25T05:33:37.336Z","collections":["60a1096b0975ce430e2b1af8"],"finvite":[],"friends":[],"grade":"NCKU ID111","intro":"Lorem ipsum","_id":"60a113e2e0b07b45dd33640a","__v":1} ] ``` 失敗 failed <br /> ## (GET) `/listFriends` #### 功能 好友列表 #### 回傳值 成功 ```json= [ { "verifyCode":"$2b$10$sCMPqjqjhaOXcQV3sqMKKuGba8iLFNJuKdXPkVamCke4mz8WYvfaS", "activated":true, "rinvited":[], "post":[], "createdTime":"2021-05-15T15:32:34.934Z", "timer":"2021-05-15T15:32:34.934Z", "collections":[], "finvite":[], "friends":["609feb6bcb6a4f287681ba0c"], "grade":"NCKU ID111", "intro":"Lorem ipsum", "_id":"609feb7ccb6a4f287681ba0e", "name":"test2", "username":"test2", "__v":0 }, ... ] ``` 失敗`failed` <br /> ## (GET) `/listFriends/:username` #### 功能 別人的好友列表 #### 回傳值 同上 ## (GET) `/game` #### 功能 取得遊戲題目 #### 回傳值 ``` {"questions":["餃子","包子"],"_id":"60c78f473de2293ecc3e7b01","__v":0} ``` ## (POST) `/game/add` #### 功能 新增遊戲題目 #### Body q1:第一個題目 q2:第二個題目 #### 回傳值 `成功`:` save successfully` `失敗`:` save failed` ### check Online or not ```js= if ((Date.now() - user.timer) / 1000 > 300) { 不在線上 } else{ 在線上 } ``` ### 計算多久以前 ```ejs= <h1>This is your post!</h1> <%=imagePath %> <div id='demo'></div> <script> var d = new Date(); var current = d.valueOf(); current = Date.parse("2021-05-07T03:40:54.735Z") //放物件裡的time document.getElementById("demo").innerHTML = fromNow(current); function fromNow(date) { var seconds = Math.floor((new Date() - date) / 1000); var years = Math.floor(seconds / 31536000); var months = Math.floor(seconds / 2592000); var days = Math.floor(seconds / 86400); if (days > 548) { return years + " years ago"; } if (days >= 320 && days <= 547) { return "a year ago"; } if (days >= 45 && days <= 319) { return months + " months ago"; } if (days >= 26 && days <= 45) { return "a month ago"; } var hours = Math.floor(seconds / 3600); if (hours >= 36 && days <= 25) { return days + " days ago"; } if (hours >= 22 && hours <= 35) { return "a day ago"; } var minutes = Math.floor(seconds / 60); if (minutes >= 90 && hours <= 21) { return hours + " hours ago"; } if (minutes >= 45 && minutes <= 89) { return "an hour ago"; } if (seconds >= 90 && minutes <= 44) { return minutes + " minutes ago"; } if (seconds >= 45 && seconds <= 89) { return "a minute ago"; } if (seconds >= 0 && seconds <= 45) { return "a few seconds ago"; } } </script> ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully