Node JS SDK - Overview
Node JS SDk has all the necessary methods to access the Catalyst Components and services. It allows you to declare and define Catalyst components whose behavior are predefined. For example, each Catalyst component has its equivalent NodeJS object in SDK and API equivalents are called methods in NodeJS.
Include Catalyst SDK in Project
If you choose install dependencies option in the CLI while initializing the Catalyst project, the node.js SDK will automatically be included in the generated sample boilerplate code. However, you can include it in your project, by executing the following command from the CATALYST_PROJECT_HOME directory in the CLI.
copy
npm install --save zcatalyst-sdk-node
Initialize the SDK
Catalyst Node.js SDK must be initialized which would return an object. You can access the catalyst components of the current project thrugh this returned object. The different initialization methods for different type of functions are as given below.
SDK Initialization in Advanced I/O Functions with the Basic Template
copy
var catalyst = require('zcatalyst-sdk-node');
module.exports = (req, res) => {
var app = catalyst.initialize(req);
//This app variable is used to access the catalyst components.
//You can refer the SDK docs for code samples.
//Your business logic comes here
}
SDK Initialization in Advanced I/O Functions with Express.js
copy
const expressApp = express();
var catalyst = require('zcatalyst-sdk-node');
const express = require('express');
expressApp.get('/',(req,res)=>{
var app = catalyst.initialize(req);
//This app variable is used to access the catalyst components.
//You can refer the SDK docs for code samples.
//Your business logic comes here
});
module.exports=expressApp;
SDK Initialization in BasicIO Functions
copy
const catalyst = require('zcatalyst-sdk-node');
module.exports = (context, basicIO) => {
const app = catalyst.initialize(context);
//This app variable is used to access the catalyst components.
//You can refer the SDK docs for code samples.
//Your business logic comes here
}
SDK Initialization in Event Functions
copy
const catalyst = require('zcatalyst-sdk-node');
module.exports = (event, context) => {
const app = catalyst.initialize(context);
//This app variable is used to access the catalyst components.
//You can refer the SDK docs for code samples.
//Your business logic comes here
}
SDK Intialization in Cron Functions
copy
const catalyst = require('zcatalyst-sdk-node');
module.exports = (cronDetails, context) => {
const app = catalyst.initialize(context);
//This app variable is used to access the catalyst components.
//You can refer the SDK docs for code samples.
//Your business logic comes here
}
Now you can access the components using the initialized variable.
Yes
No
Send your feedback to us
Skip
Submit