Script Services

From DreamFactory
Jump to: navigation, search
(Created page with "Script services are a types of service, defined by the scripting language used to execute the desired script (i.e. V8Js), that allow ad-hoc extension of DreamFactory's API by...")
(No difference)

Revision as of 20:12, 25 July 2016

Script services are a types of service, defined by the scripting language used to execute the desired script (i.e. V8Js), that allow ad-hoc extension of DreamFactory's API by utilizing server-side scripting. In pre-2.x versions of the software, this was referred to as "custom" or "user" scripts. In 2.0, they get first-class treatment, similar to all other service types, allowing them to be used by role-service-access, packaging, etc. As such, they are managed via the api/v2/system/service API endpoint under the system service.

To see which script service types exists on a particular DreamFactory instance, the api/v2/system/service_type API endpoint and look for the ones with group set to 'Script'. Also, refer to the [[1]] section of this documentation.

How It Works

The script configured as part of the Script service is run when the API endpoint for that service is called. Any additional URL resources (i.e. path after the service name) are passed, along with URL parameters, headers, and payload, are packaged into an event object and passed to the script execution context along with the platform object. Similar to event scripting, the event.response or exceptions thrown are sent back to the calling client.