Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
使用 Node.js 构建 Web 开发解决方案-EMBBNUX
Search
Embbnux Ji
October 21, 2016
Technology
0
140
使用 Node.js 构建 Web 开发解决方案-EMBBNUX
使用 Node.js 构建 Web 开发解决方案, 讲诉如何用 koa 从零构建一个web 开发框架
Embbnux Ji
October 21, 2016
Tweet
Share
Other Decks in Technology
See All in Technology
roppongirb_20250911
igaiga
1
240
RSCの時代にReactとフレームワークの境界を探る
uhyo
10
3.5k
Unlocking the Power of AI Agents with LINE Bot MCP Server
linedevth
0
110
AI時代を生き抜くエンジニアキャリアの築き方 (AI-Native 時代、エンジニアという道は 「最大の挑戦の場」となる) / Building an Engineering Career to Thrive in the Age of AI (In the AI-Native Era, the Path of Engineering Becomes the Ultimate Arena of Challenge)
jeongjaesoon
0
200
20250910_障害注入から効率的復旧へ_カオスエンジニアリング_生成AIで考えるAWS障害対応.pdf
sh_fk2
3
260
Autonomous Database - Dedicated 技術詳細 / adb-d_technical_detail_jp
oracle4engineer
PRO
4
10k
5年目から始める Vue3 サイト改善 #frontendo
tacck
PRO
3
220
2つのフロントエンドと状態管理
mixi_engineers
PRO
3
110
普通のチームがスクラムを会得するたった一つの冴えたやり方 / the best way to scrum
okamototakuyasr2
0
100
バイブスに「型」を!Kent Beckに学ぶ、AI時代のテスト駆動開発
amixedcolor
2
570
未経験者・初心者に贈る!40分でわかるAndroidアプリ開発の今と大事なポイント
operando
5
710
Terraformで構築する セルフサービス型データプラットフォーム / terraform-self-service-data-platform
pei0804
1
190
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
53k
A Tale of Four Properties
chriscoyier
160
23k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Mobile First: as difficult as doing things right
swwweet
224
9.9k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.9k
Designing Experiences People Love
moore
142
24k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Transcript
使⽤用 Node.js 构建 Web 开发解决⽅方案 Embbnux Ji
About Me • embbnux@all • github: github.com/embbnux • 个⼈人博客: www.embbnux.com
• 开源 Web 项⽬目: github.com/embbnux/kails • 标签: docker, rails, node.js, 开源硬件
Why Node.js ?
Why Node.js ? • 跑在服务器器上的 v8 引擎 • 事件驱动 •
⾮非阻塞 IO • 单线程 • 活跃的社区,300000+ 个npm 包
⾼高性能,轻量量 天猫双⼗十⼀一数据,引⾃自<dead-horse : ⽤用 Node.js 构建海海量量⻚页⾯面渲染服务 >
框架选择 • Express • 优点:使⽤用⼴广泛,功能⼤大⽽而多,⾃自带路路由模版等。 • 确定: 掌控⼒力力低,原开发⼈人⻢马跑路路!
框架选择 • connect • 精简的内核,兼容 express 中间件 • 组件⾃自⼰己实现,⾃自由掌控 •
使⽤用⼈人较少
框架选择 • koa • express 原班⼈人⻢马新作 • es6 特性,基于 generator
• 灵活的中间件模型
koa 与 express • express: • 中间件顺序执⾏行行,已经发送的body⽆无法修改 • koa: •
包裹着后⾯面所有中间件的修饰器器 • 所有中间件执⾏行行完发送请求头
koa 实战 • 官⽅方例例程:
啥?⼀一切从头开始!
架构 还是 MVC
路路由分发 还是 restful !
async 和 await ⽀支持 • 为了了更更加简单好⽤用的异步编程, 以及使⽤用 koa 2 •
同步写法的异步编程,拒绝 callback
环境 • development 环境 • test 环境 • production 环境
接⼊入redis • redis 既可以当 web 的缓存, 加速⽹网络请求 • 也可以当 session
store, 加速 session 存取
利利⽤用中间件特性 提⾼高代码复⽤用率
react 前后端同构 浏览器器与服务器器模板复⽤用
⾼高性能中间层 • 利利⽤用 node.js ⾮非阻塞 io 特性构建⾼高性能中间层 • 在服务器器端不不会有并发⽹网络请求数的限制, •
可以同时并发发起多个⽹网络请求,时间为 max(1 .. n)
⼯工程化 • 测试(单元测试 集成测试):mocha, chai • lint: eslint 规划你的 js
代码 • ci ⾃自动测试 ⾃自动集成 ⾃自动部署发布
欢迎交流 参考[1]: dead-horse - ⽤用 Node.js 构建海海量量⻚页⾯面渲染服务 参考[2]: dead-horse -
Node.js 掠影 kails: github.com/embbnux/kails 欢迎 pull request 和 star blog: www.embbnux.com