Corva node-sdk is a framework for building Corva DevCenter apps.
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
A minimal app should export a handler
that matches one defined in your manifest.json
:
const { Corva } = require('@corva/node-sdk');
exports.handler = new Corva().task((event) => console.log(event));
For details on the app types, see App types.
There are the following app types that you can build:
Stream & scheduled apps can be followed. Followable apps must produce data to trigger the chain reaction of apps' runs.
There are the following possible ways to make the app produce the data:
CorvaDataSource.produceMessages
for details.Dataset.createEntriesAndProduceMessages
for detailsTo implement an app with node-sdk, you have to write a handler function that accepts two arguments:
event
- an event itself, see Events;context
- helpers that are bound to app execution's context, see Context.const handler = (event, context) => {
console.log(event, context);
}
There are following types of events that match the related app types:
Context provides the next functionality:
cache
- convenient methods to work with the 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
- the application's sensitive data (see DevCenter docs, usage example, testing);config
- some basic info about app invoke.