SlideShare a Scribd company logo
LIKE RUBY ON RAILS FOR NODE:
THE SAILS JS
FRAMEWORK
By Stenio Ferreira
: @stenio123
: /stenio123
stenio@impacta.us
Stenio Ferreira - www.impacta.us - May 2015
WHAT IS SAILS JS?
BLUEPRINTS
… and lodash, bluebird, etc
Stenio Ferreira - www.impacta.us - May 2015
SHOULD YOU CARE?
Benefits
• Turnkey development environment
• Project standardization
• Flexibility
Stenio Ferreira - www.impacta.us - May 2015
SAILS JS IN THE NODE WORLD
abstraction
Koa Hapi RestifyExpress
Sails
Js templating engines
Generators (Yeoman)
Node js
Loopback Meteor
Ember Angular
Stenio Ferreira - www.impacta.us - May 2015
HOW SAIL CAN BE USED
or
API Server
API Server
+
Client
Stenio Ferreira - www.impacta.us - May 2015
API SERVER
JSON
Stenio Ferreira - www.impacta.us - May 2015
API SERVER
> npm install sails
> sails new myproject
> sails generate api user
> sails lift
http://localhost:1337
/user
/create?
name=Stenio
&surname=Ferreira
Stenio Ferreira - www.impacta.us - May 2015
API + CLIENT
JSON
Stenio Ferreira - www.impacta.us - May 2015
API + CLIENT
Javascript templating engine support:
ejs, jade, handlebars, mustache underscore, hogan, haml, haml-coffee,
dust atpl, eco, ect, jazz, jqtpl, JUST, liquor, QEJS, swig, templayed,
toffee, walrus, & whiskers
Stenio Ferreira - www.impacta.us - May 2015
DATABASE
ORM
(Object Relational Mapping)
… and others
adapters
Stenio Ferreira - www.impacta.us - May 2015
WEBSOCKET
Automatic starts listening on
> sails lift
register: Model.watch(req.socket.id);
publish: Model.publishCreate({});
subscribe: io.socket.get(“/model”);
listen: io.socket.on(“model”, function(event){});
Client (on the view)
Server (on the controller)
Stenio Ferreira - www.impacta.us - May 2015
ROUTES
No need to declare if following naming conventions. Three types:
RESTful
GET, POST, PUT, DELETE to /user
CRUD Shortcuts
/user/create?name=joe
/user/update:1?name=Joe
Action routes
methods declared in controller
BLUEPRINTS
Stenio Ferreira - www.impacta.us - May 2015
MISCELANEOUS
Policies
Runs after route, before controller
Grunt
Automate tasks
Stenio Ferreira - www.impacta.us - May 2015
ANGULAR/ EMBER
or
BUT!
Make sure added complexity really necessary.
Jquery + socket.io?
RivetsJS + Backbone?
JSON
Stenio Ferreira - www.impacta.us - May 2015
CHALLENGES WITH SAILS
• Modular? Waterline
• User management?
• Grunt magic?
• Deployment?
• Outdated info? (official docs
current!)
Stenio Ferreira - www.impacta.us - May 2015
FUTURE OF SAILS
(BUSINESS)
As of Dec 2014, received $120k Seed from Y
Combinator.
Stenio Ferreira - www.impacta.us - May 2015
BEFORE I GO…
Impacta
Small businesses have lots of internal processes.
More than a few of those are inefficient.
Do you believe you can help fix that?
For more info – www.impacta.us/jobs
Stenio Ferreira - www.impacta.us - May 2015
THANK YOU!
www.impacta.us/jobs
Stenio@impacta.us
Questions?
Stenio Ferreira - www.impacta.us - May 2015
APPENDIX
Stenio Ferreira - www.impacta.us - May 2015
USER MANAGEMENT
No Ruby on Rails Devise equivalent – Passport only works for
authentication, not authorization (and password reset). Potential
solutions:
Sails-auth – npm library to provide authorization
Waterlock – npm library to provide authorization
Sails starter app – github repository with code for password reset
Stormpath.com – SaaS for user management in Node apps
Stenio Ferreira - www.impacta.us - May 2015
FOLDER STRUCTURE
Folder structure
Api
• Controllers
• Models
• Policies
• Responses
• Services
Assets
• ..
• Styles
• Importer.less
• Js
• Dependencies
Config
• …
• Connections.js
• Routes.js
• Session.js
• Sockets.js
• Views.js
Tasks
• Pipeline.js
Views
• …
• Layout.ejs
CLIENT
CLIENT
SERVER
SERVER
+ VIEW
Stenio Ferreira - www.impacta.us - May 2015
WATERLINE
Model hooks -
- beforeValidate(), afterValidate(), beforeCreate(), afterCreate()
https://github.com/balderdashy/waterline-docs/blob/master/models.md#lifecycle-
callbacks
Associations – to populate,
Post.findOne(id).populate(‘user’)
.then(function(populatedPost) {
//work with result
}).catch(function(err) {
//error handling
});
https://github.com/balderdashy/waterline-docs/blob/master/associations.md
Stenio Ferreira - www.impacta.us - May 2015
EJS ON SAILS
Server and client inside same project
... previous steps,
manually create views/user/index.ejs,
add ‘index’ method to UserController,
> sails lift
Server + client
JSON
http://localhost:1337/user/
<%- body %>
<head>
<scripts>
<%= user.name %>
Stenio Ferreira - www.impacta.us - May 2015
1) To change template engine
config/views.js
2) To use view-specifc layout
on controller:
res.view({layout: ‘myLayout’});
3) Javascript loading order:
assets/js/dependencies (alphabetically)
assets/js (alphabetically)
4) To load view-specific javascript
use ejs-locals (already installed)
on layout.ejs: <%- blocks.localScripts %>
on view:
<% block('localScripts', '<script src=”/myScript.js”></script>’) %>
VIEW CONSIDERATIONS
Stenio Ferreira - www.impacta.us - May 2015
CONTROLLERS ON SAILS
req and res objects – same as Express
Controllers are usually written as
//UserController.js
module.exports = {
index: function(req, res) {
var user = req.session.User
res.json({name:user.name})
}
}
*newbie tip – watch out for asynchronous methods before
returning response!
Stenio Ferreira - www.impacta.us - May 2015
SOCKET IO
Check example project at
https://github.com/stenio123/sails-socket-example
Sails documentation reference:
http://sailsjs.org/#!/documentation/reference/websockets/resource
ful-pubsub
To perform actions before socket connects, or
once it disconnects:
Config/sockets.js
Stenio Ferreira - www.impacta.us - May 2015
CONFIG OPTIONS
Config/
Check the config folder for lots of interesting
options:
Config/session.js : can specify db to store session
Config/csrf.js: specify cross-site request forgery protection
settings
Config/policies.js: specify policies to be applied to certain routes
Config/env: specify environment variables (dev, prod)
Config/local.js: configurations of local machine
Config/blueprints.js: set pluralize to true if working with Ember
Stenio Ferreira - www.impacta.us - May 2015
EXTRA
Testing
Sails supports Mocha and istanbul
Reference:
http://sailsjs.org/#!/documentation/concepts/Testing
Sails Support:
Basic questions: Stackoverflow
Advanced Questions: Gitter (https://gitter.im/balderdashy/sails)

More Related Content

Viewers also liked

Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce
謝 宗穎
 
MVC way to introduce Sails.js - node.js framework
MVC way to introduce Sails.js - node.js frameworkMVC way to introduce Sails.js - node.js framework
MVC way to introduce Sails.js - node.js framework
Caesar Chi
 
Hashicorp @ JUST EAT - Part 2
Hashicorp @ JUST EAT - Part 2Hashicorp @ JUST EAT - Part 2
Hashicorp @ JUST EAT - Part 2
Andrew Brown
 
Symfony und Ember.js auf einer Seite #codetalks14
Symfony und Ember.js auf einer Seite #codetalks14Symfony und Ember.js auf einer Seite #codetalks14
Symfony und Ember.js auf einer Seite #codetalks14
Paul Seiffert
 
Using Vault to decouple MySQL Secrets
Using Vault to decouple MySQL SecretsUsing Vault to decouple MySQL Secrets
Using Vault to decouple MySQL Secrets
Derek Downey
 
[Js hcm] Deploying node.js with Forever.js and nginx
[Js hcm] Deploying node.js with Forever.js and nginx[Js hcm] Deploying node.js with Forever.js and nginx
[Js hcm] Deploying node.js with Forever.js and nginx
Nicolas Embleton
 
Dynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency PlanningDynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency Planning
Sean Chittenden
 
Vault - Secret and Key Management
Vault - Secret and Key ManagementVault - Secret and Key Management
Vault - Secret and Key Management
Anthony Ikeda
 
HashiCorp's Vault - The Examples
HashiCorp's Vault - The ExamplesHashiCorp's Vault - The Examples
HashiCorp's Vault - The Examples
Michał Czeraszkiewicz
 
Using ansible vault to protect your secrets
Using ansible vault to protect your secretsUsing ansible vault to protect your secrets
Using ansible vault to protect your secrets
Excella
 
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
Chickens & Eggs: Managing secrets in AWS with Hashicorp VaultChickens & Eggs: Managing secrets in AWS with Hashicorp Vault
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
Jeff Horwitz
 

Viewers also liked (11)

Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce
 
MVC way to introduce Sails.js - node.js framework
MVC way to introduce Sails.js - node.js frameworkMVC way to introduce Sails.js - node.js framework
MVC way to introduce Sails.js - node.js framework
 
Hashicorp @ JUST EAT - Part 2
Hashicorp @ JUST EAT - Part 2Hashicorp @ JUST EAT - Part 2
Hashicorp @ JUST EAT - Part 2
 
Symfony und Ember.js auf einer Seite #codetalks14
Symfony und Ember.js auf einer Seite #codetalks14Symfony und Ember.js auf einer Seite #codetalks14
Symfony und Ember.js auf einer Seite #codetalks14
 
Using Vault to decouple MySQL Secrets
Using Vault to decouple MySQL SecretsUsing Vault to decouple MySQL Secrets
Using Vault to decouple MySQL Secrets
 
[Js hcm] Deploying node.js with Forever.js and nginx
[Js hcm] Deploying node.js with Forever.js and nginx[Js hcm] Deploying node.js with Forever.js and nginx
[Js hcm] Deploying node.js with Forever.js and nginx
 
Dynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency PlanningDynamic Database Credentials: Security Contingency Planning
Dynamic Database Credentials: Security Contingency Planning
 
Vault - Secret and Key Management
Vault - Secret and Key ManagementVault - Secret and Key Management
Vault - Secret and Key Management
 
HashiCorp's Vault - The Examples
HashiCorp's Vault - The ExamplesHashiCorp's Vault - The Examples
HashiCorp's Vault - The Examples
 
Using ansible vault to protect your secrets
Using ansible vault to protect your secretsUsing ansible vault to protect your secrets
Using ansible vault to protect your secrets
 
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
Chickens & Eggs: Managing secrets in AWS with Hashicorp VaultChickens & Eggs: Managing secrets in AWS with Hashicorp Vault
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
 

Similar to Like Ruby on Rails for Node - the Sails js framework

Summer '15 Release Preview: Platform Feature Highlights
Summer '15 Release Preview: Platform Feature Highlights Summer '15 Release Preview: Platform Feature Highlights
Summer '15 Release Preview: Platform Feature Highlights
Salesforce Developers
 
Tulsa techfest awesomelysimplesharepointsolutions
Tulsa techfest awesomelysimplesharepointsolutionsTulsa techfest awesomelysimplesharepointsolutions
Tulsa techfest awesomelysimplesharepointsolutions
April Dunnam
 
Sst hackathon express
Sst hackathon expressSst hackathon express
Sst hackathon express
Aeshan Wijetunge
 
Pwa, separating the features from the solutions
Pwa, separating the features from the solutions Pwa, separating the features from the solutions
Pwa, separating the features from the solutions
Sander Mangel
 
Tulsa techfest awesomelysimplesharepointsolutions
Tulsa techfest awesomelysimplesharepointsolutionsTulsa techfest awesomelysimplesharepointsolutions
Tulsa techfest awesomelysimplesharepointsolutions
April Dunnam
 
AngularJS App In Two Weeks
AngularJS App In Two WeeksAngularJS App In Two Weeks
AngularJS App In Two Weeks
Peter Chittum
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
IT Event
 
International Search Summit 2013 - International Magento SEO
International Search Summit 2013 - International Magento SEOInternational Search Summit 2013 - International Magento SEO
International Search Summit 2013 - International Magento SEO
Steve Lock
 
Knockout in SharePoint: A Real-World Example of Components and Datatables
Knockout in SharePoint: A Real-World Example of Components and DatatablesKnockout in SharePoint: A Real-World Example of Components and Datatables
Knockout in SharePoint: A Real-World Example of Components and Datatables
Sam Larko
 
URL Funnel Optimisation: How to get budget for SEO - Michal Magdziarz, CEO, D...
URL Funnel Optimisation: How to get budget for SEO - Michal Magdziarz, CEO, D...URL Funnel Optimisation: How to get budget for SEO - Michal Magdziarz, CEO, D...
URL Funnel Optimisation: How to get budget for SEO - Michal Magdziarz, CEO, D...
DeepCrawl
 
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces..."Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
hamidsamadi
 
4-identifying-problems.pdf
4-identifying-problems.pdf4-identifying-problems.pdf
4-identifying-problems.pdf
Brian Rahmawan Purwoto
 
Visual AI Testing Using Applitools
Visual AI Testing Using ApplitoolsVisual AI Testing Using Applitools
Visual AI Testing Using Applitools
Mikhail Laptev
 
Wordpress development 101
Wordpress development 101Wordpress development 101
Wordpress development 101
Commit Software Sh.p.k.
 
JavaScript Integration with Visualforce
JavaScript Integration with VisualforceJavaScript Integration with Visualforce
JavaScript Integration with Visualforce
Salesforce Developers
 
Technical Introduction to YDN
Technical Introduction to YDNTechnical Introduction to YDN
Technical Introduction to YDN
Christian Heilmann
 
JS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJSJS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJS
Yuriy Silvestrov
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and Beyond
Matt Stine
 
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for MobileVisualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Salesforce Developers
 
What’s new in VS 2015 and ALM 2015
What’s new in VS 2015 and ALM 2015What’s new in VS 2015 and ALM 2015
What’s new in VS 2015 and ALM 2015
SSW
 

Similar to Like Ruby on Rails for Node - the Sails js framework (20)

Summer '15 Release Preview: Platform Feature Highlights
Summer '15 Release Preview: Platform Feature Highlights Summer '15 Release Preview: Platform Feature Highlights
Summer '15 Release Preview: Platform Feature Highlights
 
Tulsa techfest awesomelysimplesharepointsolutions
Tulsa techfest awesomelysimplesharepointsolutionsTulsa techfest awesomelysimplesharepointsolutions
Tulsa techfest awesomelysimplesharepointsolutions
 
Sst hackathon express
Sst hackathon expressSst hackathon express
Sst hackathon express
 
Pwa, separating the features from the solutions
Pwa, separating the features from the solutions Pwa, separating the features from the solutions
Pwa, separating the features from the solutions
 
Tulsa techfest awesomelysimplesharepointsolutions
Tulsa techfest awesomelysimplesharepointsolutionsTulsa techfest awesomelysimplesharepointsolutions
Tulsa techfest awesomelysimplesharepointsolutions
 
AngularJS App In Two Weeks
AngularJS App In Two WeeksAngularJS App In Two Weeks
AngularJS App In Two Weeks
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
 
International Search Summit 2013 - International Magento SEO
International Search Summit 2013 - International Magento SEOInternational Search Summit 2013 - International Magento SEO
International Search Summit 2013 - International Magento SEO
 
Knockout in SharePoint: A Real-World Example of Components and Datatables
Knockout in SharePoint: A Real-World Example of Components and DatatablesKnockout in SharePoint: A Real-World Example of Components and Datatables
Knockout in SharePoint: A Real-World Example of Components and Datatables
 
URL Funnel Optimisation: How to get budget for SEO - Michal Magdziarz, CEO, D...
URL Funnel Optimisation: How to get budget for SEO - Michal Magdziarz, CEO, D...URL Funnel Optimisation: How to get budget for SEO - Michal Magdziarz, CEO, D...
URL Funnel Optimisation: How to get budget for SEO - Michal Magdziarz, CEO, D...
 
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces..."Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
 
4-identifying-problems.pdf
4-identifying-problems.pdf4-identifying-problems.pdf
4-identifying-problems.pdf
 
Visual AI Testing Using Applitools
Visual AI Testing Using ApplitoolsVisual AI Testing Using Applitools
Visual AI Testing Using Applitools
 
Wordpress development 101
Wordpress development 101Wordpress development 101
Wordpress development 101
 
JavaScript Integration with Visualforce
JavaScript Integration with VisualforceJavaScript Integration with Visualforce
JavaScript Integration with Visualforce
 
Technical Introduction to YDN
Technical Introduction to YDNTechnical Introduction to YDN
Technical Introduction to YDN
 
JS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJSJS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJS
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and Beyond
 
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for MobileVisualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
 
What’s new in VS 2015 and ALM 2015
What’s new in VS 2015 and ALM 2015What’s new in VS 2015 and ALM 2015
What’s new in VS 2015 and ALM 2015
 

More from Stenio Ferreira

Lgpd webinar hashitalks brasil 2020
Lgpd webinar   hashitalks brasil 2020Lgpd webinar   hashitalks brasil 2020
Lgpd webinar hashitalks brasil 2020
Stenio Ferreira
 
HashiTalks 2020 Latin America Nomad
HashiTalks 2020 Latin America NomadHashiTalks 2020 Latin America Nomad
HashiTalks 2020 Latin America Nomad
Stenio Ferreira
 
Vault Open Source vs Enterprise v2
Vault Open Source vs Enterprise v2Vault Open Source vs Enterprise v2
Vault Open Source vs Enterprise v2
Stenio Ferreira
 
Hashicorp Webinar - Vault Cloud Security - Spanish
Hashicorp Webinar - Vault Cloud Security - SpanishHashicorp Webinar - Vault Cloud Security - Spanish
Hashicorp Webinar - Vault Cloud Security - Spanish
Stenio Ferreira
 
Hashicorp Webinar - Vault Cloud Security - Portuguese
Hashicorp Webinar - Vault Cloud Security - PortugueseHashicorp Webinar - Vault Cloud Security - Portuguese
Hashicorp Webinar - Vault Cloud Security - Portuguese
Stenio Ferreira
 
Hashicorp corporate pitch deck Spanish
Hashicorp corporate pitch deck SpanishHashicorp corporate pitch deck Spanish
Hashicorp corporate pitch deck Spanish
Stenio Ferreira
 
Vault Digital Transformation
Vault Digital TransformationVault Digital Transformation
Vault Digital Transformation
Stenio Ferreira
 
Demystifying Terraform 012
Demystifying Terraform 012Demystifying Terraform 012
Demystifying Terraform 012
Stenio Ferreira
 
Hashicorp Corporate Pitch Deck Stenio_v2
Hashicorp Corporate Pitch Deck Stenio_v2 Hashicorp Corporate Pitch Deck Stenio_v2
Hashicorp Corporate Pitch Deck Stenio_v2
Stenio Ferreira
 
Hashicorp Terraform Open Source vs Enterprise
Hashicorp Terraform Open Source vs EnterpriseHashicorp Terraform Open Source vs Enterprise
Hashicorp Terraform Open Source vs Enterprise
Stenio Ferreira
 
Hashicorp Vault Open Source vs Enterprise
Hashicorp Vault Open Source vs EnterpriseHashicorp Vault Open Source vs Enterprise
Hashicorp Vault Open Source vs Enterprise
Stenio Ferreira
 
Hashicorp Corporate and Product Overview
Hashicorp Corporate and Product OverviewHashicorp Corporate and Product Overview
Hashicorp Corporate and Product Overview
Stenio Ferreira
 
Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...
Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...
Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...
Stenio Ferreira
 
Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...
Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...
Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...
Stenio Ferreira
 
Chicago Hashicorp User Group - Terraform Public Module Registry
Chicago Hashicorp User Group - Terraform Public Module RegistryChicago Hashicorp User Group - Terraform Public Module Registry
Chicago Hashicorp User Group - Terraform Public Module Registry
Stenio Ferreira
 
Slalom: Introduction to Containers and AWS ECS
Slalom: Introduction to Containers and AWS ECSSlalom: Introduction to Containers and AWS ECS
Slalom: Introduction to Containers and AWS ECS
Stenio Ferreira
 
Networking 101 AWS - VPCs, Subnets, NAT Gateways, etc
Networking 101 AWS - VPCs, Subnets, NAT Gateways, etcNetworking 101 AWS - VPCs, Subnets, NAT Gateways, etc
Networking 101 AWS - VPCs, Subnets, NAT Gateways, etc
Stenio Ferreira
 
Secret Management Architectures
Secret Management Architectures Secret Management Architectures
Secret Management Architectures
Stenio Ferreira
 
Sales and Marketing in Small Company Environment
Sales and Marketing in Small Company EnvironmentSales and Marketing in Small Company Environment
Sales and Marketing in Small Company Environment
Stenio Ferreira
 

More from Stenio Ferreira (19)

Lgpd webinar hashitalks brasil 2020
Lgpd webinar   hashitalks brasil 2020Lgpd webinar   hashitalks brasil 2020
Lgpd webinar hashitalks brasil 2020
 
HashiTalks 2020 Latin America Nomad
HashiTalks 2020 Latin America NomadHashiTalks 2020 Latin America Nomad
HashiTalks 2020 Latin America Nomad
 
Vault Open Source vs Enterprise v2
Vault Open Source vs Enterprise v2Vault Open Source vs Enterprise v2
Vault Open Source vs Enterprise v2
 
Hashicorp Webinar - Vault Cloud Security - Spanish
Hashicorp Webinar - Vault Cloud Security - SpanishHashicorp Webinar - Vault Cloud Security - Spanish
Hashicorp Webinar - Vault Cloud Security - Spanish
 
Hashicorp Webinar - Vault Cloud Security - Portuguese
Hashicorp Webinar - Vault Cloud Security - PortugueseHashicorp Webinar - Vault Cloud Security - Portuguese
Hashicorp Webinar - Vault Cloud Security - Portuguese
 
Hashicorp corporate pitch deck Spanish
Hashicorp corporate pitch deck SpanishHashicorp corporate pitch deck Spanish
Hashicorp corporate pitch deck Spanish
 
Vault Digital Transformation
Vault Digital TransformationVault Digital Transformation
Vault Digital Transformation
 
Demystifying Terraform 012
Demystifying Terraform 012Demystifying Terraform 012
Demystifying Terraform 012
 
Hashicorp Corporate Pitch Deck Stenio_v2
Hashicorp Corporate Pitch Deck Stenio_v2 Hashicorp Corporate Pitch Deck Stenio_v2
Hashicorp Corporate Pitch Deck Stenio_v2
 
Hashicorp Terraform Open Source vs Enterprise
Hashicorp Terraform Open Source vs EnterpriseHashicorp Terraform Open Source vs Enterprise
Hashicorp Terraform Open Source vs Enterprise
 
Hashicorp Vault Open Source vs Enterprise
Hashicorp Vault Open Source vs EnterpriseHashicorp Vault Open Source vs Enterprise
Hashicorp Vault Open Source vs Enterprise
 
Hashicorp Corporate and Product Overview
Hashicorp Corporate and Product OverviewHashicorp Corporate and Product Overview
Hashicorp Corporate and Product Overview
 
Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...
Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...
Hashicorp Chicago HUG - Secure and Automated Workflows in Azure with Vault an...
 
Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...
Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...
Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...
 
Chicago Hashicorp User Group - Terraform Public Module Registry
Chicago Hashicorp User Group - Terraform Public Module RegistryChicago Hashicorp User Group - Terraform Public Module Registry
Chicago Hashicorp User Group - Terraform Public Module Registry
 
Slalom: Introduction to Containers and AWS ECS
Slalom: Introduction to Containers and AWS ECSSlalom: Introduction to Containers and AWS ECS
Slalom: Introduction to Containers and AWS ECS
 
Networking 101 AWS - VPCs, Subnets, NAT Gateways, etc
Networking 101 AWS - VPCs, Subnets, NAT Gateways, etcNetworking 101 AWS - VPCs, Subnets, NAT Gateways, etc
Networking 101 AWS - VPCs, Subnets, NAT Gateways, etc
 
Secret Management Architectures
Secret Management Architectures Secret Management Architectures
Secret Management Architectures
 
Sales and Marketing in Small Company Environment
Sales and Marketing in Small Company EnvironmentSales and Marketing in Small Company Environment
Sales and Marketing in Small Company Environment
 

Recently uploaded

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

Like Ruby on Rails for Node - the Sails js framework

  • 1. LIKE RUBY ON RAILS FOR NODE: THE SAILS JS FRAMEWORK By Stenio Ferreira : @stenio123 : /stenio123 stenio@impacta.us
  • 2. Stenio Ferreira - www.impacta.us - May 2015 WHAT IS SAILS JS? BLUEPRINTS … and lodash, bluebird, etc
  • 3. Stenio Ferreira - www.impacta.us - May 2015 SHOULD YOU CARE? Benefits • Turnkey development environment • Project standardization • Flexibility
  • 4. Stenio Ferreira - www.impacta.us - May 2015 SAILS JS IN THE NODE WORLD abstraction Koa Hapi RestifyExpress Sails Js templating engines Generators (Yeoman) Node js Loopback Meteor Ember Angular
  • 5. Stenio Ferreira - www.impacta.us - May 2015 HOW SAIL CAN BE USED or API Server API Server + Client
  • 6. Stenio Ferreira - www.impacta.us - May 2015 API SERVER JSON
  • 7. Stenio Ferreira - www.impacta.us - May 2015 API SERVER > npm install sails > sails new myproject > sails generate api user > sails lift http://localhost:1337 /user /create? name=Stenio &surname=Ferreira
  • 8. Stenio Ferreira - www.impacta.us - May 2015 API + CLIENT JSON
  • 9. Stenio Ferreira - www.impacta.us - May 2015 API + CLIENT Javascript templating engine support: ejs, jade, handlebars, mustache underscore, hogan, haml, haml-coffee, dust atpl, eco, ect, jazz, jqtpl, JUST, liquor, QEJS, swig, templayed, toffee, walrus, & whiskers
  • 10. Stenio Ferreira - www.impacta.us - May 2015 DATABASE ORM (Object Relational Mapping) … and others adapters
  • 11. Stenio Ferreira - www.impacta.us - May 2015 WEBSOCKET Automatic starts listening on > sails lift register: Model.watch(req.socket.id); publish: Model.publishCreate({}); subscribe: io.socket.get(“/model”); listen: io.socket.on(“model”, function(event){}); Client (on the view) Server (on the controller)
  • 12. Stenio Ferreira - www.impacta.us - May 2015 ROUTES No need to declare if following naming conventions. Three types: RESTful GET, POST, PUT, DELETE to /user CRUD Shortcuts /user/create?name=joe /user/update:1?name=Joe Action routes methods declared in controller BLUEPRINTS
  • 13. Stenio Ferreira - www.impacta.us - May 2015 MISCELANEOUS Policies Runs after route, before controller Grunt Automate tasks
  • 14. Stenio Ferreira - www.impacta.us - May 2015 ANGULAR/ EMBER or BUT! Make sure added complexity really necessary. Jquery + socket.io? RivetsJS + Backbone? JSON
  • 15. Stenio Ferreira - www.impacta.us - May 2015 CHALLENGES WITH SAILS • Modular? Waterline • User management? • Grunt magic? • Deployment? • Outdated info? (official docs current!)
  • 16. Stenio Ferreira - www.impacta.us - May 2015 FUTURE OF SAILS (BUSINESS) As of Dec 2014, received $120k Seed from Y Combinator.
  • 17. Stenio Ferreira - www.impacta.us - May 2015 BEFORE I GO… Impacta Small businesses have lots of internal processes. More than a few of those are inefficient. Do you believe you can help fix that? For more info – www.impacta.us/jobs
  • 18. Stenio Ferreira - www.impacta.us - May 2015 THANK YOU! www.impacta.us/jobs Stenio@impacta.us Questions?
  • 19. Stenio Ferreira - www.impacta.us - May 2015 APPENDIX
  • 20. Stenio Ferreira - www.impacta.us - May 2015 USER MANAGEMENT No Ruby on Rails Devise equivalent – Passport only works for authentication, not authorization (and password reset). Potential solutions: Sails-auth – npm library to provide authorization Waterlock – npm library to provide authorization Sails starter app – github repository with code for password reset Stormpath.com – SaaS for user management in Node apps
  • 21. Stenio Ferreira - www.impacta.us - May 2015 FOLDER STRUCTURE Folder structure Api • Controllers • Models • Policies • Responses • Services Assets • .. • Styles • Importer.less • Js • Dependencies Config • … • Connections.js • Routes.js • Session.js • Sockets.js • Views.js Tasks • Pipeline.js Views • … • Layout.ejs CLIENT CLIENT SERVER SERVER + VIEW
  • 22. Stenio Ferreira - www.impacta.us - May 2015 WATERLINE Model hooks - - beforeValidate(), afterValidate(), beforeCreate(), afterCreate() https://github.com/balderdashy/waterline-docs/blob/master/models.md#lifecycle- callbacks Associations – to populate, Post.findOne(id).populate(‘user’) .then(function(populatedPost) { //work with result }).catch(function(err) { //error handling }); https://github.com/balderdashy/waterline-docs/blob/master/associations.md
  • 23. Stenio Ferreira - www.impacta.us - May 2015 EJS ON SAILS Server and client inside same project ... previous steps, manually create views/user/index.ejs, add ‘index’ method to UserController, > sails lift Server + client JSON http://localhost:1337/user/ <%- body %> <head> <scripts> <%= user.name %>
  • 24. Stenio Ferreira - www.impacta.us - May 2015 1) To change template engine config/views.js 2) To use view-specifc layout on controller: res.view({layout: ‘myLayout’}); 3) Javascript loading order: assets/js/dependencies (alphabetically) assets/js (alphabetically) 4) To load view-specific javascript use ejs-locals (already installed) on layout.ejs: <%- blocks.localScripts %> on view: <% block('localScripts', '<script src=”/myScript.js”></script>’) %> VIEW CONSIDERATIONS
  • 25. Stenio Ferreira - www.impacta.us - May 2015 CONTROLLERS ON SAILS req and res objects – same as Express Controllers are usually written as //UserController.js module.exports = { index: function(req, res) { var user = req.session.User res.json({name:user.name}) } } *newbie tip – watch out for asynchronous methods before returning response!
  • 26. Stenio Ferreira - www.impacta.us - May 2015 SOCKET IO Check example project at https://github.com/stenio123/sails-socket-example Sails documentation reference: http://sailsjs.org/#!/documentation/reference/websockets/resource ful-pubsub To perform actions before socket connects, or once it disconnects: Config/sockets.js
  • 27. Stenio Ferreira - www.impacta.us - May 2015 CONFIG OPTIONS Config/ Check the config folder for lots of interesting options: Config/session.js : can specify db to store session Config/csrf.js: specify cross-site request forgery protection settings Config/policies.js: specify policies to be applied to certain routes Config/env: specify environment variables (dev, prod) Config/local.js: configurations of local machine Config/blueprints.js: set pluralize to true if working with Ember
  • 28. Stenio Ferreira - www.impacta.us - May 2015 EXTRA Testing Sails supports Mocha and istanbul Reference: http://sailsjs.org/#!/documentation/concepts/Testing Sails Support: Basic questions: Stackoverflow Advanced Questions: Gitter (https://gitter.im/balderdashy/sails)