Interface

Server.Modules.Core. Interface

# new Interface(name)

This class provides a base class for all interfaces to inherit from. It contains common methods that all interfaces inherit. It is only accessible from within the Application Server, or where Blackrock is accessed as a Dependency.

Interfaces allow Blackrock to "talk" in the language of difference communications protocols. Amongst these are HTTP(S), WebSockets, Axon, NanoMSG, SSH and ZeroMQ. This gives you the freedom to design the best service architecture for your business - whether that be a single monolith, or a collection of microservices - which you may own all of, or may own a few - perhaps subscribing to cloud versions of some of these services (Identity would be a good example).

Parameters:
Name Type Description
name string

The name of the interface being instantiated

Example
const superInterface = new core.Mod('SuperInterface');

Extends

Methods

# (static) get(name) → {object}

This method returns the requested instance from an interface.

Parameters:
Name Type Description
name string

Instance Name

Returns:

instance - The Requested Instance

Type
object
Example
// Returns an instance from an interface:
require('is-blackrock').init()
  .then(function(core) {
    const httpInterface = core.module('http', 'interface');
    const instance = httpInterface.get('default');
  });

# (static) list() → {array}

This method returns a list of available instances for an interface.

Returns:

instances - A List of Instances

Type
array
Example
// Returns a list of interface instances:
require('is-blackrock').init()
  .then(function(core) {
    const httpInterface = core.module('http', 'interface');
    const instanceList = httpInterface.list();
    console.log(instanceList)
    // Output: ['instance1', 'instance2', 'instance3']
  });