We have a default Node 6.10(LTS) support on our platform. Custom version support also available on request.
Since backbench is a Faas integrated with APIGATEWAY we provide a static convention to map your functions to API endpoints. (we call em public functions). And this is how we define them -
arg2 is a nodejs callback and is optional. Callback will let you see the response on your APIs. (not console.log)
Note: callback function should have an argument which is JSON.parsed.
To log your application, use console.log() and logs will be generated on Logs section.
To check compilation error, click on bug button(integrated JSHint).
For runtime failure, see your bench's dashboard.
Restrictions
Module name cannot be func.js.
Callback function's argument should be JSON.parsed() to use.
Example
API to display Hello World!
2. Running a background process (without callback).
3. Using ESv6
4. Using node async/await.
More about callback function
error – is an optional parameter that you can use to provide results of the failed function execution. When a function succeeds, you can pass null as the first parameter.
result – is an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.parse() compatible. If an error is provided, this parameter is ignored.
exports.endpoint = function(request, callback){
console.log("Logged at " + new Date())
callback(undefined, {response: "Hello World"})
}
exports.endpoint = function(request){
//this program can be used to log IP address,
//for the user hitting this api.
console.log(req["x-forwarded-for"]);
}