File size: 1,229 Bytes
5bd4e3a
 
1444c0a
5bd4e3a
1444c0a
 
 
 
 
5bd4e3a
1444c0a
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { loadConfig } from "./config.js";
import { buildApp } from "./app.js";
import { HfSecretsPersister, Runtime } from "./runtime.js";

// If WALLET_STORE=supabase is set but the keys are missing/removed, run in memory mode instead of crash-looping.
if (process.env.WALLET_STORE === "supabase" && (!process.env.SUPABASE_URL || !process.env.SUPABASE_SERVICE_ROLE_KEY)) {
  console.warn("WALLET_STORE=supabase but Supabase URL/key missing: falling back to memory store");
  process.env.WALLET_STORE = "memory";
}
const cfg = loadConfig(); // throws on sk_live_ / Apple Pay creds
const persister = new HfSecretsPersister(process.env.SPACE_ID, process.env.HF_SPACE_TOKEN);
const runtime = new Runtime(cfg, { persister });
const app = buildApp(cfg, null, null, { runtime, adminPasscode: process.env.ADMIN_PASSCODE });
if (!cfg.STRIPE_SECRET_KEY || !cfg.STRIPE_WEBHOOK_SECRET) console.warn("Stripe not configured: funding/webhook routes return 503 until keys are added on /settings");
if (!process.env.ADMIN_PASSCODE) console.warn("ADMIN_PASSCODE not set: /settings and /devices sign-in are disabled");
app.listen(cfg.PORT, "0.0.0.0", () => console.log(`wallet (TEST mode, store=${runtime.storeMode}) listening on :${cfg.PORT}`));