# 一起學koa
> 作者:[17koa](https://github.com/17koa)
> 來源:[koa-generator-examples](https://github.com/17koa/koa-generator-examples)
koa是下一代基于nodejs的modern web framework,會用到很多es高級特性,可以說無論從es學習還是web開發都有必要學習。
鑒于目前學習資料不多,故有此書
年前幾天比較忙,更新暫緩
## 宗旨
大家一起學習koa
- 暫時不會的可以學會
- 會的可以幫助他人,查缺補漏,提供更多最佳實踐
## 參與流程
通過提問、實現,pr的方式
- 提issue
- 根據某個issue,fork并實現
- 提交pr
- 合并pr并提交
- 發布到git pages上
## 版本說明
目前Koa 2.x還沒有發布,先以Koa 1.x為主
## koajs 1.x和2.x的區別
1.x和2.x的都是基于ctx(上下文)模型實現的
目前2.x還沒沒有完全定下來
- nodejs 4.0+支持的es6語法
- async/await支持 (現在須借由 babel)
- generator不能直接使用,必須使用co類的包裝后才可以
## 目錄
- koa基礎
* 上下文
- koa-generator
* 安裝
* 創建項目
* 切換視圖模板引擎
* 路由
- HTTP
* Get請求
+ 如何獲取query參數
+ 如何獲取params
* Post請求
+ 從post獲取參數
+ 標準表單(Post with x-www-form-urlencoded)
+ 文件上傳(Post with form-data)
+ Post with raw
- 數據庫
* MySQL
* Mongo
- 流程控制
* generator/co
+ es6的generator是什么?
+ co = generator + promise
* async/await
* promise with bluebird
- 測試
* Mocha
* supertest
- 部署
- 最佳實踐
- FAQ
## 預覽
- [一起學koa之1.x版本預覽](http://base-n.github.io/koa-generator-examples/)
- [一起學koa之2.x版本預覽](2.x.md)
## 技術顧問
- [@fundon](https://github.com/fundon)
- [@alsotang](https://github.com/alsotang)
- [@老雷](https://github.com/leizongmin)
用明白不一定寫明白,但寫明白就一定能用明白,大家加油
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Version History
- v0.1.0 初始化版本
## 歡迎fork和反饋
如有建議或意見,請在issue提問或郵件
當然也可以在國內最專業的cnode論壇上回復[《一起學koa》](https://cnodejs.org/topic/5668e0a55af0e6ab3bf1a1d8)
## License
this repo is released under the [MIT
License](http://www.opensource.org/licenses/MIT).
- Introduction
- Nodejs 4.x新特性
- classes
- typed arrays
- generators
- collections
- Set
- Map
- arrow functions
- block scoping
- template strings
- promises
- symbols
- Koa基礎
- 上下文
- koa-generator
- 安裝
- 創建項目
- 更改視圖模板引擎
- Routes
- HTTP
- Get
- 如何獲取query參數
- 如何獲取params
- Post
- 從post獲取參數
- 標準表單(Post with x-www-form-urlencoded)
- 文件上傳(Post with form-data)
- Post with raw
- 數據庫
- MySQL
- Mongo
- 流程控制
- generator/co
- es6的generator是什么?
- co = generator + promise
- async/await
- promise with bluebird
- 測試
- Mocha
- Supertest
- 部署
- 最佳實踐
- FAQ
- 如何發布本書到git pages
- 如何知道require模塊的用法
- koa中的異常處理