一個簡單的會員認證機制。
{
firstName: 'Tony',
email: 'tony@stark.com',
password: 'iamironman'
},
{
firstName: 'Steve',
email: 'captain@hotmail.com',
password: 'icandothisallday'
},
{
firstName: 'Peter',
email: 'peter@parker.com',
password: 'enajyram'
},
{
firstName: 'Natasha',
email: 'natasha@gamil.com',
password: '*parol#@$!'
},
{
firstName: 'Nick',
email: 'nick@shield.com',
password: 'password'
}
- 打開你的 terminal,Clone 此專案至本機電腦
git clone https://github.com/AlanChiangg/account-login.git
- 開啟終端機(Terminal),進入存放此專案的資料夾
cd account-login
- 安裝 npm 套件
npm install
- 安裝 nodemon 套件
npm i -g nodemon
- 安裝完畢後,設定環境變數連線 MongoDB
MONGODB_URI=mongodb+srv://<Your MongoDB Account>:<Your MongoDB Password>@cluster0.xxxx.xxxx.net/<Your MongoDB Table><?retryWrites=true&w=majority
- 加入預設帳密到資料庫
npm run seed
- 啟動伺服器,執行 app.js 檔案
npm run dev
- 當 terminal 出現以下字樣,表示伺服器與資料庫已啟動並成功連結
Express is running on http://localhost:3000
- Visual Studio Code - 開發環境
- Express - 應用程式架構
- Express-Handlebars - 模板引擎
- MongoDB - 資料庫
