0
0

app.js 509 B

12345678910111213141516171819
  1. const Koa = require('koa')
  2. const app = new Koa()
  3. const debug = require('debug')('koa-weapp-demo')
  4. const response = require('./middlewares/response')
  5. const bodyParser = require('koa-bodyparser')
  6. const config = require('./config')
  7. // 使用响应处理中间件
  8. app.use(response)
  9. // 解析请求体
  10. app.use(bodyParser())
  11. // 引入路由分发
  12. const router = require('./routes')
  13. app.use(router.routes())
  14. // 启动程序,监听端口
  15. app.listen(config.port, () => debug(`listening on port ${config.port}`))