All files / src/utils subscriptionTiers.js

100% Statements 2/2
100% Branches 0/0
100% Functions 0/0
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                              16x           16x  
/**
 * Single source of truth for the productId → subscription-tier map.
 *
 * Both `routes/economy.js` (purchase grant path) and
 * `routes/apple-notifications.js` (refund / expiry / revoke path) read
 * from this. Previously the same map was duplicated in both files; that
 * meant adding a new tier (e.g. a quarterly SKU or a localised
 * promotional offer) only on the purchase side would silently break the
 * refund side — the refund handler would log a warning, ack with 200,
 * and the user would keep their entitlement after a refund. Centralising
 * the map here makes that drift impossible.
 *
 * `tier` is the value persisted to `users.superShyTier`.
 * `days` is the entitlement length (`null` = lifetime / never expires).
 */
const SUBSCRIPTION_TIERS = Object.freeze({
  super_shy_monthly: { tier: 'monthly', days: 30 },
  super_shy_yearly: { tier: 'yearly', days: 365 },
  super_shy_lifetime: { tier: 'lifetime', days: null },
});
 
module.exports = { SUBSCRIPTION_TIERS };