Node PDX: Intro to Sails.js

6,380 views

Published on

Sails.js makes it easy to build custom, enterprise-grade Node.js apps. It is designed to resemble the MVC architecture from frameworks like Ruby on Rails, but with support for the more modern, data-oriented style of web app development. It's especially good for building realtime features like chat.

Published in: Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,380
On SlideShare
0
From Embeds
0
Number of Embeds
79
Actions
Shares
0
Downloads
79
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

Node PDX: Intro to Sails.js

  1. 1. sails.jsrealtime MVC framework for Node.js
  2. 2. who am i?@mikermcneil
  3. 3. Design and develop javascript apps forenterprise and startup customersi have a startup called balderdash
  4. 4. Realtime used tobe kind of hardXMPPCometReverse AJAXLong pollingFlash socketsWebSocketsServer-sent events
  5. 5. love at first sightcirca 2011Node.js...
  6. 6. A lot easier now
  7. 7. Can we use Node.js for,like, everything?i wondered...
  8. 8. Can we use Node.js for,like, everything?i wondered...maybe.
  9. 9. Lotsof differentkinds ofprojectsThere weren’t really any simpleand reproducible patterns forstructuring complicated Node.jsaplications top to bottom
  10. 10. Lotsof differentkinds ofprojectsThere weren’t really any simpleand reproducible patterns forstructuring complicated Node.jsaplications top to bottomCould be working with anexisting client, or writing a newclient for a mobile web browser,an automobile, a toaster, or godknows what
  11. 11. Lotsof differentkinds ofprojectsThere weren’t really any simpleand reproducible patterns forstructuring complicated Node.jsaplications top to bottomCould be working with anexisting client, or writing a newclient for a mobile web browser,an automobile, a toaster, or godknows whatLots of different 3rd partyproprietary services to deal withon the back-end -- there was nostandard way to integrate newsystems
  12. 12. Programmingrealtime appswas still nottrivial.Socket.io and Expressmessages/requests have to behandled independently, whichleads to separate code bases forrealtime and traditional servercode.
  13. 13. Programmingrealtime appswas still nottrivial.Socket.io and Expressmessages/requests have to behandled independently, whichleads to separate code bases forrealtime and traditional servercode.Socket programming is a newparadigm for many modern webdevelopers
  14. 14. Socket.io and Expressmessages/requests have to behandled independently, whichleads to separate code bases forrealtime and traditional servercode.Socket programming is a newparadigm for many modern webdevelopersQuestions about scalabilityProgrammingrealtime appswas still nottrivial.
  15. 15. Express wasn’t“structuredenough”Authentication has to be rolledfrom scratch
  16. 16. Express wasn’t“structuredenough”Authentication has to be rolledfrom scratchNo standard,implementation-agnostic methodof working with datastores
  17. 17. Express wasn’t“structuredenough”Authentication has to be rolledfrom scratchNo standard,implementation-agnostic methodof working with datastoresLow level and free-form -- not alot of guidelines for teams usedto convention-over-configurationframeworks
  18. 18. too bad.we went with Node anyway.
  19. 19. so Sails.js was born
  20. 20. MVC structureSails.js is modeled after the sameconvetion-over-configuration philosophyyou’re used to from frameworks like Rails,Grails, Symfony, and Zend.Controllers are just Express middlewareViews are ejs by default, but you can usejade, etc. We rarely use them since we’renormally making single page apps withclient-side templates.
  21. 21. Lightweight ORMKept querying semantics dead-simple andadapter-agnostic whenever possiblePulled the best of Active Record,Hibernate, and MongooseMade it easy to add purpose-built adaptersat the app level
  22. 22. PoliciesPolicies are just more Express middlewareThey can be chained together to “protect”or preprocess requests for controllersE.g. access control, storage quotas, oranything else you’d want to usemiddleware for
  23. 23. Socket.io ExpressinterpreterTranslated incoming socket.io messages intoExpress requestsTranslated res.send(), res.json(), and res.view()to respond via the socket, as well as allowingfor streamsAdded res.broadcast() and req.join() methodsfor pubsubNormalized configuration
  24. 24. BlueprintsInstead of something like Rails HTMLscaffolds, by default, when you generate amodel and controller, Sails serves an APIBuilt-in search, sort, pagination, andcomplex queriesAuthentication/access control can be builton top using policies
  25. 25. OthercoolstuffCLI toolREPLCustom adaptersOptional server-side coffeesupportAutomatic asset bundling (LESSand coffeescript files arecompiled, merged with css and js,and injected into the DOM,minified in production mode)
  26. 26. let’s code things nowOK
  27. 27. Community is growing (1900 stars, 160 forkson github, active IRC channel and Googlegroup)CURRENT STATUS (V0.8.9)
  28. 28. Community is growing (1900 stars, 160 forkson github, active IRC channel and Googlegroup)My company and most of our customers areusing Sails in productionCURRENT STATUS (V0.8.9)
  29. 29. Community is growing (1900 stars, 160 forkson github, active IRC channel and Googlegroup)My company and most of our customers areusing Sails in productionOldest running production Sails app hasbeen up for over 300 daysCURRENT STATUS (V0.8.9)
  30. 30. RoadmapMore adaptersMore modularization to allow fora la carte usage of frameworkcomponentsGrunt/Yeoman integration forasset management and appgenerationBuilt-in support for associationsin ORM
  31. 31. Contribute to an adapterWant to get involved?
  32. 32. Contribute to an adapterWork on the yeoman/gruntintegrationWant to get involved?
  33. 33. Contribute to an adapterWork on the yeoman/gruntintegrationPlay with Sails and come up withmore cool shitWant to get involved?
  34. 34. Questions?
  35. 35. Special thanks to:@colinwren@dcbartlett@particlebanana@tedkulpIrl NathanTroy & NodePDXDan Dwyer & Joyent& all the other excellent Sails.js contributors
  36. 36. Thanks!@mikermcneilmike@balderdash.co

×