Sails.js Essentials
()
About this ebook
Get up to speed with Sails.js development with this fast-paced tutorial
About This Book- Gain expertise in building web apps with Sails.js
- Develop apps such as real-time chat app and more in no time
- Helps you understand how MVC framework works in Node.js and how to make it work for you
This book is for web developers who want to build web apps with Sails.js.
Proficiency with JavaScript and Node.js is assumed, as well as familiarity with web development concepts. Familiarity with the MEAN (Mongo, Express, Angular, and Node) stack would be an added advantage.
What You Will Learn- Find out to quick-start Sails.js and develop production-ready apps
- Understand how to apply the MVC model of software development in Node.js using Sails.js
- Discover how to write quality code using Sails.js
- Integrate third-party APIs and databases such Mongo and MySQL in Sails.js
- Get to know the advantages and importance of the MVC framework in software development
Sails.js makes it easy to build custom, enterprise-grade Node.js apps. It is designed to emulate the familiar MVC pattern of frameworks, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture.
This book will provide practical examples to get you started with Sails.js and get you develop production-ready apps in no time. We will take you from a Node.js web server and single threading system to a general MVC architecture. You will then learn to develop applications that you might be already familiar with using Sails.js. Finally, we will show you how to create a chat app and a to-do application, and improve code quality using JSHINT and JSCS.
Style and approachThis practical and easy-to-follow yet comprehensive guide will help you get to grips with the Sails.js framework. Each topic is explained and placed in context, and for the more inquisitive, there are more details of the concepts used.
Read more from Shahid Shaikh
Mastering RethinkDB Rating: 0 out of 5 stars0 ratings
Related to Sails.js Essentials
Related ebooks
Blazor WebAssembly by Example: A project-based guide to building web apps with .NET, Blazor WebAssembly, and C# Rating: 0 out of 5 stars0 ratingsJasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsNoSQL Essentials: Navigating the World of Non-Relational Databases Rating: 0 out of 5 stars0 ratingsBeginning DotNetNuke Skinning and Design Rating: 0 out of 5 stars0 ratingsEmbedded Systems Architecture: Design and write software for embedded devices to build safe and connected systems Rating: 0 out of 5 stars0 ratingsASP.NET 3.5 CMS Development Rating: 0 out of 5 stars0 ratingsPractical C Programming: Solutions for modern C developers to create efficient and well-structured programs Rating: 0 out of 5 stars0 ratingsComputer Productivity Book 3. Use AutoHotKey to License & Deploy Your Scripts to Sell: AutoHotKey productivity, #3 Rating: 0 out of 5 stars0 ratingsResponsive Design High Performance Rating: 0 out of 5 stars0 ratingsJump Start Web Performance Rating: 0 out of 5 stars0 ratingsInstant Hands-on Testing with PHPUnit How-to Rating: 0 out of 5 stars0 ratingsDrupal Multimedia Rating: 4 out of 5 stars4/5Tools and Skills for .NET 8: Get the career you want with good practices and patterns to design, debug, and test your solutions Rating: 0 out of 5 stars0 ratingsLearn LLVM 12: A beginner's guide to learning LLVM compiler tools and core libraries with C++ Rating: 0 out of 5 stars0 ratingsHTML Application A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsLiving With Linux In the Industrial World Rating: 0 out of 5 stars0 ratingsGet Your Hands Dirty on Clean Architecture: Build 'clean' applications with code examples in Java Rating: 0 out of 5 stars0 ratingsThe Art of Modern PHP 8: Learn how to write modern, performant, and enterprise-ready code with the latest PHP features and practices Rating: 0 out of 5 stars0 ratingsSoftware Documentation Strategy A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsHello World: Student to Software Professional - a Transformation Guide Rating: 0 out of 5 stars0 ratingsRapid Application Development With CakePHP Rating: 0 out of 5 stars0 ratingsVideo Streaming Second Edition Rating: 0 out of 5 stars0 ratingsMining for Knowledge: Exploring GPU Architectures In Cryptocurrency and AI: The Crypto Mining Mastery Series Rating: 0 out of 5 stars0 ratingsMastering Java: A Comprehensive Guide to Programming Excellence Category Rating: 0 out of 5 stars0 ratingsBuilding Your Own JavaScript Framework: Architect extensible and reusable framework systems Rating: 0 out of 5 stars0 ratingsBare-Metal Embedded C Programming: Develop high-performance embedded systems with C for Arm microcontrollers Rating: 0 out of 5 stars0 ratingsPractical Java Programming with ChatGPT Rating: 0 out of 5 stars0 ratingsJump Start Sass: Get Up to Speed With Sass in a Weekend Rating: 0 out of 5 stars0 ratingsIoT Architecture A Complete Guide - 2019 Edition Rating: 0 out of 5 stars0 ratings
Programming For You
Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Python Data Structures and Algorithms Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsHTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 5 out of 5 stars5/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5JavaScript All-in-One For Dummies Rating: 5 out of 5 stars5/5HTML in 30 Pages Rating: 5 out of 5 stars5/5Narrative Design for Indies: Getting Started Rating: 4 out of 5 stars4/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5C All-in-One Desk Reference For Dummies Rating: 5 out of 5 stars5/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Coding with JavaScript For Dummies Rating: 0 out of 5 stars0 ratingsGrokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Beginning Programming with C++ For Dummies Rating: 4 out of 5 stars4/5C Programming For Beginners: The Simple Guide to Learning C Programming Language Fast! Rating: 5 out of 5 stars5/5Lua Game Development Cookbook Rating: 0 out of 5 stars0 ratings
Reviews for Sails.js Essentials
0 ratings0 reviews
Book preview
Sails.js Essentials - Shahid Shaikh
Table of Contents
Sails.js Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Revisiting Node.js Concepts
Node.js architecture
V8
Event driven I/O – libuv
Single-threaded system and its working
Working of libuv – core of Node.js
Multi-threading versus single-threading
Event loop and non-blocking I/O model
Importance of event loop
Working of event loop
Summary
2. Developing Node.js Web Server
Working of web servers
HTTP operations and their use
Create
Read
Update
Delete
Developing web server using HTTP module
HTTP headers and content-type
Developing web server using Express
Using Express to develop web server
Routers and middleware
Summary
3. Introduction to Sails.js and MVC Concepts
Getting started with MVC concepts
Model
View
Controller
Installing Sails.js
Understanding directory structure of Sails.js project
The assets directory
The views directory
The node_modules directory
The api directory
The config directory
Adding database support
Configuring MySQL database with Sails.js
config/connections.js
config/models.js
Configuring MongoDB database with Sails.js
config/connections.js
config/models.js
Configuring the Grunt task runner file with JSHint
Summary
4. Developing REST API Using Sails.js
Why it is called REST?
The REST CRUD operation
Database design for REST API
Building REST API in Sails.js
config/connections.js
config/models.js
Discussing migrate key
Running our code
Create new message
Read the message
Update the message
Delete the message
Defining custom controller
api/controllers/MessageController.js
Summary
5. Build a Chat System Using Sails.js
Application architecture and flow
Creating a Sails.js app
Sails.js API for chat
Model definition and MySQL integration in the app
Sails.js controller to handle the chat operation
AngularJS app for client-side interaction
Running the application
Summary
6. Building a Real-Time News Feed App Using Sails.js
Briefing Socket.IO
Using Socket in Sails.js
Discussing the database design of the app
Implementing the application
Summary
7. Creating a TODO Single-Page Application
MongoDB support in Sails.js
Defining model for API
TODO app view design
/assets/js/app.js
/assets/js/services/ToDoService.js
Summary
8. Sails.js Production Checklist
Sails.js migrate in detail
Sails.js security checklist
CSRF
CORS
DDOS
XSS
Sails.js deployment checklist
Configure production environment setting
Run app on port 80 if there is no proxy
Configure database settings
Estimate the traffic from all the endpoints
Sails.js hosting
Summary
Index
Sails.js Essentials
Sails.js Essentials
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2016
Production reference: 1190216
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78355-453-9
www.packtpub.com
Credits
Author
Shaikh Shahid
Reviewer
Diogo Resende
Commissioning Editor
Kartikey Pandey
Acquisition Editor
Sonali Vernekar
Content Development Editor
Siddhesh Salvi
Technical Editor
Manthan Raja
Copy Editor
Vibha Shukla
Project Coordinator
Nidhi Joshi
Proofreader
Safis Editing
Indexer
Monica Ajmera Mehta
Graphics
Jason Monteiro
Kirk D'Penha
Production Coordinator
Conidon Miranda
Cover Work
Conidon Miranda
About the Author
Shaikh Shahid has been a product developer for over two years. He has the experience of working on Node.js for more than two years. He loves to spread the word about Node.js and its various packages via his programming blog. Shahid is also very interested in software architecture and design and loves to develop software system from the core.
When he is not playing with Node.js or helping people, he watches movies, reads books, or travels to Goa.
I'd like to thank my father, who was not aware of my experiments with Node.js and similar things during my college days, and supported me at every step. I'd also like to thank Ashutosh sir and Jane for giving me an opportunity to work professionally on this awesome technology.
About the Reviewer
Diogo Resende is a passionate developer, obsessed with perfection in everything he works on. He loves everything about the Internet of Things: the ability to connect everything together and always being connected to the world. He is also the author of Node.js High Performance, Packt Publishing.
Diogo Resende studied computer science and graduated in engineering, which deepened his knowledge about computer networking and security, software development, and cloud computing. In the past 10 years, he has embraced different challenges to develop applications and services to connect people with embedded devices around the world, creating a bridge between the ancient and uncommon protocols and