What is Asgard

Asgard is what bootstraps cogs to TCore. Asgard is the middleware between TCore and client applications. We use it to handle communication between cogs and clients, which happens through post requests sent to Asgard. To put it simply, Asgard is an API endpoint hosted on your local device. Developers can send POST requests to Asgard to get things done using TCore. The core functionality of TCore revolves around Asgard, and this is what anyone wanting to create an app which makes use of a TCore cog would need to use. To access it, you need to ping This can also be accessed over a local network by pinging the IP address displayed on the TCore mobile app's notification.

We use tcli to bootstrap cogs. Cogs have a very specific folder structure, and messing with this structure will cause it to stop functioning.

Structure of a request

Communication between TCore and client applications is accomplished using POST requests sent to the sAPI which are then handled by Asgard. POST requests processed by Asgard have a special structure, the body of the POST contains all of the essential payload data for Asgard; the cog to be used, action inside the cog and the data.

{  "hook": "test-cog", // Name of the cog  "action": "hello", // Action is same as functions on mobile version of TCore  "function": "hello", // Which function to execute  "params": [] // Any inputs which are to be passed to the cog}

Asgard will then return a response to the request with the final processed data provided by the cog.

{  "code": 200,  "data": {    "msg": "Hello World!" // This is the return we get from the function  }}
Asgard functions like a normal API. It follows the same spec as HTTP for error codes. The maximum timeout is 300ms.

Connecting to Asgard

The best way to connect to Asgard is to send requests through the sAPI since they will be formatted on the fly to be in the correct format for Asgard to process. These requests can be sent by pinging the end-point; but this results in hard to read and messy code. To simplify this process, there’s a few helper libraries to get started: TCoreLIB.JS(or tcore.js on npm) and TCoreLIB.Dart. More information on the specifics of these libraries is available at this repo.