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

2014 Intro to Sails (v0.10.x)

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.

Mike McNeil

September 17, 2014
Tweet

More Decks by Mike McNeil

Other Decks in Technology

Transcript

  1. Dev Workshop Conference — 2014

    View Slide

  2. who am i?
    @mikermcneil

    View Slide

  3. We design and develop javascript apps for
    enterprise and startup customers.
    i have a startup called balderdash

    View Slide

  4. View Slide

  5. I’m a sucker for Node.js.
    I wrote Sails.
    Disclaimers
    I don’t like CoffeeScript very much.

    View Slide

  6. love at first sight
    circa 2011
    Node.js...

    View Slide

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

    View Slide

  8. Unterschied
    Not acceptable!

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  13. so…

    View Slide

  14. View Slide

  15. You don't want to be writing all
    these system calls.
    You need something that gives
    you… an ORM abstraction, or
    something.

    View Slide

  16. so Sails.js was born

    View Slide

  17. What is
    ?

    View Slide

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

    View Slide

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

    View Slide

  20. Sails is a backend web framework.
    (uses Socket.io for optional WebSocket support)
    (built on Express)
    (runs on the server)

    View Slide

  21. View Slide

  22. View Slide

  23. What does “backend web framework” mean?

    View Slide

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

    View Slide

  25. provides structure
    Sails is a backend web framework.

    View Slide

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

    View Slide

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

    View Slide

  28. Sails is NOT a frontend web framework.

    View Slide

  29. That’s up to you.

    View Slide

  30. Handling Requests

    View Slide

  31. Two different kinds of incoming requests:

    View Slide

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

    View Slide

  33. Two different kinds of incoming requests:

    View Slide

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

    View Slide

  35. Two different kinds of incoming requests:

    View Slide

  36. same server-side code

    View Slide

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

    View Slide

  38. same server-side code
    function (req, res) {!
    if (req.isSocket) {!
    return res.json({!
    hello: ‘socket’!
    }!
    }!
    !
    return res.json({!
    hello: ’http’!
    });!
    }

    View Slide

  39. Structuring Your App

    View Slide

  40. Sails is an MVC framework.

    View Slide

  41. Sails is an MVC framework.

    View Slide

  42. Sails is an MVC framework.

    View Slide

  43. Sails is an MVC framework.

    View Slide

  44. Sails is an MVC framework.

    View Slide

  45. Sails is an MVC framework.

    View Slide

  46. Sails is an MVC framework.

    View Slide

  47. Sails is an MVC framework.

    View Slide

  48. Sails is an MVC framework.

    View Slide

  49. More Conventions

    View Slide

  50. Sails comes with an asset pipeline.

    View Slide

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

    View Slide

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

    View Slide

  53. More Conventions

    View Slide

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

    View Slide

  55. More Conventions

    View Slide

  56. Sails apps support existing Express code.

    View Slide

  57. Databases

    View Slide

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

    View Slide

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

    View Slide

  60. View Slide

  61. View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  65. View Slide

  66. Community

    View Slide

  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

    View Slide

  68. View Slide

  69. View Slide

  70. Questions?

    View Slide

  71. Thanks!
    @mikermcneil
    [email protected]

    View Slide