concept controller action in category sails

This is an excerpt from Manning's book Sails.js in Action.
Now that we’ve covered the fundamental pieces of any Sails application, let’s take what you’ve learned so far and see how it all fits together. You saw how the frontend talks to your Sails app by sending HTTP requests and how your Sails app replies with HTTP responses. We looked at how every time your Sails app receives a request, it uses your configured routes to determine which controller action to run. And in the last section, we introduced model methods, which are just one example of the many Sails and Node.js library methods you can call from the backend code in your controller actions. But, in theory, you could create almost any imaginable server-side web application with routes and controller actions alone. Routes and controller actions are the fundamental pieces of any Sails application. In practice, controller actions usually leverage many additional library methods provided by Sails and Node.js.
Controller actions can be simple or complex. For example, in the same app you might write one controller action (PageController.showHomePage) that simply responds with an HTML web page and another (CartController.checkout) that uses model methods to fetch data, calls out to a service with custom business logic, contacts a third-party service to process a bitcoin transaction, and responds with a 200 status code to indicate success. Thinking about the different parts of your application this way can get very complicated very quickly—particularly as time passes and more hands touch the code.
Luckily, there’s another, simpler way to reason about the backend that’s widely accepted by developers all over the world. Regardless of what a particular controller action (or endpoint) does, it’s usually pretty easy to discuss how it responds and why it ran in the first place. Instead of focusing on the code inside the controller action, you can simply consider the request you need to send from the frontend to kick it off and the response you expect to receive in return. In the example of the complicated controller action we mentioned earlier (CartController.checkout), instead of thinking about the mechanics of working with the database and calling a third-party service, you can simply remember that to call the endpoint you need to send a POST request to /checkout and that you can expect a 200 status code in response (provided everything went according to plan).
To secure the backend, we first need to determine the different rights and restrictions a user can have with regard to access in Brushfire. Then we need to identify the controllers and actions whose access will be affected. Finally, we’ll implement the actual policies that contain the logic necessary to manage access to the controller actions according to our defined requirements.
Leave the controller action as is. When is a policy more appropriate than placing the code in a controller action to manage access? The best practice is to use a policy to protect those controller actions that are not accessible in the UI. To clarify, that doesn’t mean the controller action is never accessible in the UI. Instead, look for instances when the controller action is restricted in the UI by not being displayed, but is open to unwanted access outside the UI with programs like Postman.