0.2.5 • Published 8 years ago

comcom v0.2.5

Weekly downloads
3
License
AGPL-3.0
Repository
github
Last release
8 years ago

Complyify Commons for Javscript

Module containing common classes and helper functions for Javascript/Node.js applications.

Code Climate Test Coverage

Installation

npm install comcom --save

Building

This module is written in ES6 but can be compiled to ES5 with Babel for wider compatibility.

npm run compile

Ensure you run the compile command after running npm install which will load Babel and other development dependancies.

Getting Started

Simply import or require one or more classes from this module to make them available in your code.

ES6

import { SomeClass } from 'comcom';

ES5

var SomeClass = require('comcom').SomeClass;

API Reference

Classes

Configurable

A class that defines an object that must have a config object as a local property.

Constructor

var name = 'SomeName';
var type = 'SomeType';
var config = { configKey: 'someValue' };
var configurable = new Configurable(name, type, config);
ParameterDescriptionConstraints
nameuser-friendly name for the configurable object, mostly for showing in logsmust not be undefined, null, nor an empty string
typeuser-friendly type for the configurable object, mostly for show in logsmust not be undefined, null, nor an empty string
configinstance configuration objectmust be an object or undefined/null

Executable

A class designed to provide the scaffolding for an asynchronous job.

Constructor

var name = 'SomeName';
var config = { configKey: 'someValue' };
var log = bunyan.createLogger({name: 'myAppName'});
var executable = new Executable(name, config, log);
ParameterDescriptionConstraints
nameuser-friendly name for the executable, mostly for showing in logsmust not be undefined, null, nor an empty string
configinstance configuration objectmust be an object or undefined/null
loga Bunyan logger objectrequired

Methods

MethodDescriptionReturns
exec()Runs the executable by calling the implementing class' execImpl() methoda promise that resolves to the eventual returned value of execImpl()

Named

A class that defines an object that must have name as a local property.

Constructor

var name = 'SomeName';
var named = new Named(name);
ParameterDescriptionConstraints
nameuser-friendly name for the object, mostly for showing in logsmust not be undefined, null, nor an empty string

NamedTyped

A class that defines an object that must have name and type as local properties.

Constructor

var name = 'SomeName';
var type = 'SomeType';
var namedTyped = new NamedTyped(name, type);
ParameterDescriptionConstraints
nameuser-friendly name for the object, mostly for showing in logsmust not be undefined, null, nor an empty string
typeuser-friendly type for the object, mostly for show in logsmust not be undefined, null, nor an empty string

Service

A class designed to provide the scaffolding for a persistent service or daemon.

Usage

const NAME = 'SomeName';
const CONFIG = { configKey: 'someValue' };
const LOG = bunyan.createLogger({name: 'myAppName'});
let MyService = class extends Service {
  constructor() {
    super(NAME, CONFIG, LOG);
  }
}
let svc = new MyService();
svc.start();
ParameterDescriptionConstraints
nameuser-friendly name for the service, mostly for showing in logsmust not be undefined, null, nor an empty string
configinstance configuration objectmust be an object or undefined/null
loga Bunyan logger objectrequired

Methods

MethodDescriptionReturns
start()Starts the service by calling the implementing class' startImpl() methoda promise that resolves when startup is complete
stop()Stops the service by calling the implementing class' stopImpl() methoda promise that resolves when shutdown is complete
restart()Convenience method to call stop(), wait for completion, then call start()a promise that resolves upon completion of the restart
use()Register a service adapter or command/query/event handlerundefined

License

This module is made available under the terms of the GNU Affero General Public License v3.0 (see LICENSE).

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago