Plugin

This is the mother of all plugin classes. All Bajo plugin classess inherit from this class respectfully.

There are currently only two main plugins available:

  • Bajo - Core plugin class, responsible for system wide setup and boot process. You should not touch this obviously
  • Base - Base plugin class your own plugin should extend from

Constructor

new Plugin(pkgName, app)

Parameters:
NameTypeDescription
pkgNamestring

Package name (the one you use in package.json)

appObject

App instance reference. Usefull to call app method inside a plugin

Members

alias :string

Getter for plugin's alias

Type:
  • string

app :Object

Reference to app instance

Type:
  • Object

config :Object

Config object

Type:
  • Object
See
  • config

log :Log

Shortcut to App#log with prefix parameter set to this plugin name.

Type:

ns :string

Getter for plugin's ns

Type:
  • string

pkgName :string

Getter for plugin's package name

Type:
  • string

t

Translate text and interpolate with given args.

Shortcut to App#t with ns parameter set to this plugin namespace.

(static, readonly) alias :string

Plugin alias. Derived plugin must provide its own, unique alias. If it left blank, Bajo will provide this automatically (by using the kebab-cased version of plugin name)

Type:
  • string

(static, constant) ns :string

Namespace (ns) or plugin's name. Simply the camel cased version of plugin's package name

Type:
  • string

(static, constant) pkgName :string

Package name, the one from package.json

Type:
  • string

Methods

error(msg, …argsopt) → {Object}

Create an instance of Err object

Parameters:
NameTypeAttributesDescription
msgmsg

Error message

argsany<optional>
<repeatable>

Argument variables you might want to add to the error object

Returns:

Err instance

Type: 
Object

fatal(msg, …argsopt)

Create an instance of Err object, display it on screen and then force terminate the app process

Parameters:
NameTypeAttributesDescription
msgmsg

Error message

argsany<optional>
<repeatable>

Argument variables you might want to add to the error object

getConfig(pathopt, optionsopt) → {Object}

Get plugin's config value

Parameters:
NameTypeAttributesDefaultDescription
pathstring<optional>

dot separated config path (think of lodash's 'get'). If not provided, the full config will be given

optionsObject<optional>
{}

Options

Properties
NameTypeAttributesDefaultDescription
defValueany<optional>
{}

Default value to use if returned object is undefined

omitArray.<string><optional>
[]

Omit these keys from returned object

noCloneboolean<optional>
false

Set true to NOT clone returned object

Returns:

Returned object. If no path provided, the whole config object is returned

Type: 
Object