cti-checks-aggregator

1.0.2 • Public • Published

cti-checks-aggregator

Library to aggregate results/errors while performing checks

Usage

const ChecksAggregator = require( 'cti-checks-aggregator' );
const Promise = require( 'bluebird' );

const aggregator = new ChecksAggregator();

aggregator.addCheckResult( 'testTopic', 'testCheck1', true );
aggregator.addCheckResult( 'testTopic', 'testCheck2', true );

aggregator.addCheckResult( 'testTopic2', 'testCheck', false, { message: 'something went wrong' } );

const error = new Error( 'something went wrong' );
const operationalError = new Promise.OperationalError( error );
aggregator.addCheckResult( 'testTopic3', 'testCheck', false, operationalError );

console.log( aggregator.results );
/*
{
    testTopic: {
        testCheck1: true,
        testCheck2: true
    },
    testTopic2: {
        testCheck: false,
        testCheckError: {
            message: 'something went wrong'
        }
    },
    testTopic3: {
        testCheck: false,
        testCheckError: [Error: something went wrong]
    }
}
*/

console.log( aggregator.allSucceeded );
/* false */

Readme

Keywords

Package Sidebar

Install

npm i cti-checks-aggregator

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators

  • cantireinnovations