Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.44 KB | None | 0 0
  1. CONTENTS
  2. PART I: GETTING STARTED: SETUP AND CONCEPTS
  3. 5
  4. Chapter 1: The Setup
  5. 7
  6. Installing on Windows
  7. 8
  8. Installing on OS X
  9. 8
  10. Installing on Linux
  11. 8
  12. Compiling 9
  13. Ensuring that it works
  14. 9
  15. The Node REPL
  16. 9
  17. Executing a file
  18. 10
  19. NPM 10
  20. Installing modules
  21. 11
  22. Defining your own module
  23. 12
  24. Installing binary utilities
  25. 13
  26. Exploring the NPM registry 14
  27. Summary 14
  28. Chapter 2: JavaScript: An Overview
  29. 15
  30. Introduction 15
  31. Basic JavaScript
  32. 16
  33. Types 16
  34. Type hiccups
  35. 16
  36. Functions 18
  37. this, Function#call, and Function#apply
  38. 18
  39. Function arity
  40. 19
  41. Closures 19
  42. Classes 20
  43. Inheritance 20
  44. try {} catch {}
  45. 21
  46. v8 JavaScript
  47. 22
  48. Object#keys 22
  49. Array#isArray 23
  50. Array methods
  51. 23
  52. String methods
  53. 24
  54. JSON 24
  55. Function#bind 24
  56. CONTENTS
  57. Function#name 24
  58. _proto_ (inheritance)
  59. 25
  60. Accessors 25
  61. Summary 26
  62. Chapter 3: Blocking and Non-blocking IO
  63. 27
  64. With great power comes great responsibility
  65. 28
  66. Blocking-ness 29
  67. A single-threaded world
  68. 31
  69. Error handling
  70. 33
  71. Stack traces
  72. 35
  73. Summary 37
  74. Chapter 4: Node JavaScript
  75. 39
  76. The global object
  77. 40
  78. Useful globals
  79. 40
  80. The module system
  81. 41
  82. Absolute and relative modules
  83. 41
  84. Exposing APIs
  85. 44
  86. Events 45
  87. Buffers 47
  88. Summary 48
  89. PART II: ESSENTIAL NODE APIS
  90. 49
  91. Chapter 5: CLI and FS APIs: Your First Application
  92. 51
  93. Requirements 52
  94. Writing your first program
  95. 52
  96. Creating the module
  97. 53
  98. Sync or async?
  99. 54
  100. Understanding streams
  101. 55
  102. Input and ouput
  103. 57
  104. Refactoring 59
  105. Interacting with the fs
  106. 61
  107. Exploring the CLI
  108. 63
  109. Argv 63
  110. Working directory
  111. 64
  112. Environmental variables
  113. 65
  114. Exiting 65
  115. Signals 65
  116. ANSI escape codes
  117. 66
  118. Exploring the fs module
  119. 66
  120. Streams 67
  121. Watch 67
  122. Summary 68
  123. v
  124. vi
  125. CONTENTS
  126. Chapter 6: TCP 69
  127. What are the characteristics of TCP?
  128. 70
  129. Connection-oriented communication
  130. and same-order delivery
  131. 70
  132. Byte orientation
  133. 70
  134. Reliability 71
  135. Flow control
  136. 71
  137. Congestion control
  138. 71
  139. Telnet 71
  140. A TCP chat program
  141. 74
  142. Creating the module
  143. 74
  144. Understanding the net.server API
  145. 74
  146. Receiving connections
  147. 76
  148. The data event
  149. 77
  150. State and keeping track of connections
  151. 79
  152. Wrap up
  153. 81
  154. An IRC Client program
  155. 83
  156. Creating the module
  157. 83
  158. Understanding the net#Stream API
  159. 84
  160. Implementing part of the IRC protocol
  161. 84
  162. Testing with a real-world IRC server
  163. 85
  164. Summary 85
  165. Chapter 7: HTTP 87
  166. The structure of HTTP
  167. 88
  168. Headers 89
  169. Connections 93
  170. A simple web server
  171. 94
  172. Creating the module
  173. 95
  174. Printing out the form
  175. 95
  176. Methods and URLs
  177. 97
  178. Data 99
  179. Putting the pieces together
  180. 102
  181. Bullet-proofing 103
  182. A Twitter web client
  183. 104
  184. Creating the module
  185. 104
  186. Making a simple HTTP request
  187. 104
  188. Sending a body of data
  189. 106
  190. Getting tweets
  191. 107
  192. A superagent to the rescue
  193. 110
  194. Reloading HTTP servers with up
  195. 111
  196. Summary 112
  197. CONTENTS
  198. PART III: WEB DEVELOPMENT
  199. 113
  200. Chapter 8: Connect 115
  201. A simple website with HTTP
  202. 116
  203. A simple website with Connect
  204. 119
  205. Middleware 121
  206. Writing reusable middleware
  207. 122
  208. Static middleware
  209. 127
  210. Query 128
  211. Logger 129
  212. Body parser
  213. 131
  214. Cookies 134
  215. Session 134
  216. REDIS sessions
  217. 140
  218. methodOverride 141
  219. basicAuth 141
  220. Summary 144
  221. Chapter 9: Express 145
  222. A simple express app
  223. 146
  224. Creating the module
  225. 146
  226. HTML 146
  227. Setup 147
  228. Defining routes
  229. 148
  230. Search 150
  231. Run 152
  232. Settings 153
  233. Template engines
  234. 154
  235. Error handling
  236. 155
  237. Convenience methods
  238. 155
  239. Routes 157
  240. Middleware 159
  241. Organization strategies
  242. 160
  243. Summary 162
  244. Chapter 10: WebSocket 163
  245. AJAX 164
  246. HTML5 WebSocket
  247. 166
  248. An Echo Example
  249. 167
  250. Setting it up
  251. 167
  252. Setting up the server
  253. 168
  254. Setting up the client
  255. 169
  256. Running the server
  257. 170
  258. Mouse cursors
  259. 171
  260. Setting up the example
  261. 171
  262. Setting up the server
  263. 172
  264. vii
  265. viii C O N T E N T S
  266. Setting up the client
  267. 174
  268. Running the server
  269. 176
  270. The Challenges Ahead
  271. 177
  272. Close doesn’t mean disconnect
  273. 177
  274. JSON 177
  275. Reconnections 177
  276. Broadcasting 177
  277. WebSockets are HTML5: Older browsers don’t support them 177
  278. The solution
  279. 178
  280. Summary 178
  281. Chapter 11: Socket.IO 179
  282. Transports 180
  283. Disconnected versus closed
  284. 180
  285. Events 180
  286. Namespaces 181
  287. A chat program
  288. 182
  289. Setting up the program
  290. 182
  291. Setting up the server
  292. 182
  293. Setting up the client
  294. 183
  295. Events and Broadcasting
  296. 185
  297. Ensuring reception
  298. 190
  299. A DJ-by-turns application
  300. 191
  301. Extending the chat
  302. 191
  303. Integrating with the Grooveshark API
  304. 193
  305. Playing 196
  306. Summary 201
  307. PART IV: DATABASES
  308. 203
  309. Chapter 12: MongoDB 205
  310. Installation 207
  311. Accessing MongoDB: A user authentication example
  312. 208
  313. Setting up the application
  314. 208
  315. Creating the Express app
  316. 208
  317. Connecting to MongoDB
  318. 212
  319. Creating documents
  320. 214
  321. Finding documents
  322. 215
  323. Authentication middleware
  324. 217
  325. Validation 218
  326. Atomicity 219
  327. Safe mode
  328. 219
  329. Introducing Mongoose
  330. 220
  331. Defining a model
  332. 220
  333. Defining nested keys
  334. 222
  335. Defining embedded documents
  336. 222
  337. CONTENTS
  338. Setting up indexes
  339. 222
  340. Middleware 223
  341. Inspecting the state of the model
  342. 223
  343. Querying 224
  344. Extending queries
  345. 224
  346. Sorting 224
  347. Making Selections
  348. 224
  349. Limiting 225
  350. Skipping 225
  351. Populating keys automatically
  352. 225
  353. Casting 225
  354. A mongoose example
  355. 226
  356. Setting up the application
  357. 226
  358. Refactoring 226
  359. Setting up models
  360. 227
  361. Summary 229
  362. Chapter 13: MySQL 231
  363. node-mysql 232
  364. Setting it up
  365. 232
  366. Te Express app
  367. h
  368. 232
  369. Connecting to MySQL
  370. 234
  371. Initializing the script
  372. 234
  373. Creating data
  374. 238
  375. Fetching data
  376. 242
  377. sequelize 244
  378. Setting up sequelize
  379. 245
  380. Setting up the Express app
  381. 245
  382. Connecting sequelize
  383. 248
  384. Defining models and synchronizing
  385. 249
  386. Creating data
  387. 250
  388. Retrieving data
  389. 253
  390. Removing data
  391. 254
  392. Wrapping up
  393. 256
  394. Summary 257
  395. Chapter 14: Redis 259
  396. Installing Redis
  397. 261
  398. The Redis query language
  399. 261
  400. Data types
  401. 262
  402. Strings 263
  403. Hashes 263
  404. Lists 265
  405. Sets 265
  406. Sorted sets
  407. 266
  408. Redis and Node
  409. 266
  410. Implementing a social graph with node-redis
  411. 267
  412. Summary 276
  413. ix
  414. x
  415. CONTENTS
  416. PART V: TESTING
  417. 277
  418. Chapter 15: Code Sharing
  419. 279
  420. What can be shared?
  421. 280
  422. Writing compatible JavaScript
  423. 280
  424. Exposing modules
  425. 280
  426. Shimming ECMA APIs
  427. 282
  428. Shimming Node APIs
  429. 283
  430. Shimming browser APIs
  431. 284
  432. Cross-browser inheritance
  433. 284
  434. Putting it all together: browserbuild
  435. 285
  436. A basic example
  437. 286
  438. Summary 288
  439. Chapter 16: Testing 289
  440. Simple testing
  441. 290
  442. Te test subject
  443. h
  444. 290
  445. Te test strategy
  446. h
  447. 290
  448. Te test program
  449. h
  450. 291
  451. Expect.JS 292
  452. API overview
  453. 292
  454. Mocha 294
  455. Testing asynchronous code
  456. 295
  457. BDD style
  458. 297
  459. TDD style
  460. 298
  461. Exports style
  462. 298
  463. Taking Mocha to the browser
  464. 299
  465. Summary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement