nex_basse/backend/ENV.md

44 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 环境配置说明
本项目默认使用 `.env` 读取配置。请复制 `backend/.env.example``backend/.env` 后填写。
## Database Support
- Default: PostgreSQL (DB_TYPE=postgresql)
- Supported: MySQL (set `DB_TYPE=mysql` in `.env`)
## PostgreSQL
- Version 12+
- Default port: 5432
- Use `backend/scripts/convert_sql.py` to convert MySQL dumps if needed.
## MySQL
- 开发环境 MySQL 5.7,生产 MySQL 8.0+
- 表字符集:`utf8mb4`,排序规则:`utf8mb4_unicode_ci`
## Redis
- 主要用于 token、黑名单与异步任务状态
## Token 过期时间
- 默认从环境变量读取
- **正式逻辑**:存入系统参数 `sys_param`
- `security.access_token_minutes`
- `security.refresh_token_minutes`
## 启动示例
```bash
cd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
```
## 初始化数据库
1. 先执行 `backend/docs/init_mysql.sql`
2. 初始化管理员账号默认admin / 123456
```bash
cd backend
source .venv/bin/activate
python -m scripts.init_admin
```