Sams Teach Yourself Node.js In 24 Hours

2y ago
265 Views
54 Downloads
1.09 MB
58 Pages
Last View : 1m ago
Last Download : 2m ago
Upload by : Bennett Almond
Transcription

George OrnboNode.js

Sams Teach Yourself Node.js in 24 HoursCopyright 2013 by Pearson Education, Inc.All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, ortransmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, withoutwritten permission from the publisher. No patent liability is assumed with respect to the use ofthe information contained herein. Although every precaution has been taken in the preparation ofthis book, the publisher and author assume no responsibility for errors or omissions. Nor is anyliability assumed for damages resulting from the use of the information contained herein.ISBN-13: 9780672335952ISBN-10: 0672335956Library of Congress Cataloging-in-Publication Data:Printed in the United States of AmericaEditor-in-ChiefMark TaubAcquisitions EditorLaura LewinDevelopmentEditorSheri CainManaging EditorKristy HartProject EditorAnne GoebelCopy EditorGeneil BreezeFirst Printing September 2012IndexerTim WrightTrademarksProofreaderSarah KearnsAll terms mentioned in this book that are known to be trademarks or service marks have beenappropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Useof a term in this book should not be regarded as affecting the validity of any trademark or servicemark.Warning and DisclaimerEvery effort has been made to make this book as complete and as accurate as possible, but nowarranty or fitness is implied. The information provided is on an “as is” basis. The author andthe publisher shall have neither liability nor responsibility to any person or entity with respect toany loss or damages arising from the information contained in this book or from the use of theprograms accompanying it.Bulk SalesSams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contactU.S. Corporate and Government or sales outside of the U.S., please contactInternational Salesinternational@pearsoned.comTechnical EditorRemy SharpPublishingCoordinatorOlivia BasegioInterior DesignerGary AdairCover DesignerAnne JonesSenior CompositorGloria Schurick

Contents at a GlanceIntroduction . 1Part I: Getting StartedHOUR 1 Introducing Node.js . 72 npm (Node Package Manager) . 153 What Node.js Is Used For . 274 Callbacks . 41Part II: Basic Websites with Node.jsHOUR 5 HTTP . 596 Introducing Express . 737 More on Express . 918 Persisting Data . 103Part III: Debugging, Testing, and DeployingHOUR 9 Debugging Node.js Applications . 13510 Testing Node.js Applications . 15111 Deploying Node.js Applications . 169Part IV: Intermediate Sites with Node.jsHOUR 12 Introducting Socket.IO . 18913 A Socket.IO Chat Server. 21314 A Streaming Twitter Client . 23715 JSON APIs . 265

ivSams Teach Yourself Node.js in 24 HoursPart V: Exploring the Node.js APIHOUR 16 The Process Module . 29117 The Child Process Module . 30518 The Events Module. 31719 The Buffer Module . 33320 The Stream Module. 345Part VI: Further Node.js DevelopmentHOUR 21 CoffeeScript . 36122 Creating Node.js Modules. 38123 Creating Middleware with Connect . 39924 Using Node.js with Backbone.js. 417Index . 435

Table of ContentsIntroduction1Who Should Read This Book? . 1Why Should I Learn Node.js?. 2How This Book Is Organized . 2Code Examples . 2Conventions Used in This Book . 3Part I: Getting StartedHOUR 1: Introducing Node.js7What Is Node.js? . 7What You Can Do with Node.js. 8Installing and Creating Your First Node.js Program . 9Summary . 11Q&A . 12Workshop. 12Exercises . 13HOUR 2: npm (Node Package Manager)15What Is npm? . 15Installing npm . 16Installing Modules . 17Using Modules . 17How to Find Modules . 19Local and Global Installation . 21How to Find Module Documentation . 22Specifying Dependencies with package.json . 23Summary . 25Q&A . 25Workshop. 26Exercises . 26

viSams Teach Yourself Node.js in 24 HoursHOUR 3: What Node.js Is Used For27What Node.js Is Designed to Do . 27Understanding I/O . 27Dealing with Input . 29Networked I/O Is Unpredictable . 33Humans Are Unpredictable . 35Dealing with Unpredictability . 37Summary . 38Q&A . 38Workshop. 39Exercises . 39HOUR 4: Callbacks41What Is a Callback? . 41The Anatomy of a Callback . 46How Node.js Uses Callbacks. 47Synchronous and Asynchronous Code . 50The Event Loop . 53Summary . 54Q&A . 55Workshop. 55Exercises . 56Part II: Basic Websites with Node.jsHOUR 5: HTTP59What Is HTTP? . 59HTTP Servers with Node.js. 59HTTP Clients with Node.js . 69Summary . 70Q&A . 71Workshop. 71Exercises . 72

ContentsHOUR 6: Introducing Expressvii73What Is Express?. 73Why Use Express? . 73Installing Express . 74Creating a Basic Express Site . 74Exploring Express . 76Introducing Jade . 77Summary . 89Q&A . 89Workshop. 90Exercises . 90HOUR 7: More on Express91Routing in Web Applications . 91How Routing Works in Express . 91Adding a GET Route . 92Adding a POST Route . 94Using Parameters in Routes . 95Keeping Routes Maintainable . 96View Rendering. 97Using Local Variables . 99Summary . 101Q&A . 101Workshop. 101Exercises . 102HOUR 8: Persisting Data103What Is Persistent Data? . 103Writing Data to a File . 104Reading Data from a File . 105Reading Environment Variables . 106Using Databases . 108Using MongoDB with Node.js . 109Summary . 131Q&A . 131

viiiSams Teach Yourself Node.js in 24 HoursWorkshop. 132Exercises . 132Part III: Debugging, Testing, and DeployingHOUR 9: Debugging Node.js Applications135Debugging . 135The STDIO Module . 136The Node.js Debugger . 141Node Inspector . 144A Note on Testing . 147Summary . 148Q&A . 148Workshop. 149Exercises . 149HOUR 10: Testing Node.js Applications151Why Test? . 151The Assert Module . 152Third-Party Testing Tools . 155Behavior Driven Development. 159Summary . 167Q&A . 167Workshop. 168Exercises . 168HOUR 11: Deploying Node.js Applications169Ready to Deploy! . 169Hosting in the Cloud . 169Heroku . 171Cloud Foundry . 176Nodester . 180Other PaaS Providers . 184Summary . 184Q&A . 184Workshop. 185Exercises . 186

ContentsixPart IV: Intermediate Sites with Node.jsHOUR 12: Introducting Socket.IO189Now for Something Completely Different . 189Brief History of the Dynamic Web . 189Socket.IO . 191Basic Socket.IO Example . 191Sending Data from the Server to Clients . 194Broadcasting Data to Clients . 199Bi-Directional Data . 204Summary . 209Q&A . 209Workshop. 210Exercises . 210HOUR 13: A Socket.IO Chat Server213Express and Socket.IO .

vi Sams Teach Yourself Node.js in 24 Hours HOUR 3:What Node.js Is Used For 27 What Node.js Is Designed to Do .27File Size: 1MB

Related Documents:

Sams teach yourself regular expressions in 10 minutes / Ben Forta. Indianapolis, Ind. : Sams, 2004. 005.133 For 2004 Sams teach yourself PHP in 24 hours / Matt Zandstra. Indianapolis, Ind. : Sams Pub., c2004. 005.133 Zan 2004 Neal-Schuman directory of management software for public a

Tytuł oryginału: Sams Teach Yourself SQL in 10 Minutes, Fourth Edition Tłumaczenie: Rafał Jońca ISBN: 978-83-283-1089-6 Authorized translation from the English language edition: SAMS TEACH YOURSELF SQL IN 10

Tytuł oryginału: Sams Teach Yourself Bootstrap in 24 Hours Tłumaczenie: Andrzej Watrak ISBN: 978-83-283-2514-2 Authorized translation from the English language edition, entitled: BOOTSTRAP IN 24 HOURS, SAMS TEACH YOURSELF; ISBN 0672337045; by Jennifer Kyrnin; published

Meloni, Julie C. Sams teach yourself HTML and CSS 24 hours / Julie Meloni, Michael Morrison. -- 8th ed. p. cm. Rev. ed. of: Sams teach yourself HTML and CSS in 24 hours / Dick Oliver, 7th ed., 2006. ISBN 978--672-33097-1 (pbk.) 1. HTML (Document markup language) 2. XHTML (Document markup language) 3. Cascading style sheets. I. Morrison .

Tall With Spark Hadoop Worker Node Executor Cache Worker Node Executor Cache Worker Node Executor Cache Master Name Node YARN (Resource Manager) Data Node Data Node Data Node Worker Node Executor Cache Data Node HDFS Task Task Task Task Edge Node Client Libraries MATLAB Spark-submit script

Sams teach yourself node.js in 24 hours pdf download full crack . 4th Editionbook 482 10.2 MB 107 27 Basic Sensors In iOS 106 4.1 MB 63 28 Building Hypermedia Apis With HTML5 And Node 241 6.6 MB 167 29 Android Tutorial 216 3.2 MB 72 30 Beginning iOS 6 Development 750 15.6 MB 25 31

9781444106022 Complete Estonian: Teach Yourself 34.99 9781444105698 Complete Filipino (Tagalog) Audio Support: Teach Yourself 29.99 9781444105681 Complete Filipino (Tagalog) Book and CD Pack: Teach Yourself 59.99 9781444105674 Complete Filipino (Tagalog): Teach Yourself 29.99 9781444195248 Complete Finnish Audio Support: Teach Yourself (New Edition) 24.99 9781444195224 Complete .

Alfredo López Austin “Rayamiento (Tlahuahuanaliztli)” p. 15-22 : Juegos rituales aztecas Alfredo López Austin (versión, introducción y notas) México Universidad Nacional Autónoma de México . Instituto de Investigaciones Históricas : 1967 . 94 p. (Cuadernos Serie Documental 5) [Sin ISBN] Formato: PDF Publicado en línea: 21 de noviembre de 2018 . Disponible en: www.historicas.unam .