You are previewing Sails.js Essentials.
O'Reilly logo
Sails.js Essentials

Book Description

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

  • Who This Book Is For

    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

  • In Detail

    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 approach

    This 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.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Sails.js Essentials
      1. Table of Contents
      2. Sails.js Essentials
      3. Credits
      4. About the Author
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Revisiting Node.js Concepts
        1. Node.js architecture
          1. V8
          2. Event driven I/O – libuv
        2. Single-threaded system and its working
          1. Working of libuv – core of Node.js
          2. Multi-threading versus single-threading
        3. Event loop and non-blocking I/O model
          1. Importance of event loop
          2. Working of event loop
        4. Summary
      9. 2. Developing Node.js Web Server
        1. Working of web servers
        2. HTTP operations and their use
          1. Create
          2. Read
          3. Update
          4. Delete
        3. Developing web server using HTTP module
        4. HTTP headers and content-type
        5. Developing web server using Express
          1. Using Express to develop web server
          2. Routers and middleware
        6. Summary
      10. 3. Introduction to Sails.js and MVC Concepts
        1. Getting started with MVC concepts
          1. Model
          2. View
          3. Controller
        2. Installing Sails.js
        3. Understanding directory structure of Sails.js project
          1. The assets directory
          2. The views directory
          3. The node_modules directory
          4. The api directory
          5. The config directory
        4. Adding database support
          1. Configuring MySQL database with Sails.js
            1. config/connections.js
            2. config/models.js
          2. Configuring MongoDB database with Sails.js
            1. config/connections.js
            2. config/models.js
        5. Configuring the Grunt task runner file with JSHint
        6. Summary
      11. 4. Developing REST API Using Sails.js
        1. Why it is called REST?
        2. The REST CRUD operation
        3. Database design for REST API
        4. Building REST API in Sails.js
          1. config/connections.js
          2. config/models.js
          3. Discussing migrate key
          4. Running our code
            1. Create new message
            2. Read the message
            3. Update the message
            4. Delete the message
          5. Defining custom controller
            1. api/controllers/MessageController.js
        5. Summary
      12. 5. Build a Chat System Using Sails.js
        1. Application architecture and flow
        2. Creating a Sails.js app
        3. Sails.js API for chat
        4. Model definition and MySQL integration in the app
        5. Sails.js controller to handle the chat operation
        6. AngularJS app for client-side interaction
        7. Running the application
        8. Summary
      13. 6. Building a Real-Time News Feed App Using Sails.js
        1. Briefing Socket.IO
        2. Using Socket in Sails.js
        3. Discussing the database design of the app
        4. Implementing the application
        5. Summary
      14. 7. Creating a TODO Single-Page Application
        1. MongoDB support in Sails.js
        2. Defining model for API
        3. TODO app view design
          1. /assets/js/app.js
          2. /assets/js/services/ToDoService.js
        4. Summary
      15. 8. Sails.js Production Checklist
        1. Sails.js migrate in detail
        2. Sails.js security checklist
          1. CSRF
          2. CORS
          3. DDOS
          4. XSS
        3. Sails.js deployment checklist
          1. Configure production environment setting
          2. Run app on port 80 if there is no proxy
          3. Configure database settings
          4. Estimate the traffic from all the endpoints
        4. Sails.js hosting
        5. Summary
      16. Index