first commit

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
root
2026-05-10 19:20:03 +00:00
parent 1050bb39ec
commit a3f08242fe
58 changed files with 5803 additions and 261 deletions

12
scripts/http-smoke.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Requires: npm run start (or dev) on port 8008
set -euo pipefail
BASE="${1:-http://127.0.0.1:8008}"
echo "[http] GET $BASE/api/public/stats"
code=$(curl -s -o /tmp/stats.json -w "%{http_code}" "$BASE/api/public/stats")
echo "[http] status $code"
cat /tmp/stats.json | head -c 400
echo ""
echo "[http] GET $BASE/api/wallet (expect 401)"
code2=$(curl -s -o /dev/null -w "%{http_code}" "$BASE/api/wallet")
echo "[http] status $code2"

View File

@@ -0,0 +1,57 @@
/**
* Local integration smoke checks: Postgres via Prisma adapter + optional Stripe API ping.
* Does not hit Next.js HTTP routes (use npm run test:http after starting the server).
*/
import "dotenv/config";
import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "@prisma/client";
import { Pool } from "pg";
import Stripe from "stripe";
async function main() {
const connectionString = process.env.DATABASE_URL;
if (!connectionString) {
throw new Error("DATABASE_URL is not set");
}
const pool = new Pool({ connectionString });
const prisma = new PrismaClient({ adapter: new PrismaPg(pool) });
await prisma.$queryRaw`SELECT 1`;
const counts = await prisma.$transaction([
prisma.user.count(),
prisma.wallet.count(),
prisma.donation.count(),
prisma.ledgerEntry.count(),
]);
console.log("[db] connected OK");
console.log("[db] counts — users:", counts[0], "wallets:", counts[1], "donations:", counts[2], "ledger:", counts[3]);
const admins = await prisma.user.count({ where: { role: "ADMIN" } });
console.log("[db] admin users:", admins);
await prisma.$disconnect();
await pool.end();
const sk = process.env.STRIPE_SECRET_KEY?.trim();
if (!sk || sk.includes("disabled_configure")) {
console.log("[stripe] skipped — set STRIPE_SECRET_KEY to call the Stripe API");
return;
}
const stripe = new Stripe(sk, { typescript: true });
try {
const balance = await stripe.balance.retrieve();
const cur = new Set([...balance.available, ...balance.pending].map((b) => b.currency));
console.log("[stripe] balance.retrieve OK — currencies:", [...cur].join(", ") || "(none)");
} catch (e) {
console.log("[stripe] balance.retrieve failed — check key mode (test/live) and permissions:", (e as Error).message);
}
}
main().catch((e) => {
console.error("[smoke] failed:", e);
process.exit(1);
});