Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2014 Intro to Sails (v0.10.x)

143a2600e408b5a2edbb00c3631ed5f5?s=47 Mike McNeil
September 17, 2014

2014 Intro to Sails (v0.10.x)

This talk was given in a few different permutations in 2014-- at Powered By JavaScript in St. Louis, MO, then as the keynote presentation for Dev Workshop Conference in Indianapolis, then NorfolkJS in Norfolk, VA, and finally Nodevember in Nashville, TN.

See http://lanyrd.com/profile/mikermcneil/sessions/ for more information.

143a2600e408b5a2edbb00c3631ed5f5?s=128

Mike McNeil

September 17, 2014
Tweet

Transcript

  1. Dev Workshop Conference — 2014

  2. who am i? @mikermcneil

  3. We design and develop javascript apps for enterprise and startup

    customers. i have a startup called balderdash
  4. None
  5. I’m a sucker for Node.js. I wrote Sails. Disclaimers I

    don’t like CoffeeScript very much.
  6. love at first sight circa 2011 Node.js...

  7. We’re doing I/O completely wrong.

  8. <— just look at the Unterschied Not acceptable!

  9. Threads should be used by experts only. Concurrency should be

    easy.
  10. How is that possible? (copy the browser)

  11. // synchronous! console.log(‘hi’) // asynchronous! setTimeout(function (){! console.log(‘hi’);! }, 240000000);

    vs. incredible
  12. could we use …for everything? I wondered…

  13. so…

  14. None
  15. You don't want to be writing all these system calls.

    You need something that gives you… an ORM abstraction, or something.
  16. so Sails.js was born

  17. What is ?

  18. Sails is a backend web framework. (runs on the server)

  19. Sails is a backend web framework. (built on Express) (runs

    on the server)
  20. Sails is a backend web framework. (uses Socket.io for optional

    WebSocket support) (built on Express) (runs on the server)
  21. None
  22. None
  23. What does “backend web framework” mean?

  24. handles incoming requests Sails is a backend web framework.

  25. provides structure Sails is a backend web framework.

  26. talks to your database Sails is a backend web framework.

  27. talks to your database database(s) Sails is a backend web

    framework.
  28. Sails is NOT a frontend web framework.

  29. That’s up to you.

  30. Handling Requests

  31. Two different kinds of incoming requests:

  32. $.get(‘/hello’, function (data) {! console.log(data);! });

  33. Two different kinds of incoming requests:

  34. io.socket.get(‘/hello’, function (data) {! console.log(data);! });

  35. Two different kinds of incoming requests:

  36. same server-side code

  37. same server-side code function (req, res) {! res.json({! hello: ’world’!

    });! }
  38. same server-side code function (req, res) {! if (req.isSocket) {!

    return res.json({! hello: ‘socket’! }! }! ! return res.json({! hello: ’http’! });! }
  39. Structuring Your App

  40. Sails is an MVC framework.

  41. Sails is an MVC framework.

  42. Sails is an MVC framework.

  43. Sails is an MVC framework.

  44. Sails is an MVC framework.

  45. Sails is an MVC framework.

  46. Sails is an MVC framework.

  47. Sails is an MVC framework.

  48. Sails is an MVC framework.

  49. More Conventions

  50. Sails comes with an asset pipeline.

  51. Sails comes with an asset pipeline. (defaults to grunt)

  52. Sails comes with an asset pipeline. (but gulp is ok

    too)
  53. More Conventions

  54. Sails apps maintain Node.js best-practices.

  55. More Conventions

  56. Sails apps support existing Express code.

  57. Databases

  58. Sails ships with an ORM. (Object-Relational Mapping)

  59. Sails ships with an ORM. (Object-Relational Mapping)

  60. None
  61. None
  62. >=20 other community adapters custom app-specific adapters

  63. Put your data in the container that makes the most

    sense for it. Users Products Orders Activity ExternalUsers Administrators
  64. Put your data in the container that makes the most

    sense for it. Then join it together. Products Users Administrators Activity Orders ExternalUsers
  65. None
  66. Community

  67. • Released v0.10 in late Summer 2014 • ~7,600 Github

    stars • ~750-1500 npm downloads / day • ~100 folks in #sailsjs on freenode on average • ~1,100 questions tagged on SO Community
  68. None
  69. None
  70. Questions?

  71. Thanks! @mikermcneil mike@balderdash.co