Skip to main content

路径

GET /user/referral-info

认证

Bearer JWT(supabaseAuth(),挂在 app.use("/referral-info", ...)

响应

{
  totalCreditsEarned: number,        // invitedUsers.length * 50
  invitedUsers: Array<{
    id: string,
    nickname: string,                // 缺失时 ""
    avatarUrl: string,               // uuid 走 cdn.sign,缺失/失败回退 DEFAULT_AVATAR_URL
    credits: 50                      // 每个被邀用户固定 50
  }>
}

逻辑

  1. user_profiles where invited_by = userId and id != userId,按 created_at 倒序
  2. batchGetAvatarUrls 批量解析头像 URL(uuid → cdn.sign 公开 URL,path → 拼 supabase)
  3. 每个被邀用户固定计 credits: 50totalCreditsEarned = 人数 × 50
邀请奖励为每位被邀用户 50 credit(代码中硬编码 credits: 50totalCreditsEarned = users.length * 50)。referral 归属由 user_profiles.invited_by 记录。

错误

状态码含义
401无 JWT / jwtPayload.sub 缺失
500Supabase 查询失败

src/hono/user/index.tsGET /referral-info

相关