import { get_app_config } from './config/app_config.js'; 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'; 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 cfg = get_app_config(); const port = cfg.server.port; 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}`);