# Node

## Introduction

The Node module is responsible for deploying (starting) and un-deploying (stopping) a group of modules to form an application.

Module based applications use the Node module to bootstrap and the application configuration file (in JSON format) is passed as is (after include and expansion) to the Node module which processes the `modules` part of the file.

This module is never deployed by configuration.

## Configuration

{% tabs %}
{% tab title="Properties" %}

<table><thead><tr><th width="143">Name</th><th width="211">Description</th><th width="196">Default</th><th data-type="checkbox">Mandatory</th></tr></thead><tbody><tr><td><code>groups</code></td><td>List of module groups defining the order of deployment.</td><td><p><code>[</code></p><p><code>"first",</code></p><p><code>"system",</code></p><p><code>"authn",</code></p><p><code>"default",</code></p><p><code>"last"</code></p><p><code>]</code></p></td><td>false</td></tr><tr><td><code>modules</code></td><td>List of <a href="#module">module</a>s to deploy. If empty or non-existing no modules will be deployed.</td><td><code>[]</code></td><td>false</td></tr><tr><td><code>heartbeat</code></td><td>HTTP heartbeat configuration object (see below).</td><td><code>{ "enabled": false }</code></td><td>false</td></tr></tbody></table>
{% endtab %}

{% tab title="Example" %}

```json
{
  "groups": "first,default,last",
  "modules": [
    {
      "name": "<module-name-01>",
      "enabled": true,
      "group": "first",
      "config": {
      }
    },
    {
      "name": "<module-name-02>",
      "enabled": false
      "config": {
      }
    }    
  ],
  "heartbeat": {
    "enabled": false
  } 
}
```

{% endtab %}
{% endtabs %}

### Module

A module object represent a module to deploy. All modules defines their own configuration, documented separately.

Module deployment order is defined by groups, all modules in the first group are deployed before modules in the next, and so on. If a module has no group defined it will be added to the default group.

{% tabs %}
{% tab title="Properties" %}

<table><thead><tr><th>Name</th><th>Description</th><th>Default</th><th data-type="checkbox">Mandatory</th></tr></thead><tbody><tr><td><code>name</code></td><td>Module class name or alias </td><td></td><td>true</td></tr><tr><td><code>enabled</code></td><td>Flag controlling if module should be deployed or not </td><td><code>true</code></td><td>false</td></tr><tr><td><code>group</code></td><td>Module deployment group</td><td><code>"default"</code></td><td>false</td></tr><tr><td><code>config</code></td><td>JSON object containing the module configuration.</td><td><code>{}</code></td><td>false</td></tr></tbody></table>
{% endtab %}

{% tab title="Example" %}

```json
{
  "name": "<module-name-or-alias>",
  "enabled": true
  "config": {
  }
}
```

{% endtab %}
{% endtabs %}

### Heartbeat

The Node module supports HTTP heartbeat.&#x20;

The heartbeat responder supports all HTTP module configuration properties and is started when all configured moduled has been successfully started (i.e. when the application is started and ready to receive requests).

### Response

By default response is HTTP 200 with body OK.  Content type is set to:

"text/plain; charset="utf-8""

If using a json file response is data from the json file with headers:

\
"Content-type", "application/json; charset="utf-8"\
"Cache-Control", "no-store, no-cache, must-revalidate, max-age=0"\
"Pragma", "no-cache"\
"Expires", "0"

{% hint style="danger" %}
No data format kontrol is made by the server. It will assume json file.
{% endhint %}

{% hint style="info" %}
By default the heartbeat responder uses the following URL:\
\
`http://<host-or-ip>:8080/heartbeat`
{% endhint %}

{% hint style="warning" %}
Since the heartbeat configuration is used by the Node module, which serves as the default bootstrap module, it must be placed at the top level in config.json.
{% endhint %}

{% tabs %}
{% tab title="Properties" %}

<table><thead><tr><th>Name</th><th>Description</th><th>Default</th><th data-type="checkbox">Mandatory</th></tr></thead><tbody><tr><td><code>enabled</code></td><td>Flag to enable heartbeat</td><td><code>false</code></td><td>true</td></tr><tr><td><code>http_listener</code></td><td>Name/id of the<a href="https://app.gitbook.com/s/OT8LSTVmASMHpWaxFiFR/http-listener">HTTP listener</a> to use. <br><br>If not specified default settings will be used. </td><td></td><td>false</td></tr><tr><td><code>http_context</code></td><td>Responder base HTTP context.</td><td><code>"/heartbeat"</code></td><td>false</td></tr><tr><td><code>context_path</code></td><td>Responder HTTP context path. <br><br>This property is appended to <code>http_context</code> to form the full context ("path") of the responder.</td><td>"<code>/*"</code></td><td>false</td></tr><tr><td><code>data_file</code></td><td>File path to json file to load. It will be read at each request. No cache.</td><td>N/A</td><td>false</td></tr></tbody></table>
{% endtab %}

{% tab title="Examples" %}

```json
{
  "heartbeat": {
    "enabled": true,
    "http_listener": "default-8080"
    "http_context": "/node01",
    "context_path": "/hb"
  }
}
```

{% endtab %}
{% endtabs %}
