Sails Framework Instroduction
Introduction
Sails is a MVC architecture for Node.js, like Django to Python or Ruby on Rails to
Ruby, it has support for the more modern, data-oriented style of web app
development.
It's especially good for building APIs, single apps/sites, realtime features like chat,
analytics dashboard and multiplayer games.

Running
brew install node
sudo npm -g install sails
sails new <appName>
sails lift
What Sails can do
Socket.io / Realtime / WebSockets
Supports transport agnostic routing, which allows your controllers/policies to
automatically handle Socket.io / WebSocket messages. In the past, you'd have to
maintain a separate code base to make that happen.

Performance
Built-in support for Redis session store, and Redis MQ for reverse pubsub routing.

Express
Supports the existing ecosystem of Express middleware.

REST Blueprints
Automatically generated JSON API for manipulating models
Automatic route bindings for your controller actions
Lightweight ORM
Sails provides an ORM (Object Relational Mapping) called Waterline.
Waterline not suports databases and associations yet, but are on the immediate
todo list.

Policies
They can be chained together to protec or preprocess requests for controllers.
E.g. authentication logic, role-based access control, file storage quotas.

Support for Grunt
Grunt was added in Sails v0.9. Modifying the Gruntfile you can easy add support
for your favorite template engine or css/js preprocessor.

Asset bundling
Sails bundles support for LESS and JST Templates. Modifying your app's Gruntfile,
you can add support for SASS, Handlebars, CoffeeScript, Stylus, TypeScript, etc.
MVC structure
Model
has the same philosophy from other frameworks like Rails, Django, Zend.

View
are EJS by default, but you can set Jade, etc

Controller
are just Express Middleware.
Products app example
Create Product Model:
sails generate product
This command line create 2 files:
/api/controllers/ProductController.js
/api/models/Product.js
Now open/edit the Product.js model.
Product Model
Product Controller
After a controller has been defined, Sails will automatically map out routes to give you
easy access.
get /:controller/:id?
post /:controller
put /:controller/:id
delete /:controller/:id
/:controller/find/:id?
/:controller/create
/:controller/update/:id
/:controller/destroy/:id
Now create some products:
http://localhost:1337/product/create/?name=Shoe1&description=Desc&price=20.30
Seeing product realtime list
1. Edit app.js file to list all products:

2. Create products in other browser window and see the console.log in the
http://localhost:1337:
Next steps
1. Add MySQL support;
2. Assciate Product with Category model;
3. Choose AngularJS or Backbone.js as front-end framework.
Currents status
Community is growing fast!
It can be a great full stack framework to production use soon.
3.456 starts and 339 forks on
Active IRC channel;
Google Group.
Thanks!
Leo Berdu
@leoberdu

Resources

http://sailsjs.org
https://groups.google.com/forum/#!forum/sailsjs
http://nodejs.org/
https://github.com/joyent/node/wiki/modules#wiki-web-frameworks-full

More Related Content

PDF
NodeWay in my project & sails.js
PDF
Sails.js Intro
PPT
PDF
Sails.js Model / ORM introduce
PDF
Intro to Sails.js
PPTX
DEV208 - ASP.NET MVC 5 新功能探索
PPTX
PDF
Nuxt.js - Introduction
NodeWay in my project & sails.js
Sails.js Intro
Sails.js Model / ORM introduce
Intro to Sails.js
DEV208 - ASP.NET MVC 5 新功能探索
Nuxt.js - Introduction

What's hot (20)

PPTX
Spring Boot Update
PPTX
Javascript Bundling and modularization
PDF
Integrating Browserify with Sprockets
PDF
Server Side Apocalypse, JS
PDF
Building Isomorphic Apps (JSConf.Asia 2014)
PPTX
PDF
"Backbone React Flux" Артем Тритяк
PPT
Build Your Own CMS with Apache Sling
PPTX
Introduction to node.js
ODP
RoR 101: Session 6
PDF
The Evolution of Airbnb's Frontend
PDF
RESTful Web Applications with Apache Sling
PDF
RoR 101: Session 6
PDF
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
PDF
Angular2 ecosystem
PDF
Секретный доклад о React Router - OdessaJS 2014
KEY
Nodejs web,db,hosting
PDF
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
PPT
Developing Rest services with SailsJs by Andrey Kolodnitskiy
PDF
JSConf US 2014: Building Isomorphic Apps
Spring Boot Update
Javascript Bundling and modularization
Integrating Browserify with Sprockets
Server Side Apocalypse, JS
Building Isomorphic Apps (JSConf.Asia 2014)
"Backbone React Flux" Артем Тритяк
Build Your Own CMS with Apache Sling
Introduction to node.js
RoR 101: Session 6
The Evolution of Airbnb's Frontend
RESTful Web Applications with Apache Sling
RoR 101: Session 6
Backbone.js with React Views - Server Rendering, Virtual DOM, and More!
Angular2 ecosystem
Секретный доклад о React Router - OdessaJS 2014
Nodejs web,db,hosting
OSGi in Action - How we use OSGi to build Open Liberty - Alasdair Nottingham ...
Developing Rest services with SailsJs by Andrey Kolodnitskiy
JSConf US 2014: Building Isomorphic Apps
Ad

Similar to Sails Framework Instroduction (20)

PDF
Node PDX: Intro to Sails.js
PDF
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
PPTX
Come Sail Away With Me (you guys): Node.js MVC Web API's Using Sails.js
PPT
NijmegenJS - SailsJS intro march 10 2016
PPTX
Like Ruby on Rails for Node - the Sails js framework
PDF
Introduction to sails.js
PDF
Sails.js - Overview
PDF
Sails.js: Rags to...Open Source
PDF
Rags to Open Source - AllThingsOpen, Raleigh, NC 2014
PDF
MVC way to introduce Sails.js - node.js framework
PDF
Intro to Sail.js
PDF
Building Killer RESTful APIs with NodeJs
PDF
Coders Workshop: API First Mobile Development Featuring Angular and Node
PDF
Node frameworks talk_hackerdojo
PDF
Seattle StrongLoop Node.js Workshop
PDF
Going FaaSter, Functions as a Service at Netflix
PDF
Picking the Right Node.js Framework for Your Use Case
PDF
Creating applications with Grails, Angular JS and Spring Security
PDF
Realtime MVC with Sails.js
PDF
Future of Grails
Node PDX: Intro to Sails.js
JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"
Come Sail Away With Me (you guys): Node.js MVC Web API's Using Sails.js
NijmegenJS - SailsJS intro march 10 2016
Like Ruby on Rails for Node - the Sails js framework
Introduction to sails.js
Sails.js - Overview
Sails.js: Rags to...Open Source
Rags to Open Source - AllThingsOpen, Raleigh, NC 2014
MVC way to introduce Sails.js - node.js framework
Intro to Sail.js
Building Killer RESTful APIs with NodeJs
Coders Workshop: API First Mobile Development Featuring Angular and Node
Node frameworks talk_hackerdojo
Seattle StrongLoop Node.js Workshop
Going FaaSter, Functions as a Service at Netflix
Picking the Right Node.js Framework for Your Use Case
Creating applications with Grails, Angular JS and Spring Security
Realtime MVC with Sails.js
Future of Grails
Ad

Recently uploaded (20)

PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPT
What is a Computer? Input Devices /output devices
DOCX
search engine optimization ppt fir known well about this
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Getting Started with Data Integration: FME Form 101
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
STKI Israel Market Study 2025 version august
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
Modernising the Digital Integration Hub
PDF
Architecture types and enterprise applications.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
O2C Customer Invoices to Receipt V15A.pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
What is a Computer? Input Devices /output devices
search engine optimization ppt fir known well about this
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Getting Started with Data Integration: FME Form 101
DP Operators-handbook-extract for the Mautical Institute
Enhancing emotion recognition model for a student engagement use case through...
Web Crawler for Trend Tracking Gen Z Insights.pptx
STKI Israel Market Study 2025 version august
Module 1.ppt Iot fundamentals and Architecture
Group 1 Presentation -Planning and Decision Making .pptx
Assigned Numbers - 2025 - Bluetooth® Document
1 - Historical Antecedents, Social Consideration.pdf
Modernising the Digital Integration Hub
Architecture types and enterprise applications.pdf
Tartificialntelligence_presentation.pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
O2C Customer Invoices to Receipt V15A.pptx

Sails Framework Instroduction

  • 2. Introduction Sails is a MVC architecture for Node.js, like Django to Python or Ruby on Rails to Ruby, it has support for the more modern, data-oriented style of web app development. It's especially good for building APIs, single apps/sites, realtime features like chat, analytics dashboard and multiplayer games. Running brew install node sudo npm -g install sails sails new <appName> sails lift
  • 3. What Sails can do Socket.io / Realtime / WebSockets Supports transport agnostic routing, which allows your controllers/policies to automatically handle Socket.io / WebSocket messages. In the past, you'd have to maintain a separate code base to make that happen. Performance Built-in support for Redis session store, and Redis MQ for reverse pubsub routing. Express Supports the existing ecosystem of Express middleware. REST Blueprints Automatically generated JSON API for manipulating models Automatic route bindings for your controller actions
  • 4. Lightweight ORM Sails provides an ORM (Object Relational Mapping) called Waterline. Waterline not suports databases and associations yet, but are on the immediate todo list. Policies They can be chained together to protec or preprocess requests for controllers. E.g. authentication logic, role-based access control, file storage quotas. Support for Grunt Grunt was added in Sails v0.9. Modifying the Gruntfile you can easy add support for your favorite template engine or css/js preprocessor. Asset bundling Sails bundles support for LESS and JST Templates. Modifying your app's Gruntfile, you can add support for SASS, Handlebars, CoffeeScript, Stylus, TypeScript, etc.
  • 5. MVC structure Model has the same philosophy from other frameworks like Rails, Django, Zend. View are EJS by default, but you can set Jade, etc Controller are just Express Middleware.
  • 6. Products app example Create Product Model: sails generate product This command line create 2 files: /api/controllers/ProductController.js /api/models/Product.js Now open/edit the Product.js model.
  • 8. Product Controller After a controller has been defined, Sails will automatically map out routes to give you easy access. get /:controller/:id? post /:controller put /:controller/:id delete /:controller/:id /:controller/find/:id? /:controller/create /:controller/update/:id /:controller/destroy/:id Now create some products: http://localhost:1337/product/create/?name=Shoe1&description=Desc&price=20.30
  • 9. Seeing product realtime list 1. Edit app.js file to list all products: 2. Create products in other browser window and see the console.log in the http://localhost:1337:
  • 10. Next steps 1. Add MySQL support; 2. Assciate Product with Category model; 3. Choose AngularJS or Backbone.js as front-end framework.
  • 11. Currents status Community is growing fast! It can be a great full stack framework to production use soon. 3.456 starts and 339 forks on Active IRC channel; Google Group.