2017-07-04 16:43:07 +08:00
|
|
|
import yapi from './yapi.js';
|
|
|
|
import commons from './utils/commons';
|
|
|
|
yapi.commons = commons;
|
|
|
|
import dbModule from './utils/db.js';
|
2017-07-10 20:02:44 +08:00
|
|
|
import mockServer from './middleware/mockServer.js'
|
2017-07-04 16:43:07 +08:00
|
|
|
import Koa from 'koa'
|
|
|
|
import convert from 'koa-convert'
|
|
|
|
import koaStatic from 'koa-static'
|
|
|
|
import bodyParser from 'koa-bodyparser'
|
|
|
|
import router from './router.js'
|
|
|
|
|
2017-07-05 16:17:58 +08:00
|
|
|
yapi.connect = dbModule.connect()
|
2017-07-04 16:43:07 +08:00
|
|
|
|
|
|
|
const app = new Koa()
|
2017-07-10 20:02:44 +08:00
|
|
|
app.use(mockServer)
|
2017-07-04 16:43:07 +08:00
|
|
|
app.use(bodyParser())
|
|
|
|
app.use(router.routes())
|
|
|
|
app.use(router.allowedMethods())
|
|
|
|
app.use(koaStatic(
|
|
|
|
yapi.path.join(yapi.WEBROOT, 'static')
|
|
|
|
))
|
|
|
|
app.listen(yapi.WEBCONFIG.port)
|
|
|
|
commons.log(`the server is start at port ${yapi.WEBCONFIG.port}`)
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-11 16:50:17 +08:00
|
|
|
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-03 16:16:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|