Class: Extension

Extension

App.Extension allows you to add your own business logic to Built.io Backend. The business logic is written in JavaScript, and executed on the cloud.

new Extension(extension_key){Extension}

extension.js, line 10
Use this constructor to get an instance of Extension
Name Type Description
extension_key String The extension key of the extension application
Example
// 'blt5d4sample2633b' is a dummy Application API key

var extion = Built.App('blt5d4sample2633b').Extension('blt_extKey'); // blt_extKey is a extension key.

Methods

delete(fnUrl, reqBody, reqHeaders){Promise.<Variable>}

extension.js, line 141
Use the function to execute a delete function call deployed on Built.io Backend Extension.
Name Type Description
fnUrl String The url of the function that needs to be executed
reqBody object The request body that needs to be sent with the request (Optional)
reqHeaders object Headers that need to be sent along with the request (Optional)
Example
// 'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b')
app.Extension()
.delete('/submit', body, headers)
.then(function(result){
   // do somethings
});

executeFunction(method, fnUrl, reqBody, reqHeaders){Promise.<Variable>}

extension.js, line 49
Use the function to execute a function call deployed on Built.io Backend Extension.
Name Type Description
method String The HTTP method of the function that needs to be executed (GET, POST, PUT, DELETE)
fnUrl String The url of the function that needs to be executed
reqBody object The request body that needs to be sent with the request (Optional)
reqHeaders object Headers that need to be sent along with the request (Optional)
Example
// 'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b')
app.Extension()
.executeFunction('GET', '/submit', body, headers)
.then(function(result){
   // do somethings
});

get(fnUrl, reqBody, reqHeaders){Promise.<Variable>}

extension.js, line 78
Use the function to execute a get function call deployed on Built.io Backend Extension.
Name Type Description
fnUrl String The url of the function that needs to be executed
reqBody object The request body that needs to be sent with the request (Optional)
reqHeaders object Headers that need to be sent along with the request (Optional)
Example
// 'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b')
app.Extension()
.get('/getUser', body, headers)
.then(function(result){
   // do somethings
});

getExtensionKey(){String}

extension.js, line 178
Gets the extension key for an extension
Example
// 'blt5d4sample2633b' is a dummy Application API key
var extension = Built.App('blt5d4sample2633b').Extension().setExtensionKey('bltdb28fsaMplEf1b8');
console.log(extension.getExtensionKey());

isNew(){Boolean}

extension.js, line 194
Determines whether extension_key is assigned to this Extension
Example
//'blt5d4sample2633b' is a dummy Application API key
// 'local_extension' is a dummy extension_key
var extApp  = Built.App('blt5d4sample2633b').Extension('local_extension')
var boolean = extApp.isNew();

post(fnUrl, reqBody, reqHeaders){Promise.<Variable>}

extension.js, line 99
Use the function to execute a post function call deployed on Built.io Backend Extension.
Name Type Description
fnUrl String The url of the function that needs to be executed
reqBody object The request body that needs to be sent with the request (Optional)
reqHeaders object Headers that need to be sent along with the request (Optional)
Example
// 'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b')
app.Extension()
.post('/submit', body, headers)
.then(function(result){
   // do somethings
});

put(fnUrl, reqBody, reqHeaders){Promise.<Variable>}

extension.js, line 120
Use the function to execute a put function call deployed on Built.io Backend Extension.
Name Type Description
fnUrl String The url of the function that needs to be executed
reqBody object The request body that needs to be sent with the request (Optional)
reqHeaders object Headers that need to be sent along with the request (Optional)
Example
// 'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b')
app.Extension()
.put('/submit', body, headers)
.then(function(result){
   // do somethings
});

setExtensionKey(extensionKey){Extension}

extension.js, line 162
Sets the extension key for an extension
Name Type Description
extensionKey String The Extension key
Example
// 'blt5d4sample2633b' is a dummy Application API key
var extension = Built.App('blt5d4sample2633b').Extension().setExtensionKey('bltdb28fsaMplEf1b8');