快速参考¶
Shortener 项目的常用命令快速参考。
📦 安装¶
# 从源码构建
cargo build --release
# 安装 CLI
cargo install --path shortener-cli
# Docker
docker compose up -d
🚀 运行¶
📚 文档¶
🔨 开发¶
# 格式化代码
cargo fmt
# 代码检查
cargo clippy
# 运行测试
cargo test
# 监视更改
cargo watch -x 'run -p shortener-server'
🐳 Docker¶
# 构建镜像
make build # 或 just docker-build
# 运行(生产)
make run # 或 just docker-run
# 运行(开发)
make run-dev # 或 just docker-run-dev
# 查看日志
make logs # 或 just docker-logs
# 停止
make stop # 或 just docker-stop
🧪 测试¶
📖 CLI 命令¶
# 初始化
shortener-cli init
# 创建短链接
shortener-cli create https://example.com
# 获取详情
shortener-cli get <code>
# 列出所有
shortener-cli list --all
# 更新
shortener-cli update <code> --ourl <new-url>
# 删除
shortener-cli delete <code>
🔧 配置¶
🌐 API¶
# 登录
curl -X POST http://localhost:8080/api/account/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"password"}'
# 创建短链接
curl -X POST http://localhost:8080/api/shortens \
-H "X-API-KEY: your-api-key" \
-H "Content-Type: application/json" \
-d '{"original_url":"https://example.com"}'
# 获取短链接
curl http://localhost:8080/api/shortens/<code> \
-H "X-API-KEY: your-api-key"
🔐 安全¶
📊 性能¶
🛠️ 部署¶
# Systemd
cd deploy/systemd
sudo ./install.sh
sudo systemctl start shortener-server
# Docker
docker-compose -f docker/docker-compose.yml up -d
# 交叉编译
./scripts/build-cross.sh --all
📝 贡献¶
# Fork 并克隆
git clone https://github.com/你的用户名/shortener.git
# 创建分支
git checkout -b feature/your-feature
# 提交更改
git commit -m "添加:your feature"
# 推送
git push origin feature/your-feature
🔗 链接¶
📋 检查清单¶
开发前¶
- [ ] 安装 Rust 1.90+
- [ ] 克隆仓库
- [ ] 安装开发工具
- [ ] 阅读贡献指南
提交前¶
- [ ] 运行
cargo fmt - [ ] 运行
cargo clippy - [ ] 运行
cargo test - [ ] 更新文档
- [ ] 编写提交信息
部署前¶
- [ ] 运行所有测试
- [ ] 更新版本号
- [ ] 构建发布版本
- [ ] 测试部署
提示: 使用 just --list 或 make help 查看所有可用命令。