Edit Page

sails.registerAction()

Register a new Sails action that can then be bound to a route.

sails.registerAction(action, name);

While actions are mainly registered automatically when the files in an app’s api/controllers folder are loaded, you can use the registerAction() method to add a new action programmatically. This is especially useful in custom hooks, in situations where you want to provide a new action but let the app developer determine the route to bind the action to, or when you want to ensure that policies and other action middleware apply to your action.

Usage

#
  Argument Type Details
1 action Function or Dictionary Either a classic action (aka (req, res)) function or an actions2 definition.
2 identity String The identifier for the action. This is the string that will be used to reference the action elsewhere in an app, for instance when binding the action to a route.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

Reference