import Koa from 'koa'; import Router from 'koa-router'; import config from "./config/index.js" import koaStatic from 'koa-static'; const app = new Koa(); const router = new Router(); // 简单的路由示例 router.get('/', (ctx) => { ctx.body = {message: 'Hello from Koa server!'}; }); router.get('/api/test', (ctx) => { ctx.body = {message: 'This is a test API endpoint'}; }); router.get('/api/config', (ctx) => { ctx.body = {data: config} }) app.use(router.routes()); app.use(router.allowedMethods()); app.use(koaStatic('/www')) const PORT = process.env.PORT || 3001; app.listen(PORT, () => { console.log(`Koa server is running on port ${PORT}`); });