counters.js 556 Bytes
'use strict';

const countersSdk = require('komodo-sdk/counters');

function increment(name, modemInfo) {
    if (!name || !modemInfo.imsi) return;

    countersSdk.increment(`IMSI_${modemInfo.IMSI}_${name}`);
}

function get(name, modemInfo) {
    return new Promise(async (resolve) => {
        if (!name || !modemInfo.imsi) {
            resolve(0);
            return;
        }

        const value = await countersSdk.get(`IMSI_${modemInfo.IMSI}_${name}`);
        resolve(Number(value));
    });
}

exports.get = get;
exports.increment = increment;