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​
variable | default value | Â usage |
---|---|---|
projectId | undefined | Is used to connect with the dcupl console. You wil find it in the console dashboard |
apiKey | undefined | * same as projectId |
version | draft | The version of your uploaded dcupl files you can load from the CDNÂ |
cdnBaseUrl | https://cdn.dcupl.com/files/projects | Specifies the base url to our CDN |
baseUrl | ${cdnBaseUrl}/${projectId}/${version} | Specifies the base url to your project in our CDN |
modelUrl | ${baseUrl}/models | Your "models" folder in our CDN |
dataUrl | ${baseUrl}/data | Your "data" folder in our CDN |
transformerUrl | ${baseUrl}/transformers | Your "transformer" folder in our CDN |
loaderFileName | dcupl.lc.json | The name of your default loader |
cdnVersion | undefined | The version of your files in the CDN Cache. Will be set to the last-changed timestamp of your files |
consoleApiUrl | https://api.dcupl.com | The 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.
- default variables
- environment variables
- process options variables
- 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');