Skip to content

Glue42 Rest Configuration Service Example in NodeJS- with support for applications and layouts

License

Notifications You must be signed in to change notification settings

gdavidkov/rest-config-example-node-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glue42 Configuration Service Example

Glue42 Enterprise uses application and layout configurations defined on the local machine, but can also be reconfigured to fetch them from a REST service.

This example project shows how to run a Node.js REST service that provides application and layout stores for Glue42 Enterprise.

Note that this is a sample implementation and some parts of it must be extended to work well in a multi-user scenario.

Configuration and Start

This example uses application definitions in JSON format located in the configuration\apps folder. Layout definitions are fetched from and saved in the configuration\layouts folder. You can also use your own application definitions, but they must be in the standard Glue42 application definition format.

To start:

npm i           // install the dependencies
npm run start   // run the server

This will start the service on port 8004.

Glue42 Enterprise Configuration

To enable fetching application and layout definitions from the REST service, you need to edit the appStores and layouts top-level keys in the Glue42 Enterprise system.json file, usually located in the %LOCALAPPDATA%\Tick42\GlueDesktop\config folder.

Applications

Find the appStores top-level key in the system.json file and add a new entry (or replace existing entries) with the following configuration:

"appStores": [
    {
        "type": "rest",
        "details": {
            "url": "http://localhost:8004/apps/"           
        }
    }
]

Layouts

Find the layouts top-level key in the system.json file and edit the store property - change the type to "rest" and assign the URL of the service to the restURL:

 "layouts": {
    "store": {
        "type": "rest",
        "restURL": "http://localhost:8004/"
      }
  } 

Configurations

Add the "extends" top-level key in any configuration file.

 "extends": [
    {
        "type": "file",
        "source": "config/local.system.nested.json"
    },
    {
        "type": "rest",
        "source": "http://localhost:8004/"
    },
    { 
        "type": "remote", 
        "source": "https://something.com/glue42/%GLUE-REGION%-%GLUE-ENV%.system.json"
    },         
]

Service configuration

Port

By default, the server will listen on port 8004. The environment variable SERVER_PORT can be used to override this setting, e.g. to change the port to 8005 in the start script:

scripts: {
    "start": "env SERVER_PORT=8005 && npm run build && node ./src/index.js"
}

Application Files

This example uses application definitions in JSON format located in the configuration\apps folder. The env variable APPS_FOLDER can be used to override the default setting.

Layout Files

This example reads and stores layouts from the configuration\layouts folder. The env variable LAYOUTS_FOLDER can be used to override the default setting.

User Identity

In this example, the user calling the service is not considered, and the returned data is the same for any user. In a real application, you may want to return a different set of applications per user, or to store layouts per user. To achieve this, you need to have information about the user identity - you can use the helper function getUser(), which returns the username of the user making the request.

About

Glue42 Rest Configuration Service Example in NodeJS- with support for applications and layouts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%