generated-bill / backend /src /server.ts
narasimha01tm's picture
Fix HF port binding and add health check
04fd18e
Raw History Blame Contribute Delete
934 Bytes
import { app } from './app';
import dotenv from 'dotenv';
import mongoose from 'mongoose';
// Import models to ensure they are registered
import './models/PlatformConnection.model';
import './models/Bill.model';
dotenv.config();
dotenv.config({ path: '.env.local' });
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/smartspend';
// Connect to MongoDB
mongoose.connect(MONGODB_URI)
.then(() => {
console.log('✅ MongoDB connected successfully');
console.log(`📊 Database: ${MONGODB_URI}`);
})
.catch((error) => {
console.error('❌ MongoDB connection error:', error.message);
console.log('⚠️ Server will continue without MongoDB. Platform connections will not work.');
});
const PORT = Number(process.env.PORT) || 7860;
app.listen(PORT, '0.0.0.0', () => {
console.log(`🚀 Server running on port ${PORT} (0.0.0.0)`);
});
export default app;