Why you should use Sails today!

These features will help you decide whether to utilize Sails for your next project.

Before discussing those fantastic features, let's talk briefly about what Sails is.

What is Sails?

Built on Express, Sails is a lightweight and adaptable MVC (models, views, and controllers) framework. Once you get going, it feels like a plug-and-play system. Small modules that work together to provide simplicity, maintainability, and structural convention are provided in the framework.

A nodeJS MVC framework, to build a full-stack web app with JS. Similar to Laravel and Ruby. - Kelvin. O. Omereshone (Lead Maintainer of Sails)

In simple terms, a backend framework that is simplified for JavaScript developers.

The features mentioned here can be found in the docs.

Features of Sails

  • 100% JavaScript: Sails focuses a lot on developer satisfaction and happiness. It believes in the convention-over-configuration philosophy, and based on that fact, the app was written entirely in JS because Node.js takes that principle to a whole new level. This way, you do not have to bother about context-shifting and will be able to write code consistently, thereby improving productivity and having fun during development.

  • Any Database: Sails comes with an amazing ORM, called Waterline. I saw that firsthand when I made use of it. This ORM provides a simple data access layer that works with any database of your choice. It also comes with a local disk database for your development until you decide on the database you want to use for production. Find out more about the available adapters.

  • Powerful Associations: Sails takes an approach to make data modeling more practical. You can still carry out relations you know (one-to-many, many-to-many), but you can also have multiple named associations per model. Simply put, you can have different models for different databases and still like them together by making use of associations in Sails. Read more about associations.

  • Auto-generate REST APIs: Sails comes with blueprints that optimize your backend experience. You can see them as shortcuts to achieve what you want without writing any code. Just run sails generate api articles and you'll get an API that lets you search, paginate, sort, filter, create, destroy, update, and associate articles. You can try out blueprints.

  • Support WebSockets with no additional code: The request interpreter in Sails is able to translate incoming messages for you, and for more benefits, it is automatically compatible with every route in your Sails app. Your code will be able to work with WebSockets and HTTP without doing any extra work. Read more about the virtual request interpreter.

  • Declarative, Reusable security policies: Sails comes with simple, reusable middleware functions that run before your controllers and actions, called Policies. It provides basic security and role-based access control. Making use of policies will simplify your business logic and reduce the total amount of code that you need to write. They are also interchangeable (you can use npm modules like Passport), and they work automatically with both WebSockets and HTTP.

  • Front-end Agnostic: Sails is compatible with any front-end strategy; even the ones that have not been invented yet. Yeah, it's true. Additionally, it is simple to make the same API available for another web-based service or developer community to consume.

  • Flexible asset pipeline: Sails ships with Grunt (which means your entire front-end asset is completely customizable, and comes with support for all of the great Grunt modules), so if you are building an app for the browser, you are in luck. You are also able to compile your static assets and push them out to a CDN like CloudFront to make your app load even faster. If you prefer a different toolchain, learn about generators.

  • Rock-solid foundation: Sails is built on Node.js, and we all know how powerful it is. It also makes use of Express for handling HTTP requests and socket.io for managing WebSockets. This means you are able to access raw objects that belong to those modules listed. Another cool benefit is that migrating an existing Express app is a breeze because Express routes work perfectly well in a Sails app.

Conclusion

These are just a few of the things Sails has to offer, the more you use it, the more you find out. After listening to a talk by Mike McNeil, CEO, of Fleet. Creator & BDFL, Sails, and having an AMA session with the new Lead Maintainer of Sails, Kelvin. O. Omereshone, I see an exciting future for Sails with a lot of interesting features coming soon.

You can connect with me on Twitter. See you in the next article.