1.拆分的路由
const router = require("koa-router")();
router.get("/", async ctx => {
ctx.body = "hello world"
})
router.get("/my", async ctx => {
ctx.body = "my"
})
router.get("/friend", async ctx => {
ctx.body = "f"
})
module.exports = router
2.项目的入口文件
const koa = require("koa")
const app = new koa();
const router = require("./routers")
app.use(router.routes());
app.listen(4000)