mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Continues the cleanup from 164 errors down to 88, all of which now sit in MemStorage — the in-memory dev mock — documented as known debt. Production server code and the entire client are at zero errors. Three genuine defects surfaced by the types and fixed: - deleteAnnouncement returned void while routes check the result and answer 404 "not found" on falsy: deleting an announcement succeeded in DB but the API reported failure on the fallback paths; it now returns a real boolean - AnnouncementMemoryStorage declared getAnnouncement twice; the first implementation was dead at runtime (second definition wins) and is removed - one route called storage.getDeliveryById(), a method that does not exist, crashing with a TypeError whenever hit; it now calls getDelivery() Everything else is type-level only (annotations, null-to-undefined for inline styles, honest signatures for markClientCalled's comment parameter and the invoice verification result's invoiceAmountTTC field), verified behavior-neutral: client build, production server bundle and the SMTP end-to-end test all pass unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FHdE9nEh8zHhQNGpCgrtYe
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { Pool } from 'pg';
|
|
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
import * as schema from "@shared/schema";
|
|
import { runProductionMigrations } from './migrations.production.js';
|
|
|
|
console.log('🐳 PRODUCTION: Configuring standard PostgreSQL database');
|
|
|
|
if (!process.env.DATABASE_URL) {
|
|
throw new Error("DATABASE_URL must be set for production");
|
|
}
|
|
|
|
// Log connection details (without password)
|
|
const dbUrl = new URL(process.env.DATABASE_URL);
|
|
console.log('🐳 Database connection:', {
|
|
host: dbUrl.hostname,
|
|
port: dbUrl.port,
|
|
database: dbUrl.pathname.slice(1),
|
|
user: dbUrl.username
|
|
});
|
|
|
|
export const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL,
|
|
ssl: false, // No SSL for local Docker
|
|
max: 20,
|
|
idleTimeoutMillis: 30000,
|
|
connectionTimeoutMillis: 10000,
|
|
});
|
|
|
|
export const db = drizzle({ client: pool, schema });
|
|
|
|
// Test connection
|
|
pool.on('connect', () => {
|
|
console.log('✅ PostgreSQL connection established');
|
|
});
|
|
|
|
pool.on('error', (err) => {
|
|
console.error('❌ PostgreSQL connection error:', err);
|
|
});
|
|
|
|
// Run migrations automatically when database is configured
|
|
(async () => {
|
|
try {
|
|
console.log('🔄 DB: Running automatic database migrations...');
|
|
await runProductionMigrations();
|
|
console.log('✅ DB: Database migrations completed successfully');
|
|
} catch (error) {
|
|
console.error('❌ DB: Database migrations failed with error:', error);
|
|
console.error('❌ DB: Migration failure details:', {
|
|
name: (error as any)?.name,
|
|
message: (error as any)?.message,
|
|
code: (error as any)?.code
|
|
});
|
|
// Don't fail the application startup for migration errors
|
|
}
|
|
})();
|
|
|
|
console.log('✅ Production PostgreSQL database configured'); |