andythebreaker
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    --- title: 本組後端測試架構 lang: zh-tw tags: uidd --- # 本組後端測試架構 [![hackmd-github-sync-badge](https://hackmd.io/MljZQswSSpWniVF3iMY_cQ/badge)](https://hackmd.io/MljZQswSSpWniVF3iMY_cQ) --- ## 前端的vw要改 成`var(--var_vw)` 例如`94vw`要成為`calc(var(--var_vw)*94)` ## 對全域(windows)的100%要改 成`var(--var_vw)*100` 例如 ```=css #menu_back { position: absolute; width: calc(var(--var_vw)*100); height: calc(var(--var_vw)*23 + 3vh); bottom: 0px; z-index: 5; } ``` 的width ## 對全域(windows)的right要改 成`var(--var_right_global_displacement)` 例如 ```=css #medal_block { z-index: 5; position: absolute; width: calc(var(--var_vw)*18); right: calc(var(--var_right_global_displacement) + 5%); top: calc(var(--var_vw)*20); text-align: center; } ``` --- ## 以下的東西是之前的...留著給大家參考 --- ## how to get usr. info. @ front end (html, js) 動物: document.getElementById('jade_user_info_choosedanimal').innerText ![](https://i.imgur.com/MGOVwZF.png) ## 各url代表的jade檔案所在位置 主頁面+發文:/view/main 選角:/view/layout 其中所有的html發送router需使用 ```javascript= router.get('/', ensureAuthenticated, function (req, res, next) { Person.getPersonal(req.user.username, function (err, Personget) { if (err) throw err; res.render('main', { title: 'old_friend', var_jade_user_info_name: `${req.user.name}`, var_jade_user_info_username: `${req.user.username}`, var_jade_user_info_profileimage: `${req.user.profileimage}`, var_jade_user_info_choosedanimal: `${(!Personget)?'-1':Personget.animal}` }); }); }); ``` 方可正常作動 ## 密碼與私鑰保護 請至雲端硬碟「密碼與私鑰」資料夾下載裡面的Variouskeys資料夾,整個放到本REPO中方可運作 ## 下載完REPO的初始化 請先`npm i`再做其他動作 ## Facebook登入,跟老師說的都不一樣 原本做的是前端的登入,但是問題是:怎麼確定前端登入完的資訊傳到後端不會被修改 修正方式 https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow?locale=zh_HK 參考資料 https://ithelp.ithome.com.tw/articles/10197391 使用套件 http://www.passportjs.org/ https://github.com/jaredhanson/passport-facebook 套件參數 ['id', 'name', 'displayName', 'gender', 'emails', 'photos', 'hometown', 'profileUrl', 'friends'] --- ## TODO list - [ ] keep刪除時的作動,會造成後端程式碼crash > 錯誤如下 ![](https://i.imgur.com/iCcPiYc.png) - [ ] 捲動更新,當內容物太少,無法捲動時,無法更新 > 錯誤如下 ![](https://i.imgur.com/rQqLVCr.png) - [ ] 把發文時間記在硬碟中,看是要把那個記錄檔變成隱藏檔,還是要用其他方法去紀錄<<<這是一個次級的錯誤,不用改只要會動也沒關係>>> > code: ```javascript= fs.writeFile(`${__dirname}/poops.json`, newpooptime, (err) => { if (err) throw err var id = {}; id["id"] = newPoop._id; res.status(200).send(JSON.stringify(id)); }) ``` - [ ] 前端的css、js請一律放在resources資料夾 (與html分開) > img放在`resources/img` - [ ] 主程式清理,請地圖合成進主程式;刪除在後端repo中FBlogin資料夾 - [ ] FB登入還沒合併進入主程式...待做 - [ ] 各個router要加上使用這驗證(看line群組) ## 使用... - luffy - node js - Express - mongo db - passport ## fast setup 1. go to luffy 2. `vi backend_setup.sh` 3. paste these code #### 诶那個帳密請帶入自己的帳密ㄋㄟ,不要傻傻的 ```bash= #!/bin/bash cd ~ mkdir backend_try cd backend_try npm install express npm install express-generator git clone https://github.com/andythebreaker/backend_pet.git cd backend_pet mkdir ../garbage mv node_modules ../garbage rm *.txt rm package-lock.json rsync -r . .. cd .. search='mongodb://localhost:27017/nodeauth' replace='mongodb://帳:密@140.116.132.223:27017/petdatabase_dev' filename='./models/user.js' sed -i "s#${search}#${replace}#gi" $filename # Ask the user for their name echo enter a port you like: read varname search='3000' filename='./bin/www' sed -i "s#${search}#${varname}#gi" $filename npm install npm start ``` 4. `sh backend_setup.sh` 5. it will ask for port, type something (e.g.:19812) 6. 如果你有放乖乖的話,他應該會跑...一直跑 7. 打開瀏覽器,輸入`luffy.ee.ncku.edu.tw:[port]` you'll see this ![](https://i.imgur.com/PSQId9i.png) 8. you can input - username`nini` - password`nini` 9. you will then see welcome 10. you can find a log out btn., press it, then logout 11. 可以任意測試註冊等等行為 ##### 關閉後還要啟動 1. `cd ~/backend_try` 2. `npm start` ##### mongodb資料庫gui 參考本文件最末端:「附加文件」章節 可以照「附加文件」中描述的方法以gui查看此資料庫 ###### 更多gui軟體 - Studio 3T - MongoDBCompass #### 更多測試(無前端的api測試) ##### 所需軟體(windows) - postman - wireshark ##### 使用postman完成無前端的api測試 1. `post` `luffy.ee.ncku.edu.tw:[port]/users/login` body 設定 `X-www......` ![](https://i.imgur.com/3ZQHXyV.png) 2. 送出 3. `get` `luffy.ee.ncku.edu.tw:[port]/users/logout` body設定可以空白 4. 可以再做更多測試...也沒幾個指令啦 ## 教學與參考 這些程式碼在幹嘛請看以下url https://ithelp.ithome.com.tw/articles/10189263 ### 注意 這份教學文件因年代久遠,有諸多錯誤,使用上還需多加留意 可參考`https://github.com/andythebreaker/backend_pet.git`做出的實踐 適用日期在20210331測試可行 ## 附加文件 請至本組共用雲端硬碟>全域資源>技術文件>資料庫>下載其中的`pptx`檔案 - 其中第1至5頁描述了在本次實作中所採與用的mongodb資料庫 - 第6至9頁描述了如何以gui查看此資料庫 - 剩下的部分描述了一些注意事項 ###### 針對本次實作中所使用的資料庫 錯誤或待修正 - 存取權限未配置 - luffy以後會提供有配置好存取權限的帳號 ## 常見錯誤 ![](https://i.imgur.com/4BBXCxO.png) ![](https://i.imgur.com/hy1EnR1.png) ![](https://i.imgur.com/gq9nw3S.png) ### 解法 請查看專案根目錄中如下檔案 ![](https://i.imgur.com/Rf9OqvK.png) 並將該檔案中資料庫路徑更正(參考上方`.sh`程式碼) 須更正的東東如下 ![](https://i.imgur.com/YxSFzbf.png) --- {%hackmd B145hRQ2U %}

    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
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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