快速開始
步驟
- 建立設定檔
sh
cd api-service/config
cp carbonbond.toml carbonbond.dev.toml
- 安裝 rust
見 rust 設置。
- 設定資料庫
依照 資料庫設置 設定資料庫,以及 carbonbond.dev.toml 設定檔。
- 資料庫遷移
sh
cd api-service
cargo run --bin prepare --features=prepare -- -m;
cargo run --bin prepare --features=prepare -- -cm;
- 啓動後端伺服器
sh
cd api-service
env RUST_LOG=debug cargo run
- 安裝 Node.js
見 前端設置。
- 啓動前端伺服器
sh
cd frontend
yarn install # 第一次啓動需先安裝套件
yarn workspace web dev
本步驟完成後,前端、後端、資料庫都已準備好了,現在在瀏覽器開啓 http://localhost:3000 ,就可以喜迎碳鍵啦!接下來,我們往資料庫塞一些資料。
- 使用 dbtool 創建使用者
sh
cd api-service
cargo run --bin dbtool
會進入到一個交互式命令環境,輸入
add user <帳號> <密碼> <信箱>
來創建一或多個使用者。
- 使用 yarn inject 灌入預設看板
sh
yarn inject
根據交互式命令環境的提示完成操作,它會用到上一步在 dbtool 創建的帳密,故請務必先完成上一步。
小結
至此,開啓 http://localhost:3000 ,就能看到幾個預設看板跟文章囉!
tmux 腳本
以上安裝編譯器、灌入看板等等操作只要執行一次就好了,在開發階段,你通常只需要一個腳本
sh
sh run.sh
以 tmux 開啓三個視窗,同時監看
- cargo run
- yarn dev
- tsc --watch
的輸出,是您開發的必備良伴。
重啓伺服器
在任一 tmux 視窗中用 ctrl-c 殺掉伺服器之後,tmux 視窗會在左下角顯示 Pane is Dead,此時 ctrl-b + r 可使 tmux 命令重跑,也就能重啓伺服器。