將長網址轉換為短網址的工具,使得URL更簡潔、易於分享和使用
- 使用者可以在表單輸入原始網址
按下Shorten送出表單之後,畫面會回傳相對應的短網址
- 網址可以直接按copy複製至剪貼簿
- 網址列空白即送出會出現提示
- 點擊中間迴紋針圖示會回到首頁
- Node.js
- express 4.17.1
- express-handlebars 4.0.2
- nodemon 2.0.22
- MongoDB Atlas 資料庫
- Robo 3T 資料庫管理工具
- Mongoose 5.13.19
- dotenv 16.3.1
- 請先確認已安裝Node.js,若無,至環境建置第1項點擊安裝
- 請先至MongoDB Atlas雲端資料庫申請及使用Robo 3T創建資料庫後取得以下連線字串
mongodb+srv://<Your account>:<Your password><server location>/<database name>?retryWrites=true&w=majority
- 開啟終端機(Terminal),指令cd到欲放置專案位置,Clone此專案至本機電腦
git clone https://github.com/boxunw/url_shortener.git
- 打開專案資料夾
cd url_shortener
- 新建.env檔案,並貼上以下字串
MONGODB_URI=第2項取得的連線字串
- 安裝 npm 套件
npm install
- 開啟程式
npm run dev
- 等待終端機出現以下字樣
mongodb connected!
- 在瀏覽器輸入以下網址即可開始使用此工具
http://localhost:3000

