Files
email-unlimit/server/README.md
T

57 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Email Unlimited Server
Rust + Axum 实现的临时邮箱 HTTP API 与 SMTP 收信服务。
## 启动
开发环境默认使用 SQLite
```powershell
cargo run
```
指定配置与环境:
```powershell
cargo run -- --env production --config config/production.toml
```
嵌套环境变量使用双下划线分隔:
```powershell
$env:DATABASE__DATABASE_TYPE = "mysql"
$env:DATABASE__HOST = "localhost"
$env:DATABASE__PORT = "3306"
$env:DATABASE__USER = "root"
$env:DATABASE__PASSWORD = "your-password"
$env:DATABASE__DATABASE = "email_unlimit"
$env:AUTH__JWT_SECRET = "replace-with-at-least-32-random-characters"
$env:AUTH__INVITE_CODE = "replace-with-at-least-16-random-characters"
$env:AUTH__BOOTSTRAP_ADMIN_EMAIL = "admin@example.com"
$env:SMTP__BODY_ENCRYPTION_KEY = "0123456789abcdef0123456789abcdef"
cargo run -- --env production
```
## 核心接口
- `GET /health`
- `POST /auth/register`
- `POST /auth/login`
- `POST /auth/refresh`
- `GET|POST /api/mailboxes`
- `GET /api/mailboxes/:id/emails`
- `GET /api/mailboxes/:id/ws`
- `GET /admin/stats`
- `GET|PATCH /admin/users`
`/api` 路由使用用户或邮箱令牌,`/admin` 路由同时要求有效用户 JWT 与 `admin` 角色。
## 验证
```powershell
cargo test
cargo check
```
更完整的资料位于 `docs/`