Edit Page
api/
This folder contains the vast majority of your app's back-end logic. It is home to the 'M' and 'C' in MVC Framework.
In it you will find the following:
- Controllers: Actions contain back-end logic that handle incoming requests (like handling a form submission or responding with personalized, server-rendered HTML).
- Helpers: Helpers are shared functions that can be called from anywhere in your app.
- Models: Models are the structures that contain data for your Sails App.
- Policies: Policies are middleware that restrict access to certain actions in your app.
You may also find these folders, which are not always generated by default in new Sails apps:
- Hooks: Hooks are modules that add functionality to Sails core. You can use hooks to run custom code when your app lifts and before handling every incoming request. Hooks can also be installed as plugins, but the hooks in this folder are always custom for your application.
- Responses: Custom responses can help maintain consistent HTTP status codes and behavior across your app. (Since not every Sails application needs to define its own custom responses, this folder is sometimes excluded.)
- Services: Services are shared utilities common in Sails apps written before version 1.0. They can be just about anything, so for new apps, it's recommended that you use helpers instead.
Want to see for yourself?
An example of this directory can be found in our sample app repo, here.
Check out the full Sailsconf 2024 playlist on Youtube
Documentation