Flares

Flares are basically plugins for ATON. Check out the official API docs.

  • They intend to extend the functionalities of your ATON instance, for multiple web-apps
  • They can provide both client and server components (e.g. additional routes performing server-side actions, REST API enrichments, etc.)
  • They automatically equip the official front-end (Hathor)

They are located in <your-main-ATON-folder>/config/flares/

The model is pretty much the same for web-apps plug&play architecture – i.e. they can be pugged in while the services are running

Structure

The basic structure involves:

  • a public/ subfolder, providing client components (e.g. javascript/ES modules) loaded by the web-app / front-end
  • a flare.json representing the descriptor

Sample flare.json:

{
    "name": "My first flare",

    "client":{
        "files": [
            "myflare.js"
        ]
    }
}

This basically tells ATON we want to add a flare called “My first flare“, loading a simple javascript file located in the public/ sub-folder of the flare. A flare can also require multiple dependencies indeed, in the files list.

A very basic example for myflare.js:

{
  let F = new ATON.Flare("myFlare");
  
  // do stuff for this flare initialization
  F.setup = ()=>{
    F.log("initialized!"); // Flare log
  }

  // optional update routine (executed continuously)
  F.update = ()=>{
  }
}

myFlare” is a local identifier for this flare in ATON, although it usually matches the flare ID on the server. After flares deployment, this specific flare can be accessed via ATON.getFlare("myFlare").

Add Flares to your App via code

You can require a specific list of flares to equip your app in this way:

let myApp = ATON.App.realize();
myApp.requireFlares(["myFlare"]);

myApp.setup = ()=>{
  ATON.FE.realize();

  // Do app setup stuff
  
  // Do stuff that depends on flares (wait for all flares to be ready)
  ATON.on("AllFlaresReady",()=>{
    // ...
  });
}

Add Flares dynamically via url parameters

You can also equip any app with any flare dynamically via url parameters. Any ATON app in fact, can request a list of flares through ff parameter, for instance:

https://myatoninstance.com/a/myapp/?ff=FlareA

will equip “myapp” with the flare “FlareA“, while:

https://myatoninstance.com/a/myapp/?ff=FlareA,FlareB

will equip myapp with 2 flares (FlareA and FlareB)