@corva/node-sdk
Corva node-sdk is a framework for building Corva DevCenter apps.
Contents
Requirements
- NodeJs 14 or later.
Quick start
Install
With npm
(bundled with NodeJs, see docs):
$ npm i @corva/node-sdk
With yarn
(docs):
$ yarn add @corva/node-sdk
With pnpm
(docs):
$ pnpm add @corva/node-sdk
Create an app
A minimal app should export a handler
that match one defined in your manifest.json
:
const { Corva } = require('@corva/node-sdk`);
exports.handler = new Corva().task((event) => console.log(event));
For details on app types see App types.
App types
There are next app types that you can build:
- Stream - works with real-time data;
- Scheduled - works with data at defined schedules/intervals (e.g., once a minute, once every 3 ft.);
- Task - works with data on-demand.
Writing a handler
To implement an app with node-sdk you have to write a handler function which accepts two arguments:
-
event
- an event itself, see Events; -
context
- helpers that bound to app execution's context, see Context.
Handler example
const handler = (event, context) => {
console.log(event, context);
}
Event
There are next types of events that are matching the related app types:
- Scheduled event - contains info about current invocation interval;
- Stream event - contains records that have been published since last app invoke;
- Task - a task with which app was invoked, which contains passed parameters.
Context
Context provides next functionality:
-
cache
- convenient methods to work with state, see State class. Not available for task apps; -
api
- helper to interact with Corva API (and make any other generic request as well), see Api; -
logger
- Logger instance; -
secrets
- application's sensitive data (see DevCenter docs, usage example, testing); -
config
- some basic info about app invoke.