Skip to content
Jayesh333 edited this page Aug 22, 2018 · 3 revisions

Classes

Api

Class representing the client api.

External

Mongo

The MongoDB Client Interface.

SQL

The SQL Client Interface.

Api

Class representing the client api.

Kind: global class

new Api(projectId, url)

Create an instance of the Client API.

Param Type Default Description
projectId string The Project Id.
url string "/" Base url of space-exec server.

Example

const { API } = require('space-api-node');

const api = new API('my-project');

api.setToken(token)

Initialse the Client Api with the JWT token

Kind: instance method of Api

Param Type Description
token string The signed JWT token received from the server on successful authentication.

api.setProjectId(projectId)

Set the new Project Id

Kind: instance method of Api

Param Type Description
projectId string The Project Id.

api.Mongo() ⇒ Mongo

Returns a MongoDB client instance

Kind: instance method of Api
Returns: Mongo - MongoDB client instance

api.Postgres() ⇒ SQL

Returns a SQL client instance

Kind: instance method of Api
Returns: SQL - SQL client instance

api.MySQL() ⇒ SQL

Returns a SQL client instance

Kind: instance method of Api
Returns: SQL - SQL client instance

api.call(engineName, funcName, params, [timeout]) ⇒ Promise

Calls a function from Function as a Service Engine

Kind: instance method of Api
Returns: Promise - Returns a promise

Param Type Default Description
engineName string The name of engine with which the function is registered
funcName string The name of function to be called
params Object The params for the function
[timeout] string 5000 Timeout in milliseconds

Example

api.call('my-engine', 'my-func', { msg: 'Function as a Service is awesome!' }, 1000)
.then(res => {
  if (res.status === 200) {
    // res.data contains the response given by the function
    console.log('Response:', res.data);
    return;
  }
}).catch(ex => {
  // Exception occured while processing request
});

Mongo

The MongoDB Client Interface.

Kind: global external
See: https://github.com/spaceuptech/space-api-node/wiki/Mongo

SQL

The SQL Client Interface.

Kind: global external
See: https://github.com/spaceuptech/space-api-node/wiki/SQL