// All runtime config comes from env (Coolify sets these). Read once. // VBB v1 is off-chain: no contract, no payments. Planned prices are shown as "coming soon"; rewards are recorded, not credited yet. const path = require('path'); let cfg = null; function get() { if (cfg) return cfg; const e = process.env; const list = (v, d) => String(v == null || v === '' ? d : v).split(',').map(x => x.trim()).filter(Boolean); const num = (v, d, min, max) => { const n = Number(v); return Number.isFinite(n) && v !== '' && v != null ? Math.min(max, Math.max(min, Math.round(n))) : d; }; cfg = { port: Number(e.PORT || 3000), isProd: e.NODE_ENV === 'production', site: e.SITE_HOST || 'viralbannerblitz.com', siteName: 'Viral Banner Blitz', dataDir: e.DATA_DIR || path.join(__dirname, 'data'), chainId: Number(e.CHAIN_ID || 137), // only used in the wallet sign-in message + picker chainName: e.CHAIN_NAME || 'Polygon', publicRpc: e.PUBLIC_RPC || 'https://polygon-bor-rpc.publicnode.com', walletConnectProjectId: (e.WALLETCONNECT_PROJECT_ID || '').trim(), // the loop loopSize: num(e.LOOP_SIZE, 50, 5, 500), // banners on the splash at once perShift: num(e.VISITORS_PER_SHIFT, 10, 1, 1000), // verified unique visitors per one-place shift viewsPerCycle: num(e.VIEWS_PER_CYCLE, 150, 0, 100000), // network ad views recorded per completed cycle (not credited in v1) // verified visitors visitSeconds: num(e.VISIT_SECONDS, 6, 2, 60), // the page must be visible this long before the visit counts visitWindowHours: 24, // one count per visitor key per 24 h perIpDay: num(e.VISITS_PER_IP_DAY, 3, 1, 100), // distinct user agents counted per IP per 24 h (shared connections, UA rotation) // members freeCreditsPerDay: num(e.FREE_CREDITS_PER_DAY, 1, 0, 10), // Marty 2026-11-13: 1 free post credit a day on sign-in freeCreditCap: num(e.FREE_CREDIT_CAP, 7, 1, 365), // daily free credits bank up to this many maxQueuedPerMember: num(e.MAX_QUEUED_PER_MEMBER, 3, 1, 100), // banners one member may have waiting at once // ---- Marty's approved numbers (2026-11-13). v1 takes no payments: packages show as "coming soon" with these planned prices, // prizes are displayed only (no payout code yet), the split is kept here for the contract step. packs: list(e.CREDIT_PACKS, '10:3,40:10').map(x => { const [credits, usd] = x.split(':').map(Number); return { credits, usd }; }).filter(x => x.credits > 0 && x.usd > 0), lookUsd: Number(e.LOOK_USD || 2), // banner look (border + hover teaser), per banner, one-time split: { sponsorPct: num(e.SPONSOR_PCT, 30, 0, 100), companyPct: 100 - num(e.SPONSOR_PCT, 30, 0, 100) }, // on-chain later, no line // weekly prize pot (Marty 2026-11-13): 10% of the week's sales, never under the floor (the company tops it up), capped at $50. // Half the pot per leaderboard, split 50/30/20 across the top three. The cap is internal: the public page never shows it. prizePot: { pct: num(e.PRIZE_PCT, 10, 0, 100), floorUsd: num(e.PRIZE_FLOOR_USD, 20, 0, 100000), capUsd: num(e.PRIZE_CAP_USD, 50, 0, 100000), places: list(e.PRIZE_PLACES, '50,30,20').map(Number).filter(x => x >= 0) }, linkProbe: e.LINK_PROBE !== '0', // check the target link answers and allows frames (off in the local smoke test) iapBase: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''), lsBase: String(e.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''), // network usernames: ?u= / ?a= -> {address, username}. '' turns the lookup off (local prototype). networkLookupUrl: e.NETWORK_LOOKUP_URL !== undefined ? String(e.NETWORK_LOOKUP_URL).trim() : String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '') + '/api/network/member' }; return cfg; } module.exports = { get, reset: () => { cfg = null; } };