const Fastify = require('fastify'); const cors = require('@fastify/cors'); const articleRoutes = require('./src/routes/articles'); const statusRoutes = require('./src/routes/status'); const sourcesRoutes = require('./src/routes/sources'); const eventRoutes = require('./src/routes/events'); const adminRoutes = require('./src/routes/admin'); const devRoutes = require('./src/routes/dev'); const config = require('./src/config'); const { startScheduler } = require('./src/scheduler'); const app = Fastify({ logger: true }); app.register(cors, { origin: true }); app.register(articleRoutes); app.register(statusRoutes); app.register(sourcesRoutes); app.register(eventRoutes); app.register(adminRoutes); app.register(devRoutes); app.get('/', async () => ({ ok: true })); async function start() { await app.listen({ port: config.server.port, host: config.server.host }); startScheduler(); } start().catch((error) => { app.log.error(error); process.exit(1); });