Skip to main content

路径

POST /reward/daily

认证

Bearer JWT(整个 /reward/*supabaseAuth()

响应

成功补充:
{ "lastCreditIssuedAt": "2026-06-03T12:00:00.000Z", "credit": 15 }
不符合条件 / 已领取:
{ "message": "You have already received your daily credit or you are not eligible for it." }

逻辑

free-plan 用户每 24h 一次将 credit 补满到 15(不是叠加,是 update credit = 15)。 资格判定 eligible 同时满足三条:
  1. 距上次发放 last_credit_issued_at ≥ 24h(24 * 60 * 60 * 1000 ms)
  2. 当前 credit < 15
  3. plan === "free"
特殊:last_credit_issued_at 为 null(从未发过 / 非 free 历史)直接返回 not-eligible message。 满足条件时:
  • 入队 daily_email PGMQ 消息(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 缺失
404user_profiles 行不存在
500Supabase 查询失败

src/hono/reward/index.tsPOST /daily

相关