Application

Application constructor.

Options is an object that should contain a config object holding the configuration that will be used to configure all modules.

The application instance will extend itself with the options object, meaning that we can override any functions available in the Application prototype or add new functions which will be available in the instance.

new Application(options: Object)

Extends EventEmitter

Parameters
options (Object)
Static Members
loadConfig(options, asObject)
chainEvents
hook
getLogger(name, config)
restoreNativeConsole()
Instance Members
environment
logger
getLogger(name)
autorun
autoinitialize
autoloadModulesCommands
name
exitOnError
enableLongStackTrackes
sanitizeName
registerReadyEvent
coremodules
basepath
loaders
resolveTimeout
registerTimeout
config
registration
init(options)
register(instance, name)
provide(attr, extension)
isModuleRegistered(name)
onceRegistered(id, handler)
onErrorHandler(critical, message, err)
handleModuleError(moduleId, err)
loadDirectory(dir, options)
loadModules(dir, options)
loadCommands(dir, options)
loadModuleCommands(modulePathOrId)
resolve(id, ignoreUndefinedIds)
run()
registerApplication(register)
deregisterApplication()
command(eventType, handler, unique)
close(code, label)
nicename

core/logger

core/logger
Static Members
config
afterSolver(config)
new Filter(config)
Logger()
init(app, config)
enforceColumnWidth(message, length)
new Message()
muteConsole(context, config)
exports(app, config)

core/dispatcher

core/dispatcher
Static Members
init(context, config)
createHook(emitter, config)
createHook
chainEvents(emitter)
chainEvents

emit

emit

Gioc

Gioc constructor.

new Gioc(config: Object)
Parameters
config (Object) Optional config object.
Instance Members
configure(config)
map(beanId, context, config)
solve(beanId, options)
prepare(beanId, target, config, options)
build(beanId, options)
wire(beanId, target, config)
inject(beanId, scope, options)
post(beanId, target, options)
mapped(beanId)
solveDependencies(beanId, scope, mappings)
error(beanId, message)
addSolver(beanId, solver)
addPost(processor)
extend(beanId, target, options, config)
logger

mute

mute(names: String): this
Parameters
names (String) A list of names to mute
Returns
this:
Example
`context.getLogger('core').mute('commands', 'modules');`

unmute

Un-mute previously mute'd logger instances.

unmute(names: String): this
Parameters
names (String) A list of names of loggers
Returns
this:

silence

Silence a given Logger instance.

silence(name: String, silent: Boolean)
Parameters
name (String) Logger instance name
silent (Boolean = true)

Application/Logger

Application/Logger

Application/Logger

Application/Logger

setColorizer

setColorizer(colorizer: Colorizer): Message
Parameters
colorizer (Colorizer)
Returns
Message: Return instance

setColors

This takes a configuration object like Winston's colors object.

setColors(colors: Object)
Parameters
colors (Object)

setTime

setTime(timestamp: (boolean | function)): Message
Parameters
timestamp ((boolean | function))
Returns
Message:

setLabel

setLabel(label: (string | undefined)): Message
Parameters
label ((string | undefined))
Returns
Message:

setLevel

setLevel(level: (string | undefined)): Message
Parameters
level ((string | undefined))
Returns
Message:

setFrom

setFrom(from: (string | undefined)): Message
Parameters
from ((string | undefined))
Returns
Message:

setMessage

Set the message of this instance.

setMessage(message: String): this
Parameters
message (String) String to output
Returns
this:

wrapper

filters: used to meddle with the content string, e.g.

logger.info('User id: 423423 pass: ahdaljwer') =>

info: User id: 4...23 pass: ahd.....r

rewriters: used to format metadata:

logger.info('transaction ok', {__meta__: {creditCard: 123456789012345}})

info: transaction ok creditCard=123456****2345

wrapper(logger: core/Logger)
Parameters
logger (core/Logger) Logger instance

collectDirectory

Collect files in a directory.

collectDirectory(match: String, options: Object): void
Parameters
match (String) glob pattern
options (Object) Options object
Returns
void:

require

Require module

require(path: String, id: String): Object
Parameters
path (String) Path to module
id (String) Module id
Returns
Object:

CareTaker

Manages a program life-cycle.

  • raise
  • check
  • terminate

set timeout. If we do not get new content after this period of time, we consider the system wonked

TODO: Make CLI helper program

new CareTaker(options: Object)
Parameters
options (Object) Config object
Instance Members
startup()
check(data)

Serene

TODO: Move to it's own package. Require inside errors core module.

Serene, graceful and controlled shutdowns.

http://joseoncode.com/2014/07/21/graceful-shutdown-in-node-dot-js/

Process managers usually will send first a SIGTERM and wait 10* seconds, if the process is still running a SIGKILL gets sent.

upstart: SIGTERM - 5 secs - SIGKILL runit: SIGTERM - 10 secs - SIGKILL heroku: SIGTERM - 10 secs - SIGKILL docker: SIGTERM - 10 secs - SIGKILL supervisord: SIGTERM - 10 secs - SIGKILL

new Serene(config: Object)
Parameters
config (Object) Config object

core/repl

The repl module provides a REPL interface to your Application instance.

core/repl
Static Members
init(context, config)

on

the application context changed, we should reload the connection.

There should be a repl command to reload/refresh the connection.

on

core/utils

Module holding different utilities.

core/utils
Static Members
makeExcludeFilterFromWantList(options)
sanitizeName(name)
getModuleName(file)
getPathToMain()
getListenerCount(emitter, type)
normalizeCommandObject(command, config)

CommandLike

Anything that can be executed.

CommandLike

Type: (Function | Class | Command)

getUid

Generate an unique identifier in the form or: "jce1t9gu-sg69zzohk7"

getUid(len: Number): String
Parameters
len (Number = 20) Output length
Returns
String: