Spaces:
Sleeping
Sleeping
Download backend/src/server.ts from simhaa-hat/generated-bill: direct link, hf CLI and curl.
- Browser
- Download file 934 Bytes
-
https://huggingface.co/spaces/simhaa-hat/generated-bill/resolve/main/backend/src/server.ts
- Command line
-
hf download hf://spaces/simhaa-hat/generated-bill/backend/src/server.ts
-
curl -L -o server.ts https://huggingface.co/spaces/simhaa-hat/generated-bill/resolve/main/backend/src/server.ts
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; | |