diff --git a/pitch-deck/lib/db.ts b/pitch-deck/lib/db.ts index 7e32d9b..bce424a 100644 --- a/pitch-deck/lib/db.ts +++ b/pitch-deck/lib/db.ts @@ -1,4 +1,11 @@ -import { Pool } from 'pg' +import { Pool, types } from 'pg' + +// Coerce NUMERIC/DECIMAL columns to JS numbers globally. The default +// node-postgres behavior hands them back as strings, which silently breaks +// every downstream `.toFixed()` / direct-number call (seen crashing +// UnitEconomicsCards on the Finanzen slide). Our values fit comfortably in +// Number.MAX_SAFE_INTEGER, so the precision trade-off is fine. +types.setTypeParser(types.builtins.NUMERIC, (val) => (val === null ? null : parseFloat(val))) const pool = new Pool({ connectionString: process.env.DATABASE_URL || 'postgres://breakpilot:breakpilot123@localhost:5432/breakpilot_db',