安装
环境要求
| 依赖 | 版本 |
|---|---|
| Node.js | 18+ |
| Redis | 5.6+ |
| PostgreSQL | 14+(推荐) |
| npm | 9+ |
克隆与依赖
git clone <repository-url>
cd lottery
cd backend && npm install
cd ../frontend && npm install
Redis
# macOS
brew install redis && brew services start redis
# 验证
redis-cli ping # PONG
PostgreSQL
配置 DATABASE_URL 后:
cd frontend
npx prisma migrate dev
cd ../backend
npx prisma generate
环境变量(最小集)
Backend backend/.env
PORT=4000
FRONTEND_URL=http://localhost:3000
REDIS_URL=redis://localhost:6379
JWT_SECRET=<openssl rand -base64 32>
DATABASE_URL=postgresql://...
DEFAULT_ROOM_ID=main_room
Frontend frontend/.env.local
NEXT_PUBLIC_API_BASE=http://localhost:4000
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=<random>
JWT_SECRET=<与 backend 相同>
STAFF_ADMIN_PASSWORD=<admin 登录密码>
STAFF_DISPLAY_PASSWORD=<display 登录密码>
NEXT_PUBLIC_THEME=spring
Staff 邮箱白名单在 frontend/src/lib/auth.ts 的 ADMIN_EMAILS / DISPLAY_EMAILS。
一键启动
chmod +x start.sh && ./start.sh