New public /ueber-uns page — deliberately doesn't preview or link into the platform itself (no phone mockup, no post previews), just the founding story plus live member/pet/sponsor counts for transparency. Fully bilingual via the existing LanguageSwitcher. - src/trpc/routers/stats.ts: new public stats.getPublicStats procedure, Redis-cached (5min TTL), sponsor count includes lapsed subscriptions (not just currently-active badges) per discussion on the issue. - src/proxy.ts: /ueber-uns registered as a public route, exempt from maintenance mode (doesn't touch the platform, so no reason to gate it). - Extracted LandingHeader/LandingFooter from src/app/page.tsx into shared components under src/components/landing/ — this page reuses the same navbar, and duplicating it risked the responsive header fixes from earlier today drifting out of sync between two copies. The "Bald verfügbar" placeholder nav link now points at the real page. - src/lib/stripe.ts: made the Stripe client a lazy singleton instead of constructing it at module scope. Eager construction crashed the entire tRPC appRouter (and anything importing it, e.g. createTRPCCaller() on any public page) whenever STRIPE_SECRET_KEY is unset — invisible until now because no public page had used createTRPCCaller() before. - stats.getPublicStats wraps its Redis cache read/write in .catch() so a Redis outage degrades to uncached rather than breaking the page, matching the existing pattern in src/lib/maintenance.ts. Verified locally via dev server + Chrome DevTools MCP emulation (DE/EN, mobile 375px, desktop) — this is a public unauthenticated page so, unlike most of today's other fixes, testable outside of Clerk auth.
25 lines
889 B
TypeScript
25 lines
889 B
TypeScript
import "server-only";
|
|
import Stripe from "stripe";
|
|
|
|
// Lazy singleton — constructing eagerly at module scope crashes on
|
|
// `STRIPE_SECRET_KEY` being unset, which previously took down the entire
|
|
// module graph (including anything that transitively imports the full tRPC
|
|
// appRouter, e.g. createTRPCCaller() on any public page) even when that
|
|
// code path never touches Stripe at runtime. Get credentials at
|
|
// dashboard.stripe.com → Developers → API keys.
|
|
let stripeClient: Stripe | null = null;
|
|
function getStripeClient(): Stripe {
|
|
if (!stripeClient) {
|
|
stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY ?? "");
|
|
}
|
|
return stripeClient;
|
|
}
|
|
|
|
export const stripe = new Proxy({} as Stripe, {
|
|
get(_target, prop, receiver) {
|
|
return Reflect.get(getStripeClient(), prop, receiver);
|
|
},
|
|
});
|
|
|
|
export const STRIPE_WEBHOOK_SECRET = process.env.STRIPE_WEBHOOK_SECRET ?? "";
|