A koa2 starter by using mysql, gulp includes async/await, pm2, express-style middlewares. Based on 17koa/koa2-demo.
基于17koa/koa2-demo,并增加了mysql和gulp模块,提供了一个较完整的示例。
开发环境
//git clone https://github.com/babeliao/koa2-starter.git git clone git@github.com:babeliao/koa2-starter.git cd koa2-starter npm install npm startopen in browser
http://127.0.0.1:3000/
在路径routes/index.js下,
//根据model自动在数据库中创建表 force:是否强制建表,即删除原来表 db.sync({force: true});即访问index页面后程序会自动根据models在数据库建立对应table
生产环境,在之前的基础上 On the basis of previous
gulp会自动压缩资源文件,上传cdn,md5并在ejs中替换路径,替换后的ejs文件将生成在dist/ 路径下,此时
npm start --production读取正式环境配置数据后启动server。You can freely configure test enviroment of your own free will.