Objective
The purpose of the document is to provide a reference to the edgeEngine Context Object and the other objects that is part of the edge Serverless computing environment
Intended Readers
The intended readers of this document are software developers that will be programming using the edgeEngine Context Object as well as the other objects that are available in the edge Serverless computing environment
What You Need To Know To Use This Reference
This document assumes that you have a basic knowledge of:
Object Model Reference
context
edge
http
The class http
describes the HTTP request client that is built into the edgeEngine Runtime environment. The http
class publishes a method request
that is used to implement an HTTP request from an edge microservice.
Examples
request(httpClientOptions)
Member of the class, http
.
This property is a function that takes the httpClientOptions and parses it as an instance of a HTTP client interface.
ParametersName | Description |
---|
httpClientOptions type(httpClientOptions) | The HTTP request configuration options for making requests within the edge microservice context. |
Examples1: app.post('/data', (request, response) => {
2: context.http.request(({
3: type: 'POST',
4: data: '{}',
5: url: 'http://www.example.com/data',
6: authorization: 'Bearer token123',
7: success: (result) => {
8: response.end(result.data);
9: },
10: error: (err) => {
11: console.log(err);
12: }
13: }));
14: });
request
response
httpClientOptions
The edgeEngine Runtime has a built-in HTTP client that enables making requests to external targets running on the internet. The built in HTTP client is represented by the http
object. The class httpClientOptions
describes the HTTP request configuration options that the built-in HTTP client uses when executing requests within an edge microservice. The important thing to understand about the built-in HTTP client is that the only way to tell it how to make a request is by providing information about the intended request via the httpClientOptions
. The httpClientOptions
object is passed to the constructor of the http
class, like so: context.http.request(httpClientOptions)
.
Examples
Member of the class, httpClientOptions
.
Type Function
ParametersName | Description |
---|
result type(string) | Result of the HTTP request to the callback function. |
Examples
Member of the class, httpClientOptions
.
Type Function
ParametersName | Description |
---|
error type(string) | The error of HTTP request to the callback function |
Examples
Member of the class, httpClientOptions
.
Use this property to assign the HTTP method that the built-in HTTP client uses when making a request. For example, if you want the built-in HTTP client to make a GET request, assign the following, httpClientOptions.httpMethod = "GET"
. If you want to the HTTP client to make a POST request, assign the following: httpClientOptions.httpMethod = "POST"
Type string
Examples1:
2: httpClientOptions.httpMethod = "GET"
3:
4: httpClientOptions.httpMethod = "POST"
Member of the class, httpClientOptions
.
Use this this property to set the body of a request that is to be executed by the built-in HTTP client. Typically the data
property is set when implementing a POST
or PUT
request.
Type string
Examples httpClientOptions.data = "All good things take time."
Member of the class, httpClientOptions
.
Use this property to set the target URL that the built-in HTTP client targets when making a request.
Type string
Examples httpClientOptions.url = "https://api.example.com/movies"
Member of the class, httpClientOptions
.
Use this property to set the HTTP authorization header that the built-in HTTP client uses when making a request.
Type string
Examples httpClientOptions.authorization = "Bearer mytoken123"
Member of the class, httpClientOptions
.
Use this property to set the callback function that gets invoked when a request executed by the built-in HTTP client is successful.
Type successCallback
Examples1: httpClientOptions.success = (result) => {
2: console.log(`The request was successful. The result is: ${result}`)
3: };
Member of the class, httpClientOptions
.
Use this property to set the callback function that gets invoked when a request executed by the built-in http client throws an error.
Type errorCallback
Examples1: httpClientOptions.error = (error) => {
2: console.error(`The request was has an error. The error is: ${error}`)
3: };
decryptNodesOptions
The class decryptNodesOption
describes the configuration options for extracting sensitive information from clusters.
Examples
Member of the class, decryptNodesOptions
Use this property to set the cluster type. The possible values are account
, proximity
or local
.
Type string
Examples decryptNodesOptions.type = 'account';
Member of the class, decryptNodesOptions
Use this property to set the edge Access Token that was obtained through the mimik Identity Server API.
Type string
Examples decryptNodesOptions.token = 'token123';
Member of the class, decryptNodesOptions
Use this property to set the data that will be decrypted internally and then made available for decryption by way of edge.decryptEncryptedNodesJson(decryptNodesOption)
.
Type string
Examples decryptNodesOptions.data = 'A penny saved is a penny earned.';
Member of the class, decryptNodesOptions
Use this property to set the callback function that gets executed upon success of the decryption attempt.
BE ADVISED! The result passed into success
callback function will be the encrypted data that was [MORE TO COME]
Type successCallback
Examples1: decryptNodesOptions.success = (result) => {
2: console.log(`The decryption was successful. The result is: ${result}`)
3: };
Member of the class, decryptNodesOptions
Use this property to set the callback function that gets invoked when an decryption attempt throws an error.
Type errorCallback
Examples1: httpClientOptions.error = (error) => {
2: console.error(`The request was has an error. The error is: ${error}`)
3: };
requestBepOptions
The class requestBepOption
sets the BEP request configuration options for receiving a private communication tunnel. The options are callback functions for handling success
and error
events.
Examples
Type Function
ParametersName | Description |
---|
result type(string) | Result of the success request to the callback function. |
Examples
Type Function
ParametersName | Description |
---|
error type(string) | The error of request to the callback function. |
Examples
Member of the class, requestBepOptions
Sets the callback function that gets executed upon success.
Type successCallback
Examples1: success: (result) => {
2:
3: response.end(result.data);
4:
5: }
Member of the class, requestBepOptions
Sets the callback function that gets executed upon error.
Type errorCallback
Examples1: error: (err) => {
2: console.log(`bep request has error ${err.message}`);
3: }
storage