Scripts in action

Source

Let's open a scripts folder and look through the files as we go along.

Here's an example of some installed scripts on the server which hook into various places in JRNI.

Open the manifest.json file

Here you'll see the definition of a specific script that we've set to load.

You'll see there is are two scripts named "Present" and "PresentProxy", that are listed as a "PublicScript" that supports a "GET".

This means these scripts are ones that can be run by anyone by simply loading the URL.

Open the main.js file

This contains the scripts themselves. These scripts are called when the public URLs are called.

In this case the core JRNI engine is acting like an API Gateway to route through to these scripts.

The scripts are expected to return a response to send back to the client.

There are 2 scripts here. The difference between the two is that one says it returns a "proxy" and the other doesn't. This allows us to control how the data we return is used.

The first is returning data that it expects another application to load. It's going to return JSON data in a raw form, and it's going to return error information and log information in the result.

The second is listed as a "proxy" function. This means the data will be unwrapped and the headers will be used to format the return.

In action