1.0.2 • Published 6 years ago

space-engine-node v1.0.2

Weekly downloads
2
License
Apache-2.0
Repository
-
Last release
6 years ago

Client API for Space Cloud

Installation

$ npm install space-engine-node --save

Quick Start

Create Engine Instance

const Engine = require('space-engine-node');

const engine = new Engine('my-engine');

Note: All instances with same engine name are automatically load balanced.

Register the function

engine.registerFunc('my-func', (params, auth, cb) => {
console.log('Params:', params, 'Auth', auth)
// Do something

const res = { ack: true, message: 'Function as a Service is Awesome!' }
cb('response', res)
})

Note: Enable Functions module in Space Cloud, run space-exec and nats server to be able to use it.

Classes

Functions

Engine

Class representing the Engine Interface.

Kind: global class

new Engine(engineName, opts)

Create an instance of the Engine API.

ParamTypeDescription
engineNamestringName of the engine.
optsstring | ObjectConnection options for Nats.

Example

const Engine = require('space-engine-node');
const engine = new Engine('my-engine');

// Register function with engine
engine.registerFunc('my-func', (params, auth, cb) => {
console.log('Params:', params, 'Auth', auth)
// Do something

const res = { ack: true, message: 'Function as a Service is Awesome!' }
cb('response', res)
})

engine.registerFunc(name, func)

Register the function to FaaS Engine

Kind: instance method of Engine

ParamTypeDescription
namestringName of the function.
funcEngineFunctionFunction to be registered

Callback(type, res)

Callback to be called before returning from function.

Kind: global function

ParamTypeDescription
typestringType of callback action to be performed.
resObjectData to be sent to client.

EngineFunction(params, auth, cb)

Callback for realtime updates to the subscribed data

Kind: global function

ParamTypeDescription
paramsObjectParams received by function.
authObjectAuth object of client. Will be undefined if request is unauthenticated.
cbCallbackThe callback function to be called by the function.
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago