Service

Extends

  • EventEmitter
Service.App
staticreadonly
Type:
App
appManager
readonly
Type:
AppManager
Service.AppManager
staticreadonly
Type:
AppManager
Service.AppStatus
staticreadonly
Type:
AppStatus
cbModelManager

couchbase model manager. See affiliated kouchbase-odm npm package.
Mentioned purely because of convention. Not required. Populated by the user.

Type:
null or Object
Service.common
staticreadonly
Type:
CommonList
config
readonly

see affiliated bi-config npm package

Type:
Config
Service.error
staticreadonly
Type:
ErrorList
Service.moduleLoader
staticreadonly
Type:
ModuleLoader
Service.RemoteServiceManager
staticreadonly
remoteServiceManager
Service.RequestType
staticreadonly
Type:
RequestType
resourceManager
readonly

ResourceManager is used for any resource that can be inspected for its integrity eg. storage connections, remote dependent API services, config provider etc...

Service.ResourceManager
staticreadonly
Service.Response
staticreadonly
Type:
Response
Service.Route
staticreadonly
Type:
Route
Service.Router
staticreadonly
Type:
Router
Service.Service
staticreadonly

self reference

Type:
Service
Service
readonly

self reference

Type:
Service
sqlModelManager

may be any service specific model manager of ORM
Mentioned purely because of convention. Not required. Populated by the user.

Type:
null or Object
Service.utils
staticreadonly
Type:
Utils
Service.VERSION
staticreadonly

bi-service npm package version

Type:
String
new Service(config)

The main representation of a service as a whole. Holds AppManager, ResourceManager, RemoteServiceManager as well as global service configuration (Config) object. Optionally can hold references to Model managers of various ODMs/ORMs

Parameters:
  • config
    • Type: Config
    • npm bi-config object

Fires:
Service.onListening(app)
static

default app.on('listening') listener

Parameters:
  • app
Service.onPostInit(app)
static

default app.on('post-init') listener

Parameters:
  • app
buildApp(name, options, Constructor)AppInterface

syntax sugar for building an application (defaults to express based App) via AppManager

Parameters:
  • name
    • Type: String
    • application name as defined in apps.<name> of service configuration file (config.json5)

  • options optional
    • Type: Object
    • see App constructor options

  • Constructor optional
Returns: AppInterface
close()Promise

calls App#close on each App in the AppManager

Returns: Promise
getRemoteServiceManager()RemoteServiceManager

returns RemoteServiceManager or constructs one if there isn't any. This requires bi-service-sdk npm module to be available

Returns: RemoteServiceManager
listen()Promise<Service>
Returns: Promise<Service>
error

one of the registered apps failed to initialize

listening

all registered apps are successfully initialized and at this point already can receive connections

set-up

The event is emitted after service configuration and all registered resources are validated and ready for use.
Listeners are expected to do any initial asynchronous processing if needed and then register Apps with Router & Route definitions.
The listeners are handled asynchronously and so can deal with Promises

Example:
//$PROJECT_ROOT/index.js
const Service = require('bi-service');
const service = new Service(require('bi-config'));

service.once('set-up', function() {
    require('./lib/app.js');
});
shell-cmd

emitted once prior a shell command dispatching. Allows to register custom user-defined shell commands. See bi-service-shell plugin

Properties:
  • yargs
    • Type: Object
    • preconfigured instance of yargs npm package

static:app

for bi-service plugins emitted once for each acknowledged App by Service. The App is not necessarily initialized yet

Properties:
  • app
static:service

for bi-service plugins.
emitted once for each instantiated Service object.

Properties:
Example:
const Service = require('bi-service');

Service.on('service', function(service) {
    //do stuff
});
static:set-up

this event allows to hook-up bi-service plugins and is static version of Service#event:set-up event.

Properties:
  • config
    • Type: Config
    • service.config

Example:
const Service = require('bi-service');

Service.on('set-up', function(appManager, config) {
    //do stuff
});
static:shell-cmd

for bi-service plugins.
emitted once prior a shell command is dispatched. Allows to register custom user-defined shell commands. See bi-service-shell plugin

Properties:
  • yargs
    • Type: Object
comments powered by Disqus