1 / 19

Node.js Packages

Node.js Packages. March 13, 2012 Shamoon Siddiqui @ shamoons. What are packages?. Ruby has Gems Python has Py PI PHP has PEAR (terrible) Node.js has Packages. Node Package Manager (NPM). Get NPM at http://npmjs.org / Almost 8,000 packages! Seriously... one line install.

carrington
Download Presentation

Node.js Packages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Node.js Packages March 13, 2012 Shamoon Siddiqui @shamoons

  2. What are packages? • Ruby has Gems • Python has PyPI • PHP has PEAR (terrible) • Node.js has Packages

  3. Node Package Manager (NPM) • Get NPM at http://npmjs.org/ • Almost 8,000 packages! • Seriously... one line install • curl http://npmjs.org/install.sh | sh

  4. Awesome Packages • express • mongoose • async • socket.io • request

  5. express • Kickass Framework for Web Application Development • Routing • Sessions • Templating • $: npm install –g express • $: express mysite

  6. routes/index.js

  7. mongoose • MongoDB is awesome (look at where we are!!!!) • Interaction with MongoDB via an ODM • Keeps Code Clean

  8. Models Screenshots from MongooseJs.com

  9. Mongoose Functions Finding Model.find({name: “shamoon”}, function(err, data){console.log(data);}) Model.findOne() Model.findById()

  10. async • Callbacks are awesome • Except when they’re nested • Unless they’re well managed • Then nesting doesn’t become a huge issue • But it is still difficult to read • A function within a function • …within a function

  11. WTF??

  12. Adapted from Ryan Roemer (@ryan_roemer)

  13. Control Flow Series series waterfall Parallel parallel queue

  14. socket.io Server Client

  15. Emit and Receive • Basic model is to "emit" an event with data • Received "listens" for events • Acts on reception of event • Client or Server can be emitter or listener

  16. request • HTTP Requests made easy • POST • GET • JSON • XML

  17. Instant Proxy Server! https://github.com/mikeal/request

  18. Questions? Shamoon Siddiqui @shamoons

More Related