ForgeTotal.js 5
en

Total.js 5

TotalAPI and Componentator service boundaries

Total.js 5 · total5@0.0.19 total5reference Executed against Total.js 5

TotalAPI(operation, data) delegates to API('TAPI', operation, data). The built-in driver sends requests to the regional endpoint selected by CONF.$tapiurl, using a configured token such as CONF.secret_totalapi. .promise() and .callback() use the same API builder as other drivers. With $tapi:false, operations other than the driver's special check operation fail locally with totalapi_inactive.

COMPONENTATOR(name, components, removeprev=true, attrs='') determines a public bundle filename, stores its URL in REPO[name] and fetches it from Componentator only when the file is absent. With removeprev:true, older matching files may be deleted. The componentator event receives the name/component metadata before the lookup. This function returns before its async filesystem/download work has finished; the repo URL alone is not proof of download success.

For locally vendored frontend assets, serving known files avoids dependence on remote bundle availability. For live TotalAPI/Componentator integration, separately verify your exact service, credentials, network behavior and returned content. These services are optional and are not dependencies needed to start a native Total.js application.

config
$tapi : false
controllers/remote.js
exports.install = function() {
	ROUTE('GET /disabled-api/', async function($) {
		try { await TotalAPI('forge-fixture-no-service', {}).promise(); $.json({ unexpected: true }); }
		catch (e) { $.json({ error: String(e) }); }
	});
	ROUTE('GET /cached-componentator/', function($) {
		var components = 'forge-local-fixture';
		var relative = 'ui-' + components.makeid() + '.min.js';
		F.Fs.writeFileSync(PATH.public(relative), '/* local fixture */');
		COMPONENTATOR('fixture', components, false);
		$.json({ url: REPO.fixture, expected: '/ui-' + components.makeid() + '.min.js' });
	});
};