Node 即学即用.pdf-Qui-Note

书籍信息

书名:Node 即学即用.pdf
作者:Tom Hughes-Croucher && Mike Wilson
翻译:郑达韡
大小:9.42M
格式:PDF
版权:归原作者所有,仅供学习使用,请24小时内删除!

目录:

第一部分 基础入门
第 1 章 Node.js 简介 ........................................................................................................................3
1.1 安装 Node.js................................................................................................................................4
1.2 开始写代码.................................................................................................................................7
1.2.1 Node REPL.....................................................................................................................7
1.2.2 编写首个服务器程序 ....................................................................................................9
1.3 为什么选择 Node .....................................................................................................................11
1.3.1 高性能 Web 服务器.....................................................................................................11
1.3.2 专业的 JavaScript.........................................................................................................12
1.3.3 浏览器之战 2.0 ............................................................................................................13
第 2 章 编写有趣的应用 ................................................................................................................15
2.1 创建一个聊天服务器...............................................................................................................15
2.2 我们也来编写个 Twitter ..........................................................................................................23
第 3 章 编写健壮的 Node 程序....................................................................................................33
3.1 事件循环...................................................................................................................................33
3.2 模式...........................................................................................................................................39
3.3 编写产品代码...........................................................................................................................44
3.3.1 差错处理 ......................................................................................................................45
3.3.2 使用多处理器 ..............................................................................................................46
2 | 目录
第二部分 API 和常用模块
第 4 章 核心 API ..............................................................................................................................55
4.1 Events........................................................................................................................................55
4.1.1 EventEmitter...........................................................................................................56
4.1.2 Callback 语法...............................................................................................................57
4.2 HTTP.........................................................................................................................................59
4.2.1 HTTP 服务器 ...............................................................................................................59
4.2.2 HTTP 客户端 ...............................................................................................................61
4.2.3 URL ..............................................................................................................................65
4.2.4 querystring ....................................................................................................................67
4.3 I/O..............................................................................................................................................68
4.3.1 数据流(stream)..........................................................................................................68
4.3.2 文件系统 ......................................................................................................................69
4.3.3 Buffer............................................................................................................................70
4.3.4 console.log ....................................................................................................................76
第 5 章 工具类 API..........................................................................................................................77
5.1 DNS...........................................................................................................................................77
5.2 加密...........................................................................................................................................79
5.2.1 Hashing .........................................................................................................................79
5.2.2 HMAC ..........................................................................................................................81
5.2.3 公钥加密 ......................................................................................................................82
5.3 进程...........................................................................................................................................86
5.3.1 process 模块 .............................................................................................................87
5.3.2 子进程 ..........................................................................................................................95
5.4 用 assert 来测试......................................................................................................................101
5.5 虚拟机.....................................................................................................................................104
第 6 章 数据访问............................................................................................................................109
6.1 NoSQL 和文档存储 ...............................................................................................................109
6.1.1 CouchDB ....................................................................................................................109
6.1.2 Redis...........................................................................................................................117
6.1.3 MongoDB ...................................................................................................................125
6.2 关系型数据库.........................................................................................................................129
6.2.1 MySQL .......................................................................................................................129
6.2.2 PostgreSQL.................................................................................................................136
目录 | 3
6.3 连接池.....................................................................................................................................139
6.4 消息队列协议.........................................................................................................................141
第 7 章 重要的外部模块 ..............................................................................................................147
7.1 Express....................................................................................................................................147
7.1.1 一个简单的 Express 应用..........................................................................................147
7.1.2 在 Express 中设置路由..............................................................................................148
7.1.3 处理表单数据 ............................................................................................................153
7.1.4 模板引擎 ....................................................................................................................154
7.1.5 中间件 ........................................................................................................................158
7.2 Socket.IO.................................................................................................................................161
7.2.1 命名空间 ....................................................................................................................163
7.2.2 Express 中使用 Socket.IO..........................................................................................165
第 8 章 扩展 Node.........................................................................................................................171
8.1 模块.........................................................................................................................................171
8.2 包管理.....................................................................................................................................172
8.2.1 搜索包 ........................................................................................................................172
8.2.2 创建包 ........................................................................................................................172
8.2.3 发布包 ........................................................................................................................173
8.2.4 链接 ............................................................................................................................173
8.3 附加组件.................................................................................................................................174
词汇表..................................................................................................................................................175
索引.......................................................................................................................................................176