sails.js
realtime MVC framework for Node.js
who am i?
@mikermcneil
Design and develop javascript apps for
enterprise and startup customers
i have a startup called balderdash
Realtime used to
be kind of hard
XMPP
Comet
Reverse AJAX
Long polling
Flash sockets
WebSockets
Server-sent events
love at first sight
circa 2011
Node.js...
A lot easier now
Can we use Node.js for,
like, everything?
i wondered...
Can we use Node.js for,
like, everything?
i wondered...
maybe.
Lots
of different
kinds of
projects
There weren’t really any simple
and reproducible patterns for
structuring complicated Node.js
aplications top to bottom
Lots
of different
kinds of
projects
There weren’t really any simple
and reproducible patterns for
structuring complicated Node.js
aplications top to bottom
Could be working with an
existing client, or writing a new
client for a mobile web browser,
an automobile, a toaster, or god
knows what
Lots
of different
kinds of
projects
There weren’t really any simple
and reproducible patterns for
structuring complicated Node.js
aplications top to bottom
Could be working with an
existing client, or writing a new
client for a mobile web browser,
an automobile, a toaster, or god
knows what
Lots of different 3rd party
proprietary services to deal with
on the back-end -- there was no
standard way to integrate new
systems
Programming
realtime apps
was still not
trivial.
Socket.io and Express
messages/requests have to be
handled independently, which
leads to separate code bases for
realtime and traditional server
code.
Programming
realtime apps
was still not
trivial.
Socket.io and Express
messages/requests have to be
handled independently, which
leads to separate code bases for
realtime and traditional server
code.
Socket programming is a new
paradigm for many modern web
developers
Socket.io and Express
messages/requests have to be
handled independently, which
leads to separate code bases for
realtime and traditional server
code.
Socket programming is a new
paradigm for many modern web
developers
Questions about scalability
Programming
realtime apps
was still not
trivial.
Express wasn’t
“structured
enough”
Authentication has to be rolled
from scratch
Express wasn’t
“structured
enough”
Authentication has to be rolled
from scratch
No standard,
implementation-agnostic method
of working with datastores
Express wasn’t
“structured
enough”
Authentication has to be rolled
from scratch
No standard,
implementation-agnostic method
of working with datastores
Low level and free-form -- not a
lot of guidelines for teams used
to convention-over-configuration
frameworks
too bad.
we went with Node anyway.
so Sails.js was born
MVC structure
Sails.js is modeled after the same
convetion-over-configuration philosophy
you’re used to from frameworks like Rails,
Grails, Symfony, and Zend.
Controllers are just Express middleware
Views are ejs by default, but you can use
jade, etc. We rarely use them since we’re
normally making single page apps with
client-side templates.
Lightweight ORM
Kept querying semantics dead-simple and
adapter-agnostic whenever possible
Pulled the best of Active Record,
Hibernate, and Mongoose
Made it easy to add purpose-built adapters
at the app level
Policies
Policies are just more Express middleware
They can be chained together to “protect”
or preprocess requests for controllers
E.g. access control, storage quotas, or
anything else you’d want to use
middleware for
Socket.io Express
interpreter
Translated incoming socket.io messages into
Express requests
Translated res.send(), res.json(), and res.view()
to respond via the socket, as well as allowing
for streams
Added res.broadcast() and req.join() methods
for pubsub
Normalized configuration
Blueprints
Instead of something like Rails HTML
scaffolds, by default, when you generate a
model and controller, Sails serves an API
Built-in search, sort, pagination, and
complex queries
Authentication/access control can be built
on top using policies
Other
cool
stuff
CLI tool
REPL
Custom adapters
Optional server-side coffee
support
Automatic asset bundling (LESS
and coffeescript files are
compiled, merged with css and js,
and injected into the DOM,
minified in production mode)
let’s code things now
OK
Community is growing (1900 stars, 160 forks
on github, active IRC channel and Google
group)
CURRENT STATUS (V0.8.9)
Community is growing (1900 stars, 160 forks
on github, active IRC channel and Google
group)
My company and most of our customers are
using Sails in production
CURRENT STATUS (V0.8.9)
Community is growing (1900 stars, 160 forks
on github, active IRC channel and Google
group)
My company and most of our customers are
using Sails in production
Oldest running production Sails app has
been up for over 300 days
CURRENT STATUS (V0.8.9)
Roadmap
More adapters
More modularization to allow for
a la carte usage of framework
components
Grunt/Yeoman integration for
asset management and app
generation
Built-in support for associations
in ORM
Contribute to an adapter
Want to get involved?
Contribute to an adapter
Work on the yeoman/grunt
integration
Want to get involved?
Contribute to an adapter
Work on the yeoman/grunt
integration
Play with Sails and come up with
more cool shit
Want to get involved?
Questions?
Special thanks to:
@colinwren
@dcbartlett
@particlebanana
@tedkulp
Irl Nathan
Troy & NodePDX
Dan Dwyer & Joyent
& all the other excellent Sails.js contributors
Thanks!
@mikermcneil
mike@balderdash.co

Node PDX: Intro to Sails.js

  • 1.
  • 2.
  • 3.
    Design and developjavascript apps for enterprise and startup customers i have a startup called balderdash
  • 4.
    Realtime used to bekind of hard XMPP Comet Reverse AJAX Long polling Flash sockets WebSockets Server-sent events
  • 5.
    love at firstsight circa 2011 Node.js...
  • 6.
  • 7.
    Can we useNode.js for, like, everything? i wondered...
  • 8.
    Can we useNode.js for, like, everything? i wondered... maybe.
  • 9.
    Lots of different kinds of projects Thereweren’t really any simple and reproducible patterns for structuring complicated Node.js aplications top to bottom
  • 10.
    Lots of different kinds of projects Thereweren’t really any simple and reproducible patterns for structuring complicated Node.js aplications top to bottom Could be working with an existing client, or writing a new client for a mobile web browser, an automobile, a toaster, or god knows what
  • 11.
    Lots of different kinds of projects Thereweren’t really any simple and reproducible patterns for structuring complicated Node.js aplications top to bottom Could be working with an existing client, or writing a new client for a mobile web browser, an automobile, a toaster, or god knows what Lots of different 3rd party proprietary services to deal with on the back-end -- there was no standard way to integrate new systems
  • 12.
    Programming realtime apps was stillnot trivial. Socket.io and Express messages/requests have to be handled independently, which leads to separate code bases for realtime and traditional server code.
  • 13.
    Programming realtime apps was stillnot trivial. Socket.io and Express messages/requests have to be handled independently, which leads to separate code bases for realtime and traditional server code. Socket programming is a new paradigm for many modern web developers
  • 14.
    Socket.io and Express messages/requestshave to be handled independently, which leads to separate code bases for realtime and traditional server code. Socket programming is a new paradigm for many modern web developers Questions about scalability Programming realtime apps was still not trivial.
  • 15.
  • 16.
    Express wasn’t “structured enough” Authentication hasto be rolled from scratch No standard, implementation-agnostic method of working with datastores
  • 17.
    Express wasn’t “structured enough” Authentication hasto be rolled from scratch No standard, implementation-agnostic method of working with datastores Low level and free-form -- not a lot of guidelines for teams used to convention-over-configuration frameworks
  • 18.
    too bad. we wentwith Node anyway.
  • 19.
  • 20.
    MVC structure Sails.js ismodeled after the same convetion-over-configuration philosophy you’re used to from frameworks like Rails, Grails, Symfony, and Zend. Controllers are just Express middleware Views are ejs by default, but you can use jade, etc. We rarely use them since we’re normally making single page apps with client-side templates.
  • 21.
    Lightweight ORM Kept queryingsemantics dead-simple and adapter-agnostic whenever possible Pulled the best of Active Record, Hibernate, and Mongoose Made it easy to add purpose-built adapters at the app level
  • 22.
    Policies Policies are justmore Express middleware They can be chained together to “protect” or preprocess requests for controllers E.g. access control, storage quotas, or anything else you’d want to use middleware for
  • 24.
    Socket.io Express interpreter Translated incomingsocket.io messages into Express requests Translated res.send(), res.json(), and res.view() to respond via the socket, as well as allowing for streams Added res.broadcast() and req.join() methods for pubsub Normalized configuration
  • 26.
    Blueprints Instead of somethinglike Rails HTML scaffolds, by default, when you generate a model and controller, Sails serves an API Built-in search, sort, pagination, and complex queries Authentication/access control can be built on top using policies
  • 27.
    Other cool stuff CLI tool REPL Custom adapters Optionalserver-side coffee support Automatic asset bundling (LESS and coffeescript files are compiled, merged with css and js, and injected into the DOM, minified in production mode)
  • 30.
  • 31.
    Community is growing(1900 stars, 160 forks on github, active IRC channel and Google group) CURRENT STATUS (V0.8.9)
  • 32.
    Community is growing(1900 stars, 160 forks on github, active IRC channel and Google group) My company and most of our customers are using Sails in production CURRENT STATUS (V0.8.9)
  • 33.
    Community is growing(1900 stars, 160 forks on github, active IRC channel and Google group) My company and most of our customers are using Sails in production Oldest running production Sails app has been up for over 300 days CURRENT STATUS (V0.8.9)
  • 34.
    Roadmap More adapters More modularizationto allow for a la carte usage of framework components Grunt/Yeoman integration for asset management and app generation Built-in support for associations in ORM
  • 35.
    Contribute to anadapter Want to get involved?
  • 36.
    Contribute to anadapter Work on the yeoman/grunt integration Want to get involved?
  • 37.
    Contribute to anadapter Work on the yeoman/grunt integration Play with Sails and come up with more cool shit Want to get involved?
  • 38.
  • 39.
    Special thanks to: @colinwren @dcbartlett @particlebanana @tedkulp IrlNathan Troy & NodePDX Dan Dwyer & Joyent & all the other excellent Sails.js contributors
  • 40.