Assets

What are Assets?

Assets are application resources that support the functionality of the application, but do not have a standardized role in the application. For example, the public and private key need to support SSL would be considered an asset.

All assets are located in app/assets.

Using Assets

Depending on your needs, there are a couple of ways to load an asset. The first is to load the asset asynchronously via the asset() method.

const blueprint = require ('@onehilltech/blueprint');

function doSomething () {
  return blueprint.app.asset ('publicKey').then (publicKey => {
    // do something with the loaded asset
  });
}

The second approach is to load the asset synchronously.

const blueprint = require ('@onehilltech/blueprint');

function doSomething () {
  const publicKey = blueprint.app.assetSync ('publicKey');
  
  // do something with the loaded asset
}

Loading an asset synchronously is ideal when you must use the asset in a Blueprint configuration file.

Last updated