module.exports.respond = function()

in source/services/anomaly/lib/index.js [23:50]


module.exports.respond = function(event, cb) {

    let _anomaly = new Anomaly();
    let _message = {};

    if (typeof event === 'object') {
        _message = event;
    } else {
        _message = JSON.parse(event);
    }

    if (event.action) {

    } else {
        let payload = new Buffer(event.Records[0].kinesis.data, 'base64').toString('ascii');
        console.log('Decoded payload:', payload);
        let _record = JSON.parse(payload);
        // identify message as dtc object to be created from IoT platform
        _anomaly.createAnomaly(_record, function(err, data) {
            if (err) {
                return cb(err, null);
            }

            return cb(null, data);
        });
    }

};