feat(server): free tier with 3 monthly credits
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const { get, run } = require('./postgres');
|
||||
|
||||
const FREE_MONTHLY_CREDITS = 0;
|
||||
const FREE_MONTHLY_CREDITS = 3;
|
||||
const TRIAL_MONTHLY_CREDITS = 30;
|
||||
const PRO_MONTHLY_CREDITS = 100;
|
||||
const TOPUP_DEFAULT_CREDITS = 100;
|
||||
@@ -255,7 +255,6 @@ const getOrCreateAccount = async (db, userId) => {
|
||||
};
|
||||
|
||||
const getAvailableCredits = (account) => {
|
||||
if (account.plan !== 'pro') return 0;
|
||||
const monthlyRemaining = Math.max(0, account.monthlyAllowance - account.usedThisCycle);
|
||||
return monthlyRemaining + Math.max(0, account.topupBalance);
|
||||
};
|
||||
@@ -570,9 +569,6 @@ const syncRevenueCatWebhookEvent = async (db, eventPayload) => {
|
||||
|
||||
const consumeCredits = (account, cost) => {
|
||||
if (cost <= 0) return 0;
|
||||
if (account.plan !== 'pro') {
|
||||
throw createInsufficientCreditsError(cost, 0);
|
||||
}
|
||||
|
||||
const available = getAvailableCredits(account);
|
||||
if (available < cost) {
|
||||
|
||||
Reference in New Issue
Block a user