Files
graphs/backend/index.js
2026-08-12 09:12:14 -03:00

23 lines
837 B
JavaScript

const { createApp } = require('./server');
const { initDB } = require('./db');
const { OLIST_SYNC_ENABLED, PORT } = require('./config');
const { markInterruptedOlistRuns, scheduleOlistSync } = require('./services/olistService');
const start = async () => {
await initDB();
await markInterruptedOlistRuns();
const app = createApp();
if (OLIST_SYNC_ENABLED) await scheduleOlistSync();
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);
});