const { createApp } = require('./server'); const { initDB } = require('./db'); const { PORT } = require('./config'); const start = async () => { await initDB(); const app = createApp(); app.listen(PORT, '0.0.0.0', () => { console.log(`Nexstar Backend running at http://localhost:${PORT}`); console.log(`Endpoint for n8n: POST http://localhost:${PORT}/api/data`); console.log(`Scheduled campaign processor: POST http://localhost:${PORT}/api/internal/process-stock-campaigns`); }); }; start().catch((error) => { console.error('Failed to start backend:', error); process.exit(1); });