smartcloud (Alpha)
SmartCloud Utility Library for Node.js
$ npm install --save smartcloud
Create base cloud function
index.js
const SmartCloud = require('smartcloud')();
const myFunction = SmartCloud.SmartFunction(
{
functionName: 'test-function',
trigger: 'user-commands',
triggerType: 'pubsub',
targets: [
{ type: 'pubsub', name: 'user-events' },
{ type: 'datastore', name: 'Users'}
],
filter: ['CreateUser']
}
);
exports.testFunction = function testFunction( event, callback ) {
return myFunction.run(event, callback, ( newUser ) => {
newUser.id = Smartcloud.getUUID();
newUser.timestamp = Date.now();
myFunction.sendOutput(newUser);
})
};
exports.getFunctionDetails = function getFunctionDetails( ) {
return myFunction.options;
}
deploy.js
'use strict';
const app = require('./');
const SC = require('smartcloud')();
const DeployService = SC.Deploy(app);
return DeployService.deploy()
.catch(( error ) => { process.exit(1) });
setup.js
'use strict';
const app = require('./');
const SC = require('smartcloud')();
const SetupService = SC.Setup(app);
return SetupService.runSetup()
.catch(( error ) => { process.exit(1) });