Service

Extends

  • EventEmitter
Service.App
staticreadonly
Type:
App
Service.AppManager
staticreadonly
Type:
AppManager
appManager
readonly
Type:
AppManager
Service.AppStatus
staticreadonly
Type:
AppStatus
Service.common
staticreadonly
Type:
CommonList
config
readonly

see affiliated serviser-config npm package

Type:
Config
Service.error
staticreadonly
Type:
ErrorList
Service.moduleLoader
staticreadonly
Type:
ModuleLoader
Service.RemoteServiceManager
staticreadonly
remoteServiceManager
Service.RequestType
staticreadonly
Type:
RequestType
Service.ResourceManager
staticreadonly
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.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
Service.utils
staticreadonly
Type:
Utils
Service.VERSION
staticreadonly

serviser 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 serviser-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.js)

  • 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 serviser-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('serviser');
const service = new Service(require('serviser-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 serviser-shell plugin

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

static:app

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

Properties:
  • app
static:service

for serviser plugins.
emitted once for each instantiated Service object.

Properties:
Example:
const Service = require('serviser');

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

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

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

Example:
const Service = require('serviser');

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

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

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