路径
POST /reward/daily
认证
Bearer JWT(整个/reward/* 挂 supabaseAuth())
响应
成功补充:逻辑
free-plan 用户每 24h 一次将 credit 补满到 15(不是叠加,是update credit = 15)。
资格判定 eligible 同时满足三条:
- 距上次发放
last_credit_issued_at≥ 24h(24 * 60 * 60 * 1000ms) - 当前
credit < 15 plan === "free"
last_credit_issued_at 为 null(从未发过 / 非 free 历史)直接返回 not-eligible message。
满足条件时:
- 入队
daily_emailPGMQ 消息(sleep_seconds: 86400,次日触发邮件提醒) update user_profiles set last_credit_issued_at = now, credit = 15
从 kira-sg-billing 迁过来(不该和 Stripe 路由放一起)。补充是「补满到 15」而非加 15,已有 credit ≥ 15 不符合条件。
错误
| 状态码 | 含义 |
|---|---|
| 401 | 无 JWT / jwtPayload.sub 缺失 |
| 404 | user_profiles 行不存在 |
| 500 | Supabase 查询失败 |
源
src/hono/reward/index.ts(POST /daily)
相关
- GET /user/profile(看
credit/lastCreditIssuedAt) - Queue (PGMQ)