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.
Argument | Type | Details | |
---|---|---|---|
1 | action | Either a classic action (aka (req, res) ) function or an actions2 definition. |
|
2 | identity | 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. |