31 lines
899 B
JavaScript
31 lines
899 B
JavaScript
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 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.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);
|
|
});
|