node.js web development using sails
DESCRIPTION
End-to-end JavaScript web applications? Thanks to Node.js, this has become a reality, with the added benefit of massive scalability. Despite approaching server-side web applications differently than traditional MVC platforms (like ASP .Net MVC), frameworks have emerged to bridge the knowledge to Node.js. Using one of these frameworks, Sails.js, we demonstrate how the tried and true MVC pattern is applied in Node.js. http://agilethought.comTRANSCRIPT
MEAN Sailing: Node.js Web Development Using Sails.jsPresented by Eric Nograles, Analytics Practice Champion/Senior Consultant
Why So MEAN?
• Designed with scalability in mind• Measured ~10,000 concurrent connections
on 3 small EC2 instances
• Unified front and back-end language: minimal context-switching
• Higher productivity
• Greater development velocity
• Happy developers and happy product owners
• JavaScript has grown up
Meet Node.js
• Server-side JavaScript (yes, JavaScript)
• Runs on Chrome’s V8 JavaScript Engine
• Single-threaded, non-blocking and event-driven
• Designed for the real-time web with push capability
• Web application framework: Express
• .Net = IIS
• Java = JBoss
Node on Sails!
• Just kidding, it’s just Sails
• MVC Framework built on Node.js and Express• .Net = ASP .Net MVC
• Java = Spring MVC
• Inspired by Ruby on Rails
• Prepackaged solution of libraries: ORM, Socket.io, template engine, data store adapters
• A natural fit with MongoDB
www.agilethought.com
It’s Literally This Simple to Start…1. npm install –g sails2. sails new [application name]3. cd [application name directory]4. sails lift
www.agilethought.com
A Simple, Pattern-based Structure
• /api: Developer magic happens here
• /assets: UI/UX wizardry
• /config: Get your Sails app to behave
• /views: More UI/UX wizardry
• App.js: Node.js debugging front-door
• Gruntfile.js: Build and task
automation
WebStorm View…
www.agilethought.com
Familiar Techniques
Separation of Concerns: Modular JS Patterns
Domain Models: Waterline ORM and POJSO’s
Dependency Injection: RequireJS
Unit Testing/Mocking: Mocha, Chai, Sinon, and Proxyquire
Build and Task Automation: Grunt
Dependency Management: NPM
www.agilethought.com
Know MVC? Know Sails!
Models ControllersBusiness Logic
www.agilethought.com
Pro-Tips for Learning Sails
Know jQuery? Awesome. Forget about it.
Focus on architectural patterns + practices (i.e. “How would this be done in
MVC?”)
Understand how asynchronous development and Promises work in
JavaScript.
Get to know JavaScript “quirks” and its OOP capabilities
Use WebStorm as an IDE to ease the learning curve (from .Net and Java)
www.agilethought.com
When to Sail?
Real-time Web Applications (Chat, “Live” Dashboards)
Server API for an Object DB (CRUD, Heavy I/O)
Queued Applications (Logging, “eventual consistency” solutions)
Quick Prototyping (for Server API’s, Proxies, etc.)
www.agilethought.com
Cloud Deployment Options
• Joyent: http://www.joyent.com/
• Amazon Web Services: http://aws.amazon.com/
• NodeJitsu: https://www.nodejitsu.com/
www.agilethought.com
Sample Sources
• GitHub: https://github.com/ericnograles/agilemoviedb
• NGBP: https://github.com/ngbp/ngbp
• StartBootstrap Stylish Portfolio: http://startbootstrap.com/stylish-portfolio
www.agilethought.com
Check Out Our Recorded Webinars
Recorded ALM Webinars: http://www.agilethought.com/library
• Webinar: 5 TFS Features That Will Dramatically Improve Your Team's Performance
• Webinar: 6 Steps To Achieving Predictable Release Management With Visual Studio 2013
• Webinar: How To Create High Value Development Teams
Upcoming Events: http://www.agilethought.com/events
www.agilethought.com
Eric Nograles is a Senior Consultant and Analytics Practice Champion at AgileThought. Having 15
years of leading and executing multi-platform enterprise development, he takes particular interest
in Business Intelligence, big data, and modern web frameworks (Node.js and AngularJS).
About Eric
Thank You!
@grales
Looking For Software Solutions For Your Business? Email me at [email protected] 15
linkedin.com/in/ericnograles