Edit Page

api/controllers/

This is the directory that holds your controllers. In Sails, controllers are JavaScript files that contain logic for interacting with models and rendering appropriate views to the client.

When you call sails generate api cats via the command line from inside your project's root directory, Sails will generate the file api/controllers/CatsController.js along with a matching model.

The api/controllers directory can also contain standalone actions, which are JavaScript files containing a single controller action, rather than a dictionary of actions.

See the main actions and controllers documentation for more info.

Want to see for yourself?

An example of this directory can be found in our sample app repo, here.

Anatomy of a Sails App