SlideShare a Scribd company logo
Developing REST
services with SailsJS
What is SailsJS?
✘ MVC backend framework for Node.js
✘ Built on top of Express
✘ Inspired by Ruby on Rails / Zend
✘ Convention over configuration
✘ Ideal for real time applications, games, REST
services
Core features
✘ Database agnostic (Waterline ORM)
✘ Front end agnostic
✘ Auto generated REST API
✘ Auto generated model methods
✘ DB migration support
✘ Easy web socket support
✘ Flexible configuration
✘ Multiple environments support
✘ Localization support
✘ Still allows to use Express
Installation and first application
✘ npm install -g sails
✘ cd to your project folder
✘ sails new [path]//path is optional
✘ npm install //optional depends on version
✘ sails lift
Running application
Project structure
✘ api/controller – controllers
✘ api/model – models
✘ api/policies – policies
✘ api/responses – application responses
✘ api/services – reusable services
✘ assets – static assets
✘ config – application configuration settings
✘ views – application views
✘ tasks – grunt cli tasks
Generate API Sample
✘ Sails generate api Category
✘ What just has happened:
✗ CategoryController is created
✗ Category model is created
✗ Sails created blueprint for route /category
✘ Let’s run the app
✘ Note: Model and controller can be generated same
way
Migration options
Models
✘ Located at: Api/models
✘ Describes:
✗ DB mapping
✗ Validation rules
✗ Custom functions
✗ And other settings like: migration strategy,
schema, primary key properties
✘ Please refer to Waterline ORM documentation
✘ Note: SailsJS supports polyglot persistence layer by
allowing models to be stored in different databases
Supported databases
✘ PostgreSQL - 0.9+ compatible
✘ MySQL - 0.9+ compatible
✘ MongoDB - 0.9+ compatible
✘ Memory - 0.9+ compatible
✘ Disk - 0.9+ compatible
✘ Microsoft SQL Server
✘ Redis
✘ Riak
✘ Neo4j
✘ OrientDB
✘ ArangoDB
✘ Apache Cassandra
✘ GraphQL
✘ Solr
✘ Apache Derby
✘ And many others
How does it work with multiple databases?
✘ It uses Waterline adapters concept
✘ Waterline defines query language
✘ Then each adapter knows how to:
✗ Connect to each specific DB
✗ Turn query object into specific DB query
✗ Read/Write data from the source
Model sample
Model blueprints
✘ following methods are available for each property:
✗ findOneByPropertyName
✗ findOneByPropertyNameIn
✗ findOneByPropertyNameLike
✗ findByPropertyName
✗ findByPropertyNameIn
✗ findByPropertyNameLike
✗ countByPropertyName
✗ countByPropertyNameIn
✗ countByPropertyNameLike
✗ propertyNameStartsWith
✗ propertyNameEndsWith
✗ propertyNameContains
Model blueprints
✘ find() – accepts object with query definition like
{where: {name:{startsWith:”A”}}}
✘ Or it can an be called as chain: Category.find().skip
(10).limit(10)
✘ Supports:
✗ Filtering
✗ Paging
✗ Sorting
Controller
✘ Full support for RESTful routes
✘ Shortcut routes
✘ Can have custom actions
✘ Can be put in subdirs and subdir becomes part of
the route
✘ Has standard methods for CRUD support which can
be overridden
✘ Policies can be applied either per action or for entire
controller
Controller: custom action sample
Policies
✘ Used for authentication/authorization or like simple
handlers
✘ Can be applied:
✗ Globally
✗ On controllers
✗ On controller actions
✘ Can be integrated with Passport
Policy sample
Services
✘ Contains reusable logic across application
✘ Automatically registered by Sails like Model or
Controller
✘ Sample: https://github.com/balderdashy/sails-docs/blob/0.9/services.md
Assets
✘ This folder is just for static content
✘ Note: No need to add “/assets” in URL
Configuration
✘ Allows to configure:
✗ Environments
✗ Locales
✗ Blueprints – routing rules
✗ Connection strings
✗ Application bootstrap
✗ Sessions
✗ Sockets
✗ View engine
✗ Logging
Views
✘ View is simple HTML page
✘ Multiple view engines are supported
✘ Default is EJB
What about realtime?
✘ Based on socket.io
✘ By default notifies of any changes in any model
✘ Can notify of data requested
✘ Allows to write custom endpoints
✘ Does have scalability option by using redis as a
pub/sub storage
✘ Has transport fallback (long polling or web sockets)
Demo
Sum Up
✘ Runs on any platform
✘ Front end agnostic
✘ DB agnostic
✘ Good for prototyping
✘ Speeds up implementation
✘ Does not require sails to be installed in production
✘ Provides fallback to express when needed
Cons
✘ Is not as fast as Express could be
✘ Some adapters do not support native and effective
DB capabilities
✘ In theory switching from one DB adapter to another
go seamless in practice it’s a PAIN!
✘ Mixing DB can be an issue when you do have
associations
✘ Does not suit well for complex data structures
✘ No transaction support
THANKS!
Any questions?

More Related Content

What's hot (20)

PDF
Simple cloud reference architecture
DaeMyung Kang
 
PDF
The State of Rust Web Frameworks
IanWagner10
 
PDF
Introduction to Modern DevOps Technologies
Kriangkrai Chaonithi
 
PDF
ASP.NET Scalability - DDD7
Phil Pursglove
 
PDF
Jayway Web Tech Radar 2015
Gustaf Nilsson Kotte
 
PPTX
NoSQL Database in .NET Apps
Shiju Varghese
 
PDF
Gatsby (Code.Talks) 2019
Stefan Adolf
 
PDF
wp-cli and plugin development with future and past compatibility (Word Camp P...
Andreas - Creten
 
PPTX
12 Factor Apps and Cloud Foundry - Twin Cities Code Camp
David Strebel
 
PDF
Nginx caching
reneedv
 
PDF
Introduction to DevOps and the Practical Use Cases at Credit OK
Kriangkrai Chaonithi
 
PPTX
Javascript Myths and its Evolution
Deepu S Nath
 
PDF
ColdFusion in Transit action
ColdFusionConference
 
PDF
BUILDING WEB APPS WITH ASP.NET MVC AND NOSQL
Michael Kennedy
 
PPTX
Gutenberg: You Can't Teach an Old Dev New Tricks - WordCamp Chicago 2018
Mike Hale
 
PDF
Browserscope oscon 2011
lsimon
 
PPTX
Building the AO tech blog
AO Tech
 
PPTX
Melbourne User Group OAK and MongoDB
Yuval Ararat
 
PPTX
It's in the cloud
kenperkins
 
PDF
ASP.NET Scalability - NxtGen Oxford
Phil Pursglove
 
Simple cloud reference architecture
DaeMyung Kang
 
The State of Rust Web Frameworks
IanWagner10
 
Introduction to Modern DevOps Technologies
Kriangkrai Chaonithi
 
ASP.NET Scalability - DDD7
Phil Pursglove
 
Jayway Web Tech Radar 2015
Gustaf Nilsson Kotte
 
NoSQL Database in .NET Apps
Shiju Varghese
 
Gatsby (Code.Talks) 2019
Stefan Adolf
 
wp-cli and plugin development with future and past compatibility (Word Camp P...
Andreas - Creten
 
12 Factor Apps and Cloud Foundry - Twin Cities Code Camp
David Strebel
 
Nginx caching
reneedv
 
Introduction to DevOps and the Practical Use Cases at Credit OK
Kriangkrai Chaonithi
 
Javascript Myths and its Evolution
Deepu S Nath
 
ColdFusion in Transit action
ColdFusionConference
 
BUILDING WEB APPS WITH ASP.NET MVC AND NOSQL
Michael Kennedy
 
Gutenberg: You Can't Teach an Old Dev New Tricks - WordCamp Chicago 2018
Mike Hale
 
Browserscope oscon 2011
lsimon
 
Building the AO tech blog
AO Tech
 
Melbourne User Group OAK and MongoDB
Yuval Ararat
 
It's in the cloud
kenperkins
 
ASP.NET Scalability - NxtGen Oxford
Phil Pursglove
 

Viewers also liked (7)

PDF
JS Lab`16. Виктор Турский: "Современные тенденции в разработке frontend"
GeeksLab Odessa
 
PDF
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
GeeksLab Odessa
 
PDF
JS Lab`16. Андрей Копенкин: "RethinkDB + Socket.io. Real-time web 2.0"
GeeksLab Odessa
 
PDF
JS Lab`16. Максим Климишин: "Smarter React.js: UI faster, UX better"
GeeksLab Odessa
 
PDF
JS Lab`16. Виктор Клочихин: "Redux в реальной жизни"
GeeksLab Odessa
 
PDF
JS Lab`16. Роман Лютиков: "ClojureScript, что ты такое?"
GeeksLab Odessa
 
PDF
AI&BigData Lab 2016. Сергей Шельпук: Методология Data Science проектов
GeeksLab Odessa
 
JS Lab`16. Виктор Турский: "Современные тенденции в разработке frontend"
GeeksLab Odessa
 
JS Lab`16. Сергей Селецкий: "Ретроспектива тестирования JavaScript"
GeeksLab Odessa
 
JS Lab`16. Андрей Копенкин: "RethinkDB + Socket.io. Real-time web 2.0"
GeeksLab Odessa
 
JS Lab`16. Максим Климишин: "Smarter React.js: UI faster, UX better"
GeeksLab Odessa
 
JS Lab`16. Виктор Клочихин: "Redux в реальной жизни"
GeeksLab Odessa
 
JS Lab`16. Роман Лютиков: "ClojureScript, что ты такое?"
GeeksLab Odessa
 
AI&BigData Lab 2016. Сергей Шельпук: Методология Data Science проектов
GeeksLab Odessa
 
Ad

Similar to JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS" (20)

PPT
Developing Rest services with SailsJs by Andrey Kolodnitskiy
Lohika_Odessa_TechTalks
 
PPT
Sails js
Andrey Kolodnitsky
 
PDF
Intro to Sails.js
DevOpsDays Austin 2014
 
PDF
Sails.js Intro
Nicholas Jansma
 
PDF
Sails Framework Instroduction
Leo Berdu
 
PDF
Node PDX: Intro to Sails.js
Mike McNeil
 
PDF
Intro to Sail.js
Nicholas McClay
 
PPTX
Come Sail Away With Me (you guys): Node.js MVC Web API's Using Sails.js
Eric Nograles
 
PPT
NijmegenJS - SailsJS intro march 10 2016
Barry Nijenhuis
 
PPTX
Like Ruby on Rails for Node - the Sails js framework
Stenio Ferreira
 
PDF
Node.js Course 2 of 2 - Advanced techniques
Manuel Eusebio de Paz Carmona
 
PDF
Divide and Conquer – Microservices with Node.js
Sebastian Springer
 
PDF
Microservices - opportunities, dilemmas and problems
Łukasz Sowa
 
PDF
MVC way to introduce Sails.js - node.js framework
Caesar Chi
 
PDF
Modern Architectures with Spring and JavaScript
martinlippert
 
PDF
Seattle StrongLoop Node.js Workshop
Jimmy Guerrero
 
KEY
20120306 dublin js
Richard Rodger
 
PDF
Introduction to sails.js
Amit Bidwai
 
PDF
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
PDF
Coders Workshop: API First Mobile Development Featuring Angular and Node
Apigee | Google Cloud
 
Developing Rest services with SailsJs by Andrey Kolodnitskiy
Lohika_Odessa_TechTalks
 
Intro to Sails.js
DevOpsDays Austin 2014
 
Sails.js Intro
Nicholas Jansma
 
Sails Framework Instroduction
Leo Berdu
 
Node PDX: Intro to Sails.js
Mike McNeil
 
Intro to Sail.js
Nicholas McClay
 
Come Sail Away With Me (you guys): Node.js MVC Web API's Using Sails.js
Eric Nograles
 
NijmegenJS - SailsJS intro march 10 2016
Barry Nijenhuis
 
Like Ruby on Rails for Node - the Sails js framework
Stenio Ferreira
 
Node.js Course 2 of 2 - Advanced techniques
Manuel Eusebio de Paz Carmona
 
Divide and Conquer – Microservices with Node.js
Sebastian Springer
 
Microservices - opportunities, dilemmas and problems
Łukasz Sowa
 
MVC way to introduce Sails.js - node.js framework
Caesar Chi
 
Modern Architectures with Spring and JavaScript
martinlippert
 
Seattle StrongLoop Node.js Workshop
Jimmy Guerrero
 
20120306 dublin js
Richard Rodger
 
Introduction to sails.js
Amit Bidwai
 
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
Coders Workshop: API First Mobile Development Featuring Angular and Node
Apigee | Google Cloud
 
Ad

More from GeeksLab Odessa (20)

PDF
DataScience Lab2017_Коррекция геометрических искажений оптических спутниковых...
GeeksLab Odessa
 
PDF
DataScience Lab 2017_Kappa Architecture: How to implement a real-time streami...
GeeksLab Odessa
 
PDF
DataScience Lab 2017_Блиц-доклад_Турский Виктор
GeeksLab Odessa
 
PDF
DataScience Lab 2017_Обзор методов детекции лиц на изображение
GeeksLab Odessa
 
PDF
DataScienceLab2017_Сходство пациентов: вычистка дубликатов и предсказание про...
GeeksLab Odessa
 
PDF
DataScienceLab2017_Блиц-доклад
GeeksLab Odessa
 
PDF
DataScienceLab2017_Блиц-доклад
GeeksLab Odessa
 
PDF
DataScienceLab2017_Блиц-доклад
GeeksLab Odessa
 
PDF
DataScienceLab2017_Cервинг моделей, построенных на больших данных с помощью A...
GeeksLab Odessa
 
PDF
DataScienceLab2017_BioVec: Word2Vec в задачах анализа геномных данных и биоин...
GeeksLab Odessa
 
PDF
DataScienceLab2017_Data Sciences и Big Data в Телекоме_Александр Саенко
GeeksLab Odessa
 
PDF
DataScienceLab2017_Высокопроизводительные вычислительные возможности для сист...
GeeksLab Odessa
 
PDF
DataScience Lab 2017_Мониторинг модных трендов с помощью глубокого обучения и...
GeeksLab Odessa
 
PDF
DataScience Lab 2017_Кто здесь? Автоматическая разметка спикеров на телефонны...
GeeksLab Odessa
 
PDF
DataScience Lab 2017_From bag of texts to bag of clusters_Терпиль Евгений / П...
GeeksLab Odessa
 
PDF
DataScience Lab 2017_Графические вероятностные модели для принятия решений в ...
GeeksLab Odessa
 
PDF
DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...
GeeksLab Odessa
 
PDF
DataScienceLab2017_Как знать всё о покупателях (или почти всё)?_Дарина Перемот
GeeksLab Odessa
 
PDF
JS Lab 2017_Mapbox GL: как работают современные интерактивные карты_Владимир ...
GeeksLab Odessa
 
PPTX
JS Lab2017_Под микроскопом: блеск и нищета микросервисов на node.js
GeeksLab Odessa
 
DataScience Lab2017_Коррекция геометрических искажений оптических спутниковых...
GeeksLab Odessa
 
DataScience Lab 2017_Kappa Architecture: How to implement a real-time streami...
GeeksLab Odessa
 
DataScience Lab 2017_Блиц-доклад_Турский Виктор
GeeksLab Odessa
 
DataScience Lab 2017_Обзор методов детекции лиц на изображение
GeeksLab Odessa
 
DataScienceLab2017_Сходство пациентов: вычистка дубликатов и предсказание про...
GeeksLab Odessa
 
DataScienceLab2017_Блиц-доклад
GeeksLab Odessa
 
DataScienceLab2017_Блиц-доклад
GeeksLab Odessa
 
DataScienceLab2017_Блиц-доклад
GeeksLab Odessa
 
DataScienceLab2017_Cервинг моделей, построенных на больших данных с помощью A...
GeeksLab Odessa
 
DataScienceLab2017_BioVec: Word2Vec в задачах анализа геномных данных и биоин...
GeeksLab Odessa
 
DataScienceLab2017_Data Sciences и Big Data в Телекоме_Александр Саенко
GeeksLab Odessa
 
DataScienceLab2017_Высокопроизводительные вычислительные возможности для сист...
GeeksLab Odessa
 
DataScience Lab 2017_Мониторинг модных трендов с помощью глубокого обучения и...
GeeksLab Odessa
 
DataScience Lab 2017_Кто здесь? Автоматическая разметка спикеров на телефонны...
GeeksLab Odessa
 
DataScience Lab 2017_From bag of texts to bag of clusters_Терпиль Евгений / П...
GeeksLab Odessa
 
DataScience Lab 2017_Графические вероятностные модели для принятия решений в ...
GeeksLab Odessa
 
DataScienceLab2017_Оптимизация гиперпараметров машинного обучения при помощи ...
GeeksLab Odessa
 
DataScienceLab2017_Как знать всё о покупателях (или почти всё)?_Дарина Перемот
GeeksLab Odessa
 
JS Lab 2017_Mapbox GL: как работают современные интерактивные карты_Владимир ...
GeeksLab Odessa
 
JS Lab2017_Под микроскопом: блеск и нищета микросервисов на node.js
GeeksLab Odessa
 

Recently uploaded (20)

PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 

JS Lab`16. Андрей Колодницкий: "Разработка REST сервисов на SailsJS"

  • 2. What is SailsJS? ✘ MVC backend framework for Node.js ✘ Built on top of Express ✘ Inspired by Ruby on Rails / Zend ✘ Convention over configuration ✘ Ideal for real time applications, games, REST services
  • 3. Core features ✘ Database agnostic (Waterline ORM) ✘ Front end agnostic ✘ Auto generated REST API ✘ Auto generated model methods ✘ DB migration support ✘ Easy web socket support ✘ Flexible configuration ✘ Multiple environments support ✘ Localization support ✘ Still allows to use Express
  • 4. Installation and first application ✘ npm install -g sails ✘ cd to your project folder ✘ sails new [path]//path is optional ✘ npm install //optional depends on version ✘ sails lift
  • 6. Project structure ✘ api/controller – controllers ✘ api/model – models ✘ api/policies – policies ✘ api/responses – application responses ✘ api/services – reusable services ✘ assets – static assets ✘ config – application configuration settings ✘ views – application views ✘ tasks – grunt cli tasks
  • 7. Generate API Sample ✘ Sails generate api Category ✘ What just has happened: ✗ CategoryController is created ✗ Category model is created ✗ Sails created blueprint for route /category ✘ Let’s run the app ✘ Note: Model and controller can be generated same way
  • 9. Models ✘ Located at: Api/models ✘ Describes: ✗ DB mapping ✗ Validation rules ✗ Custom functions ✗ And other settings like: migration strategy, schema, primary key properties ✘ Please refer to Waterline ORM documentation ✘ Note: SailsJS supports polyglot persistence layer by allowing models to be stored in different databases
  • 10. Supported databases ✘ PostgreSQL - 0.9+ compatible ✘ MySQL - 0.9+ compatible ✘ MongoDB - 0.9+ compatible ✘ Memory - 0.9+ compatible ✘ Disk - 0.9+ compatible ✘ Microsoft SQL Server ✘ Redis ✘ Riak ✘ Neo4j ✘ OrientDB ✘ ArangoDB ✘ Apache Cassandra ✘ GraphQL ✘ Solr ✘ Apache Derby ✘ And many others
  • 11. How does it work with multiple databases? ✘ It uses Waterline adapters concept ✘ Waterline defines query language ✘ Then each adapter knows how to: ✗ Connect to each specific DB ✗ Turn query object into specific DB query ✗ Read/Write data from the source
  • 13. Model blueprints ✘ following methods are available for each property: ✗ findOneByPropertyName ✗ findOneByPropertyNameIn ✗ findOneByPropertyNameLike ✗ findByPropertyName ✗ findByPropertyNameIn ✗ findByPropertyNameLike ✗ countByPropertyName ✗ countByPropertyNameIn ✗ countByPropertyNameLike ✗ propertyNameStartsWith ✗ propertyNameEndsWith ✗ propertyNameContains
  • 14. Model blueprints ✘ find() – accepts object with query definition like {where: {name:{startsWith:”A”}}} ✘ Or it can an be called as chain: Category.find().skip (10).limit(10) ✘ Supports: ✗ Filtering ✗ Paging ✗ Sorting
  • 15. Controller ✘ Full support for RESTful routes ✘ Shortcut routes ✘ Can have custom actions ✘ Can be put in subdirs and subdir becomes part of the route ✘ Has standard methods for CRUD support which can be overridden ✘ Policies can be applied either per action or for entire controller
  • 17. Policies ✘ Used for authentication/authorization or like simple handlers ✘ Can be applied: ✗ Globally ✗ On controllers ✗ On controller actions ✘ Can be integrated with Passport
  • 19. Services ✘ Contains reusable logic across application ✘ Automatically registered by Sails like Model or Controller ✘ Sample: https://github.com/balderdashy/sails-docs/blob/0.9/services.md
  • 20. Assets ✘ This folder is just for static content ✘ Note: No need to add “/assets” in URL
  • 21. Configuration ✘ Allows to configure: ✗ Environments ✗ Locales ✗ Blueprints – routing rules ✗ Connection strings ✗ Application bootstrap ✗ Sessions ✗ Sockets ✗ View engine ✗ Logging
  • 22. Views ✘ View is simple HTML page ✘ Multiple view engines are supported ✘ Default is EJB
  • 23. What about realtime? ✘ Based on socket.io ✘ By default notifies of any changes in any model ✘ Can notify of data requested ✘ Allows to write custom endpoints ✘ Does have scalability option by using redis as a pub/sub storage ✘ Has transport fallback (long polling or web sockets)
  • 24. Demo
  • 25. Sum Up ✘ Runs on any platform ✘ Front end agnostic ✘ DB agnostic ✘ Good for prototyping ✘ Speeds up implementation ✘ Does not require sails to be installed in production ✘ Provides fallback to express when needed
  • 26. Cons ✘ Is not as fast as Express could be ✘ Some adapters do not support native and effective DB capabilities ✘ In theory switching from one DB adapter to another go seamless in practice it’s a PAIN! ✘ Mixing DB can be an issue when you do have associations ✘ Does not suit well for complex data structures ✘ No transaction support