How to...

Glue42 Enable Your App

Node.js

Initialization

If your Node.js script is started as a Glue42 application, you can initialize the Glue42 library without passing a configuration object to the factory function:

const Glue = require("@glue42/desktop");

// No configuration object.
const glue = await Glue().catch(console.error);

console.log(glue.version);

If your Node.js script is started outside Glue42 Enterprise, you have to pass a configuration object when initializing Glue42:

const Glue = require("@glue42/desktop");
const config = {
    application: "MyNodeApp",
    layouts: false,
    appManager: "full",
    logger: false,
    windows: false,
    gateway: {
        protocolVersion: 3,
        ws: process.env.gwURL
    },
    auth: {
        gatewayToken: process.env.gwToken
    }
};

// With configuration object.
const glue = await Glue(config).catch(console.error);

console.log(glue.version);

Application Configuration

To add your app to Glue42 Enterprise, you need to create an application configuration .json file. You should place this file in the %LocalAppData%\Tick42\UserData\<ENV-REG>\apps folder. <ENV-REG> in the link should be replaced with the region and environment folder name used for the deployment of your Glue42 Enterprise - e.g., T42-DEMO.

The following is an example configuration of a Node.js app:

{
    "title": "MyNodeServer",
    "name": "nodeServer",
    "caption": "Server description",
    "type": "node",
    "service": true,
    "details": {
        "path": "%GDDIR%/PathToMyServer",
        "showConsole": true
    }
}

The only property which is required is the path. It must lead to a .js file which will be executed by Node.js from Glue42 Enterprise.

Glue42 JavaScript Concepts

Once the Glue42 JavaScript library has been initialized, your application has access to all Glue42 functionalities. For more detailed information on the different Glue42 concepts and APIs, see:

Reference

Reference