Skip to content

bixbyjs/bixby-common

Repository files navigation

bixby-common

Build Coverage Quality Dependencies

This suite of components provides the common objects typically needed by any Node.js application, including settings that can be tuned via configuration files and logging facilities for informational and error messages.

Install

$ npm install bixby-common

Usage

To utilize Bixby.js' common suite of components, register them with the IoC container.

IoC.use(require('bixby-common'));

Table of Contents

Components

Entity

exports['@require'] = [ 'entity' ];

The entity component provides a way to identify the application itself, including any optional aliases. This is typically utilized for security-related purposes where stable identifiers are crucial.

Settings

This component will read settings within the [entity] section.

  • {string} [id] - application identifier
  • {string[]} [aliases] - additional application aliases
[entity]
id = "https://api.example.com/beepboop/v1"
aliases = [ "@api.example.com", "https://api.example.com/bebop/" ]

Logger

exports['@require'] = [ 'logger' ];

The logger component provides a logger, powered by winston. Log transports and related options are configurable within the application's configuration file.

Settings

This component will read settings within the [logger] section.

  • {string} [level] - logging level
  • {string|string[]} [transport] - log transports
  • {string} [path] - path to log file

By default, the logger will use both "console" and "file" transports, with the following paths for log files:

  • Linux: /var/log/<package-name>.log
  • Mac OS X: ~/Library/Logs/<package-name>.log
[logger]
level = "debug"
transport = "console"
[logger]
transport = "file"
path = "/var/log/app.log"

Notifications

exports['@require'] = [ 'notifications' ];

The notifications component provides a shared notification center, powered by notifications. This is useful for broadcasting events within a process, allowing communication between fully decoupled subsystems.

Settings

exports['@require'] = [ 'settings' ];

The settings component provides a mechanism to configure an application via configuration files, powered by the decisions module. Configuration is preferably loaded from TOML files, though YAML and JSON are supported as well.

Tests

$ make test

License

The MIT License

Copyright (c) 2014 Jared Hanson <http://www.jaredhanson.net/>