Skip to content

loadConfig()

Loads and validates the configuration in dd.config.mjs configuration file.

type loadConfig = loadConfig(
config?: DeepPartial<DesignerConfig>
) => Promise<DesignerConfig>

Return value

Note: loadConfig() validates the configuration asynchronously. The return value must be awaited on before it can be used.

Params

เผถ config: (optional) DesignerConfig

If you donโ€™t want to use the dd.config.mjs you can pass the configuration directly (not recommended).

If you otherwise have to work with different scenarios and chose to not use dd.config.mjs, it is still recommended that you call loadConfig(config). It will skip loading dd.config.mjs altogether but will still validate the provided object and exit ๐Ÿ›‘ the process if the configuration is not valid.

Usage

const config = loadConfig();
const context = createStoreContext(config.store);
const build = staticStoreBuilder(context);
const store = await build();

Creating an isolated config (Advanced)

If you prefer not to use dd.config.mjs configuration file, you can expose your config by passing the options object directly to loadConfig().

src/config
import { DEMO_DATA } from '@noodlestan/designer-decisions';
import { staticStoreBuilder } from '@noodlestan/designer-functions';
const store = {
decisions: [DEMO_DATA, './data'],
};
const config = { store };
export default () => loadConfig(config);

See also