# 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).
Name | Type | Description |
---|---|---|
name |
string | The name of the interface being instantiated |
- Source:
const superInterface = new core.Mod('SuperInterface');
Extends
Methods
# (static) get(name) → {object}
This method returns the requested instance from an interface.
Name | Type | Description |
---|---|---|
name |
string | Instance Name |
- Source:
instance - The Requested Instance
- Type
- object
// 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.
- Source:
instances - A List of Instances
- Type
- array
// 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']
});