Duriin-API/server.js

27 lines
672 B
JavaScript

const Fastify = require('fastify');
const articleRoutes = require('./src/routes/articles');
const statusRoutes = require('./src/routes/status');
const config = require('./src/config');
const { startScheduler, runAllIngestions } = require('./src/scheduler');
const app = Fastify({ logger: true });
app.register(articleRoutes);
app.register(statusRoutes);
app.get('/', async () => ({ ok: true }));
async function start() {
await app.listen({ port: config.server.port, host: config.server.host });
runAllIngestions().catch((error) => {
app.log.error(error);
});
startScheduler();
}
start().catch((error) => {
app.log.error(error);
process.exit(1);
});