目錄 Table of Contents
一個以 Node.js 和 Express 製作的短網址產生器。 使用了 MongoDB 來儲存資料。
- 產生隨機五位數英數混和的縮址
- 產生過縮址的網站會沿用既有縮址
- 產生的縮址與舊有的縮址不會重複
如果要使用 npm run dev
的指令,需先安裝 nodemon。
- nodemon
npm install -g nodemon
必須於使用 mongoDB + mongoose 的環境下執行。
- 在要安裝的位置開啟終端機(terminal) clone 專案檔案
git clone https://github.com/Prysline/S5A8_URLshortener.git
- 進入專案資料夾
cd S5A8_URLshortener
- 安裝所需套件
npm install
- 建立種子資料 (須連線 mongoDB 伺服器)
npm run seed
- 使用 Node.js 執行 Express 伺服器(更新檔案時需要另外 ctrl+C 退出 Node.js 環境並重新啟動)
或是使用 nodemon 執行 Express 伺服器(會在檔案變更時自動重啟伺服器,需安裝 nodemon)
npm run start
npm run dev
- 在瀏覽器網址列輸入
http://localhost:3000/
瀏覽網站
使用 MIT License。