import Koa from 'koa'; import { koaBody } from 'koa-body'; import serve from 'koa-static'; import { PORT, HOST, STATIC } from './app.config.mjs'; import router from './router/index.mjs'; const app = new Koa(); // 托管静态文件 app.use(serve(STATIC)); // 配置解析请求体 app.use(koaBody()); // 添加路由 app.use(router.routes()).use(router.allowedMethods()); app.listen(PORT, HOST, () => { console.info('Server is running at port: ', PORT); });