ThinkJS 3.0 中文文档
开发框架,整合了很多最佳实践,让企业级开发变得更加简 单、高效。从 3.0 开始,ThinkJS 基于 koa 2.x,完全兼容 koa 里的 middleware 等插件。 同时,ThinkJS 支持 Extend 和 Adapter 等方式,方便扩展框架里的各种功能。 特性 支持 Middleware、Extend、Adapter 等扩展方式 基于 Koa 2.x 开发 性能优异,单元测试覆盖程度高 内置自动编译、自动更新机制,方便开发环境快速开发 升级指南 本文档为 2.x 升级到 3.x 的文档,由于本次升级接口改动较大,所以无法平滑升级。本文档更多的 是介绍接口变化指南。 核心变化 3.0 抛弃了已有的核心架构,基于 Koa 2.x 版本构建,兼容 Koa 里的所有功能。主要变化为: 之前的 http 对象改为 ctx 对象 执行完全改为调用 middleware 来完成 框架内置的很多功能不再默认内置,可以通过扩展来支持 middleware 移除 3.x 里的 hook 和 middleware,改为 Koa 里的 middleware,middleware 的管理放在 src/config/middleware.js 配置文件中。 2.x 下的 middleware 类无法在 3.0 下使用,3.0 下可以直接使用 Koa 的 middleware。 Controller 将基类 think.controller0 码力 | 129 页 | 2.12 MB | 1 年前3Egg & Node.js 从⼩⼯坊⾛向企业级开发
EggJS / Scrat / Vue ▸ Follow me at : @atian25 @liuyong25 @liuyong25 @atian25 全景图 Koa 基于规范实现⼀一套框架 - Egg 基于上层框架开发的应⽤用 社区⽣生态 团队架构师 ⼀一线开发者 Node.js Plugin 插件⽣生态 适合特定团队业务场景的上层框架 跃,最能被前端接受的 Node.js Base on Koa [2/8] Base on Koa ▸ Koa based framework ▸ 当前解决异步编程最好的 Web 通⽤用框架,洋葱模型 ▸ 所有源代码 100% 掌握并且参与到核⼼心代码贡献 (@fengmk2 @dead_horse) Base on Koa ▸ 类似于 Connect 的定位,专注于 http lication 扩展。 ▸ 功能之间的顺序不不能简单的交给开发者,需要统⼀一编排,管理理。 ▸ 对于企业级应⽤用来说,还⽐比较基础,往往还需要⾮非常多的上层封装才能使⽤用。 WIKI:koa-vs-express.md Specification [3/8] 先思考⼏几个问题: 企业级开发中需要关注的有哪些点? ⽽而开发⼈人员和团队技术负责⼈人,关注点⼀一样么? 理理想的企业级0 码力 | 70 页 | 7.57 MB | 1 年前3Node 在有赞的实践
三、未来需要做的一些事情 2 3 Koa 中间件 有⼈人(有赞的⼀一个内部管理理系统) 第⼀一个 Node 项⽬目 4 Koa 中间件 有⼈人(有赞的⼀一个内部管理理系统) 第⼆二个 Node 项⽬目 脚⼿手架模板 有赞官⽹网 5 Koa 中间件 有⼈人 阿童⽊木 0.0.1 诞⽣生 有赞官⽹网 Astroboy 阿童⽊木 有赞招聘 有赞云官⽹网 Koa + 中间件 脚⼿手架模板 脚⼿手架模板 阿童⽊木 0.0.1 6 Koa 中间件 有⼈人 很多项⽬目都开始⽤用 Node 了了 有赞官⽹网 Astroboy 阿童⽊木 有赞招聘 有赞云官⽹网 云控制台 分销 中间件 中间件 7 Koa 交易易 店铺 Astroboy 阿童⽊木 ⽤用户 营销 有赞官⽹网 有赞招聘 Youzan Base Framework Iron Base Framework0 码力 | 29 页 | 945.50 KB | 1 年前3Egg.js 在阿里巴巴集团的的实践运用
ngot Ngot_ftd ⼑耕⽕种 裸⽤社区框架 ✤ 裸⽤ koa, express 等 ✤ 各团队独⾃野蛮发展,开发规范混乱 问题 ✤ 重复建设 ✤ ⽆法复⽤ ✤ 跨团队合作异常困难 ✤ 中间件对接困难 铁犁⽜耕 BU级别定制框架出现 ✤ 少数 BU 出现了基于 Koa 的定制框架 ✤ 开发了 cnpm,并且搭建了内部私有 npm ✤ 围绕各个框架,⽣态开始繁荣 框架(Egg.js) ✤ 开源回馈社区 Egg.js 为企业级框架和应⽤⽽⽣ express vs koa ✤ 基于 Generator/Async 的中间件(同步写法更适合企业 应⽤) ✤ 核⼼精简(req/res/ctx),易于扩展 ✤ 掌握核⼼科技(苏千,死马 koa 核⼼开发) 换位思考 ✤ 业务开发 ✤ 易⽤的框架,丰富的库,能够快速搞定业务才是王道 ✤ 架构师 org/eggjs/egg.git" npm scripts 添加: ⼯具链 ✤ egg-bin ✤ egg-mock ✤ egg-scripts ✤ egg-doctools 阿⾥内部落地 Koa Egg 基于上层框架开发的应⽤用 社区⽣生态 团队架构师 ⼀一线开发者 Node.js Plugin 插件⽣生态 适合特定团队业务场景的上层框架 Framework 蚂蚁0 码力 | 29 页 | 2.39 MB | 1 年前3ThinkJS 2.1 Documentation
same time. ThinkJS provides us very simple methods to implement i18n and custom themes. Express and koa are simple frameworks, they all only provide the very basic functions. So for developing complex projects project’s complexity. Besides, no one can ensure all the third party plugins are safety and efficient. Koa 1.x solved asynchronous callbacks problem by using */yield feature. But the newer async/await feature Configurable Routers Supports international and custom themes Comparing With Other Frameworks Express/Koa Sails But Sails still uses callbacks in asynchronous code. That’s too hard to develop, and can’t0 码力 | 148 页 | 1.69 MB | 1 年前3ThinkJS 2.2 中文文档
使用很简单的方法就可以支持国际化和多主题等功能。 与其他框架的对比 与 express/koa 对比 express/koa 是 2 个比较简单的框架,框架本身提供的功能比较简单,项目中需要借助大量的第三 方插件才能完成项目的开发,所以灵活度比较高。但使用很多第三方组件一方面提高了项目的复 杂度,另一方面第三方插件质量参差不齐,也会带来内存泄漏等风险。 koa 1.x 使用 ES6 里的 */yield 解决了异步回调的问题,但 看性能。虽然 ThinkJS 更适合大型项 目,功能和复杂度远远超过 Express 和 Koa,但性能上并不比 Express 和 Koa 逊色多少,具体的测 试数据请见下图。 注 :以上数据使用分布式压力测试系统测试。 从上图中测试数据可以看到,虽然 ThinkJS 比 Express 和 Koa 性能要差一些,但差别并不大。 ThinkJS 和 Sails.js 都更符合大型项目,但 网络请求 superagent request 日志 log4js 日期处理 moment 编码转化 iconv-lite 图像处理 gm 框架 thinkjs express koa sails 调试 node-inspector 单元测试 mocha istanbul muk 服务管理 pm2 邮件 nodemailer 定时任务 node-crontab0 码力 | 277 页 | 3.61 MB | 1 年前3ThinkJS 2.2 Documentation
same time. ThinkJS provides us very simple methods to implement i18n and custom themes. Express and koa are simple frameworks, they all only provide the very basic functions. So for developing complex projects project’s complexity. Besides, no one can ensure all the third party plugins are safety and efficient. Koa 1.x solved asynchronous callbacks problem by using */yield feature. But the newer async/await feature Configurable Routers Supports international and custom themes Comparing With Other Frameworks Express/Koa Sails But Sails still uses callbacks in asynchronous code. That’s too hard to develop, and can’t0 码力 | 156 页 | 2.62 MB | 1 年前3ThinkJS 2.0 中文文档
ThinkJS ������������������������ express/koa � 2 ��������������������������������������� ����������������������������������������������� ���������������������� koa 1.x �� ES6 �� */yield ������������ */yield �� ES6/7 ������������ JavaScript Promise��� learn-es2015 ������� ��������� �������� � express/koa �� � sails �� ThinkJS ��� ES6/7 ���� ECMAScript 6 �� � JavaScript ���� ES2015 �� ECMAScript 6 iconv-lite gm ���� npm run test-cov Bash ���� �� ���� ���� �� ���� ���� ���� thinkjs express koa sails node-inspector mocha istanbul muk pm2 nodemailer node-crontab Node.js ����������� callback0 码力 | 238 页 | 1.87 MB | 1 年前3go web 框架 严清
• 提供强⼤大、实⽤用的 HTTP 操作⽅方法语法糖 写 web 服务就是操作 HTTP,实⽤用语法糖极⼤大提升开发⼈人员的幸福指数 Middleware 模式及其控制 Express、koa、toa、Gear、Echo、Gin、Iris… ⼤大家都选择了了中间件模式 app := gear.New() app.Set(gear.SetLogger, log.New(gear Use(func(ctx *gin.Context) { fmt.Println("C") ctx.JSON(200, someBody) }) // ACB Gin 的中间件流程控制,koa 的洋葱头级联模型 思考:如何进⾏行行异常和错误控制?⽐比如 Auth 中间件⽤用户身份验证失败 Middleware 模式及其控制 Middlewares 的组合:流程之级联控制 app0 码力 | 23 页 | 333.12 KB | 1 年前3ThinkJS 2.0 Documentation
same time. ThinkJS provides us very simple methods to implement i18n and custom themes. Express and koa are simple frameworks, they all only provide the very basic functions. So for developing complex projects project’s complexity. Besides, no one can ensure all the third party plugins are safety and efficient. Koa 1.x solved asynchronous callbacks problem by using */yield feature. But the newer async/await feature Configurable routers Supports international and custom themes Comparing with other frameworks Express/Koa Sails Disadvantages You can read more about ES6/7 features here: learn-es2015 ECMAScript 6 Guide0 码力 | 141 页 | 1.61 MB | 1 年前3
共 13 条
- 1
- 2