Extending Sails

In keeping with the Node philosophy, Sails aims to keep its core as small as possible, delegating all but the most critical functions to separate modules*. There are currently three types of extensions that you can make to Sails:

  • Generators - for adding and overriding functionality in the Sails CLI. Example: sails-generate-model, which allows you to create models on the command line with sails generate model foo.
  • Adapters - for integrating Waterline (Sails' ORM) with new data sources, including databases, APIs, or even hardware. Example: sails-postgresql, the official PostgreSQL adapter for Sails.
  • Hooks - for overriding or injecting new functionality in the Sails runtime. Example: sails-hook-autoreload, which adds auto-refreshing for a Sails project's API without having to manually restart the server.

If you’re interested in developing a “plugin” for Sails, you will most often want to make a hook.

* Some of the more important modules, like the Request hook, are still bundled with the Sails core, but they could technically be removed and installed separately.