Shared CloudCode Tasks
Overview
A shared CloudCode task can be created to manage files that need to be shared with other CloudCode tasks. This can be used to share configuration or common functions across multiple CloudCode tasks within the same app.
Version Compatibility
Compatible with version 1.4.2 and later of CloudCode.
A "Shared" task template has been added to assist in creating a task which can be accessed from all other tasks.
Simply select this template when creating a new CloudCode task. A shared task is required to be called "shared" and have the following package.json:
{
"name": "shared",
"cloudcode": {
"shared": true,
"enabled": true
}
}The shared task cannot be deployed or executed directly but files in the task can be included from other CloudCode tasks.
Example
Given a shared task with the following files:
module.exports = {
// put method and values to share here
secret: 'foo',
add: function add(a, b) {
return a + b;
}
};The files in the shared task can then be loaded from other tasks, for example:
The output of the task will be as follows:
Last updated