ZEST / base.resolver / Module: base-resolver

base-resolver

require("base-resolver")(configPathOrArray, basePath) → {external:q}

This function configures the resolver. This function takes two parameters and creates a configuration object that is used to load the starting modules.

Parameters:
Name Type Argument Description
configPathOrArray string | Array.<(module:base-resolver~Configuration|string)>

If this parameter is a string, requiring the string path should return the config array. We try to require the configPath directly. If that fails, it is joined with the current working directory of the process for resolution. The config array itself can also be passed instead of passing a configPath. if config array element is a string, it is assumed to be the path of the module:base-resolver~Configuration object, with all other properties defaulted.

basePath string <optional>

basePath is an optional parameter which provides the absolute path from where the components should be resolved. If basePath is not provided, it is resolved as follows:

  • if the first parameter is a configPath string, the basePath is assumed to be the configPath
  • if the first parameter is a not a configPath string, the basePath is assumed to be the current working directory for the process
Source:
Returns:

a Promise that gets resolved with module:base-resolver~Resolver when the resolver is set up. This promise is rejected with the error if the resolver set-up fails.

Type
external:q

The base.resolver component provides inversion of control and dependency injection api for running of zest infrastructure components. Using resolver, you set up a simple configuration and tell resolver which components you want to load. Each component registers itself with resolver, so other components can use its functions. Components can be maintained as NPM packages so they can be dropped in to other zest integrations. Simple components can also just be a file that can be required from node. (A javascript file or even a JSON file)

Source:

Requires

Namespaces

Resolver

Type Definitions

Configuration

An array of Configuration object is passed to configure resolver

Type:
  • object
Properties:
Name Type Argument Description
path string

specifies the path of the component

  • if path does not start with a ., or does not contain / the component is assumed to be an npm module
  • if path does not start with a ., and has a single /, the component is assumed to be a git repository
  • in all other cases, the component is assumed to be located at the path specified in the local disk.
options * <optional>

the options to be passed to instantiate the component. - The Parameter Modifier can be used here using the {param-number} format - The | (OR modifier) can also be used to gracefully degrade to defaults (explained in the example below) - If #, | or / are to be used as literals in option, they must be escaped by a /. Eg. /# will translate to a single #

startup boolean <optional>

startup is optional and is used to specify if a component is a starting component.

native boolean <optional>

is optional and is used to mark a component as native nodejs module.

  • Native modules are nodejs modules that are not compliant to the zest component structure
  • When a component is marked as native, no dependency will be injected in it
  • A native component can be injected into another component by its module name (as specified in package.json file
  • If no package.json file is found, or if no name is there in package.json, the native component will be named as the last part of the path in configuration excluding extension.
Source: