Moa2 is a open-source web framework based koa 2.x、mongoose、bluebird、ava that’s optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration.
"Lost, like the Moa is lost" - Maori proverb
core
with database
Core
- 自动加载路由
- 使用jsonwebtoken做用户鉴权
- 支持migrate测试
- 支持ava测试
- 默认集成res.api,便于写接口
- 集成supervisor,代码变动,自动重载
- gulp自动监控文件变动,跑测试
- gulp routes生成路由说明
- 使用log4js记录日志
- production 产品模式,即部署到服务器上的
- test 测试模式,辅助测试
- development 开发模式,日志上会有差异
举例
$ export NODE_ENV=production && ./node_modules/.bin/supervisor ./bin/www
or
$ npm run production
$ git clone --depth=1 https://github.com/moajs/moa2.git <your-project-name>
$ cd <your-project-name>
$ npm install
$ npm start
Koa 2支持3种中间件,其中async/await需要babel支持,根据koa、koa2、koa2-async和express的压测性能比较,性能不是特别好,所以默认Moa2不使用async/await
说明
- user 是common function
- student 是GeneratorFunction
浏览器里访问地址
Install moag
as Moajs scaffold
$ [sudo] npm install --global moag
$ cd <your-project-name>
$ moag <model-name> name:string password:string -k
- for koa 2 common function
$ moag user name:string password:string -k
- for koa2 generator
$ moag book name:string password:string -k -g
- for koa2 async/await
$ moag cup name:string password:string -k -a
async/await
需要babel,所以使用runkoa可以暂时作为开发用,不建议产品环境使用。
$ npm run async
如果加不上,请加微信shiren1118
,说明加入原因
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- v1.0.0 初始化版本,以Koa 2.x为基础
- write by
i5ting
[email protected]
如有建议或意见,请在issue提问或邮件
this repo is released under the MIT License.