forge-nodejs-sdk v5.3.0
Forge Node.JS SDK
Install
npm install forge-nodejs-sdk --saveUsage
// Require sdk main module
const sdk = require("forge-nodejs-sdk");
// Available classes
const ForgeManagementApi = sdk.ForgeManagementApi;
const ForgeNotificationBus = sdk.ForgeNotificationBus;
const DistributionNotificationBus = sdk.DistributionNotificationBus;
const ForgeCommands = sdk.ForgeCommands;
const ForgeDistributionApi = sdk.ForgeDistributionApi;
const ForgeFrontEndApi = sdk.ForgeFrontEndApi;Consider that most methods returns Es6 Promise,
write the correct implementation code to catch errors and handle continuation.
IMPORTANT: If you start receiving notification from ForgeNotificationBus or DistributionNotificationBus it is important to keep just one active connection for your entire application process, because each new connection will create a new service bus subscription.
Compatibility
Version 4.1 of the SDK is compatible only with Forge >= 4.1.0.
How to call a management API
let api = new ForgeManagementApi(config.managementApi);
api.getStories("working")
.then((stories) => {
// TODO your code
});How to send a command
let api = new ForgeManagementApi(config.managementApi);
let notificationBus = new ForgeNotificationBus(config.serviceBus);
api.autoWaitCommandNotification(notificationBus);
function connect(){
return notificationBus.startReceiving();
}
function disconnect(){
return notificationBus.stopReceiving();
}
connect()
.then(() => {
let cmd = new ForgeCommands.CreateStory({
translationInfo: {culture:"en-us"}
});
return api.post(cmd)
})
.then(disconnect, disconnect);How to subscribe to distribution notification
let notificationBus = new DistributionNotificationBus(config.serviceBus);
function connect(){
return notificationBus.startReceiving();
}
function disconnect(){
return notificationBus.stopReceiving();
}
connect()
.then(() => {
notificationBus.on("EntityDistributionNotification", (e) => {
// TODO your code
});
});How to subscribe to forge notification
let notificationBus = new ForgeNotificationBus(config.serviceBus);
function connect(){
return notificationBus.startReceiving();
}
function disconnect(){
return notificationBus.stopReceiving();
}
connect()
.then(() => {
notificationBus.on("PublishedNotification", (e) => {
// TODO your code
});
});Configuration
Forge node.js SDK expects a configuration defined like this:
{
"managementApi":{
"authKey": "f083d945-a644-41f1-9d2f-ff9b7fd5cd01",
"url": "http://localhost:60191/",
"version": "v1"
},
"serviceBus":{
"url": "amqp://guest:guest@localhost:5672"
},
"distributionApi":{
"url": "http://localhost:60192/",
"version": "v2"
},
"frontEnd":{
"url": "http://localhost:54787/",
"authKey": "00174056-D0E4-4983-9202-114F1339F6C9"
}
}Samples
See ./sample/ directory.
How to run a sample
npm install # install dependencies
set FORGE_TARGET=yourtarget
# ensure to have a valid configuration file "config.yourtarget.json"
node ./sample/waitForNotifications.jsBy default samples load configuration from config.localhost.json. You can read
another configuration file by changing the FORGE_TARGET environment variable.
For example:
set FORGE_TARGET=webplu-testwill load the configuration file config.webplu-test.json.
How to publish new version of the SDK
git commit -a -m "message"
npm version major|minor|patch
git push
npm publish7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago