API Docs for:
Show:

Facade Class

Facade class of DDD pattern.

  • create instance of factories
  • create instance of repositories

Methods

addClass

(
  • name
  • klass
  • skipNameValidation
)
Function private

add copied class to facade. the class is acquired by @require(name)

attaches getFacade() method (for both class and instance)

Parameters:

  • name String
  • klass Function
  • skipNameValidation Boolean

    validate class name is compatible with the name to register

Returns:

Function:

create

(
  • name
  • [options]
)
BaseFactory private

read a file and returns the instance of the file's class

Parameters:

  • name String
  • [options] Object optional

Returns:

createFactory

(
  • name
  • [useAnonymousWhenFailed=false]
)
BaseFactory

create a factory instance

Parameters:

  • name String
  • [useAnonymousWhenFailed=false] Boolean optional

Returns:

createInstance

(
  • [options]
)
Facade static

create instance of Facade

Parameters:

  • [options] Object optional

Returns:

createRepository

(
  • name
  • [options]
)
BaseRepository

create a repository instance

Parameters:

  • name String
  • [options] Object optional

Returns:

error

(
  • reason
  • [message]
)
Error

create instance of DomainError

Parameters:

  • reason String

    reason of the error

  • [message] String optional

Returns:

Error:

getFactory

(
  • name
  • [useAnonymousWhenFailed=false]
)
Function

get a factory class

ISSUE: user will never know load failure

Parameters:

  • name String
  • [useAnonymousWhenFailed=false] Boolean optional

Returns:

Function:

getModel

(
  • name
)
Class

get a model class

Parameters:

  • name String

Returns:

Class:

getRepository

(
  • name
)
Class

get a repository class

Parameters:

  • name String

Returns:

Class:

hasClass

(
  • name
)
Function

check existence of the class of the given name

Parameters:

  • name String

Returns:

Function:

insertFixtures

(
  • [options]
)
Promise(Object)

insert fixture data (Node.js only)

Parameters:

  • [options] Object optional
    • [dataDir='./data'] String optional

      directory to have fixture data files

    • [tsvDir='./tsv'] String optional

      directory to have TSV files

    • [models=null] Array(String) optional

      model names to insert. default: all models

Returns:

Promise(Object):

dataPool inserted data

isBaseClass

(
  • klass
)
Boolean static

check the given class is registered in facade

Parameters:

  • klass Function

Returns:

Boolean:

isDomainError

(
  • e
)
Boolean

check if given object is instance of DomainError

Parameters:

  • e Error

Returns:

Boolean:

loadMasterTables

() Promise

load master tables

Returns:

Promise:

registerBaseClass

(
  • klass
)
static

registers the given class as a base class

Parameters:

  • klass Function

require

(
  • name
)
Function private

read a file and returns class

Parameters:

  • name String

Returns:

Function: