import dotenv from 'dotenv'; import Koa from 'koa'; import body_parser from 'koa-bodyparser'; import { sequelize } from './models/index.js'; import { crawl_router } from './routes/crawl.js'; import { start_all_cron_tasks } from './services/schedule_loader.js'; dotenv.config(); const app = new Koa(); app.use(body_parser({ jsonLimit: '10mb' })); app.use(crawl_router.routes()).use(crawl_router.allowedMethods()); app.use(async (ctx) => { ctx.status = 404; ctx.body = { ok: false, error: 'not_found' }; }); const port = Number(process.env.SERVER_PORT || 38080); await sequelize.authenticate(); await sequelize.sync(); start_all_cron_tasks(); app.listen(port); // eslint-disable-next-line no-console console.log(`server listening on ${port}`);