Skip to main content

Variables

The DcuplAppLoader offers extensive configuration options out of the box. Utilize variables in your loader file to customize resource paths or dynamically set headers (such as authorization) and queries. For added flexibility, you can nest variables within other variables (see default variables -> baseUrl). There are several methods to set variables, which are evaluated in a specific order to ensure your project's maintainability and variable management throughout its lifecycle. We also provide some default variables to help you hit the ground running.

loader.variables.get('projectId'); // 'your-projectId'
loader.variables.getAll();

default variables​

variabledefault value usage
projectIdundefinedIs used to connect with the dcupl console. You wil find it in the console dashboard 
apiKeyundefined* same as projectId 
versiondraftThe version of your uploaded dcupl files you can load from the CDN 
cdnBaseUrlhttps://cdn.dcupl.com/files/projectsSpecifies the base url to our CDN
baseUrl${cdnBaseUrl}/${projectId}/${version}Specifies the base url to your project in our CDN
modelUrl${baseUrl}/modelsYour "models" folder in our CDN
dataUrl${baseUrl}/dataYour "data" folder in our CDN
transformerUrl${baseUrl}/transformersYour "transformer" folder in our CDN
loaderFileNamedcupl.lc.jsonThe name of your default loader
cdnVersionundefinedThe version of your files in the CDN Cache. Will be set to the last-changed timestamp of your files
consoleApiUrlhttps://api.dcupl.comThe dcupl console API Url

Evaluation order of variables​

Depending on your application's requirements, there are various ways to set your variables. If you're using the dcupl console, you might want to define your variables in the dcupl.lc.json file, allowing you to reuse them within the console.

  1. default variables
  2. environment variables
  3. process options variables
  4. global variables

Set Environment variables​

{
"applications": [...],
"environments": [
{
"key": "development",
"name": "Development",
"variables": [
{
"key": "my-var",
"value": "some-value"
}
]
}
],
"resources": [...]
}

Set process options variables​

const loader = new DcuplAppLoader();
await loader.config.fetch();

await loader.process({
applicationKey: 'default',
variables: [
{
key: 'my-var',
value: 'some-value',
},
],
});

Set global variables​

loader.variables.global.set('my-var', 'some-value');