Item 2 — founder counter is REAL or hidden (kills the hardcoded 47/100)

ClaimMeter rendered a fabricated "47 / 100 CLAIMED" (a hardcoded default; the
comment even said "Cosmetic conversion driver… Static here"). Now:

- GET /api/founders/count counts ONLY real paying founders — user_profiles
  where founder_pricing = true AND subscription_status = 'active' (the
  Stripe-webhook-synced mirror, so we never hammer the Stripe API). Cached 5
  min in Redis on top of that.
- If the source is unavailable (Supabase unconfigured, query error, column not
  migrated, client throws) the endpoint returns { available: false } and the
  ClaimMeter renders NOTHING — counter and progress bar both hidden. We never
  fall back to a number.
- A low real count is shown honestly (0 → "0 / 100"); the truth is the feature.

Next proxy at app/api/founders/count. 6 route tests cover real count, low
count, error/unconfigured/throw → hidden, and cache-hit. Suite 271/3260 green,
web build exit 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kev
2026-07-17 15:32:18 -04:00
parent 66d52a9ce0
commit 41fc2b90e2
5 changed files with 203 additions and 5 deletions
+25
View File
@@ -0,0 +1,25 @@
import { NextResponse } from 'next/server';
export const dynamic = 'force-dynamic';
const BACKEND_URL = process.env.BACKEND_URL || 'http://localhost:3000';
/**
* Founder-seat count proxy (Truth-Everywhere Part 2, item 2) — forwards
* GET /api/founders/count to Express (real active paying founders). On any
* upstream failure we return { available: false } so the ClaimMeter HIDES —
* never a fabricated number.
*/
export async function GET() {
try {
const upstream = await fetch(`${BACKEND_URL}/api/founders/count`, {
method: 'GET',
headers: { Accept: 'application/json' },
cache: 'no-store',
});
const data = await upstream.json().catch(() => ({ available: false }));
return NextResponse.json(data, { status: upstream.ok ? 200 : 200 });
} catch {
return NextResponse.json({ available: false }, { status: 200 });
}
}
+31 -5
View File
@@ -1,17 +1,43 @@
'use client';
import { useEffect, useState } from 'react';
import SectionHead from '@/components/vyndr/SectionHead';
interface ClaimMeterProps {
interface FounderCount {
available: boolean;
claimed?: number;
total?: number;
}
/**
* Founder-seat scarcity meter (§12 ClaimMeter) — "47 / 100 seats claimed",
* amber bar. Cosmetic conversion driver; the live tick-up wires into the
* living layer in Session 38. Static here.
* Founder-seat scarcity meter (§12 ClaimMeter).
*
* TRUTH LAW (Truth-Everywhere Part 2, item 2): this used to render a hardcoded
* "47 / 100 CLAIMED". It now fetches the REAL count of active paying founders
* from /api/founders/count (Stripe-synced, cached). If the source is
* unavailable — or the fetch fails — the counter and progress bar HIDE
* entirely. We never fall back to a number. A low real count is fine; the
* truth is the feature.
*/
export default function ClaimMeter({ claimed = 47, total = 100 }: ClaimMeterProps) {
export default function ClaimMeter() {
const [data, setData] = useState<FounderCount | null>(null);
useEffect(() => {
let active = true;
fetch('/api/founders/count', { cache: 'no-store' })
.then((r) => r.json())
.then((d) => { if (active) setData(d); })
.catch(() => { if (active) setData({ available: false }); });
return () => { active = false; };
}, []);
// Hide until we have a REAL number. Unavailable source → render nothing.
if (!data || !data.available || typeof data.claimed !== 'number') return null;
const total = data.total || 100;
const claimed = Math.max(0, Math.min(total, data.claimed));
const pct = Math.min(100, Math.round((claimed / total) * 100));
return (
<div style={{ maxWidth: 420, margin: '0 auto', width: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginBottom: 8 }}>