12345678910111213141516171819202122232425262728293031 |
- import Koa from 'koa'
- import logger from 'koa-logger'
- import convert from 'koa-convert'
- import bodyParser from 'koa-bodyparser'
- import config from '../config'
- //建立MYSQL连接
- require('../src/new_dao');
- // require('../src/old_dao');
- require('../src/old_dao2');
- // require('../src/test_dao');
- //创建Koa对象
- const app = new Koa()
- //加载中间件
- app.use(convert(logger()))
- app.use(convert(bodyParser()))
- //加载路由
- require('../src/modules')(app)
- //接入Socket.IO
- const server = require('http').createServer(app.callback());
- console.log('config', config)
- //启动服务
- server.listen(config.port, () => {
- console.log(`Server started on ${config.port}`)
- });
- export default app
|