lib/sync.js
function syncBatch(batch, cb) {
    if (batch && batch.length > 0) {
      var mbaasClient = new MBaaSClient(ENVIRONMENT, {
        url: URL.format(PROTOCOL + '://' + HOST),
        accessKey: ACCESS_KEY,
        project: PROJECT,
        app: GUID,
        appApiKey: API_KEY
      });
      // /api/app/:domain/:environment/:projectid/:appid/message/:topic with [] or messages for data (a batch)
      mbaasClient.app.message.sendbatch({
        'host': HOST,
        'environment': ENVIRONMENT,
        'domain': DOMAIN,
        'data': batch,
        'topic': 'fhact' //the only other topic is fhweb which is not longer used
      }, function(err) {
        if (err) {
          return cb(err, {message: 'Error sending message batch to MBaaS', host: HOST, environment: ENVIRONMENT, domain: DOMAIN, topic:'fhact', batch: batch});
        } else {
          return cb(undefined, {message: 'Batch sent to MBaaS'});
        }
      });
    } else {
      return cb(undefined, {message: 'Batch empty...nothing to sync at this time'});
    }
  }
function syncBatch(batch, cb) {
    if (batch && batch.length > 0) {
      var mbaasClient = new MBaaSClient(ENVIRONMENT, {
        url: URL.format(PROTOCOL + '://' + HOST),
        accessKey: ACCESS_KEY,
        project: PROJECT,
        app: GUID,
        appApiKey: API_KEY
      });
      // /api/app/:domain/:environment/:projectid/:appid/message/:topic with [] or messages for data (a batch)
      mbaasClient.app.message.sendbatch({
        'host': HOST,
        'environment': ENVIRONMENT,
        'domain': DOMAIN,
        'data': batch,
        'topic': 'fhact' //the only other topic is fhweb which is not longer used
      }, function(err) {
        if (err) {
          return cb(err, {message: 'Error sending message batch to MBaaS', host: HOST, environment: ENVIRONMENT, domain: DOMAIN, topic:'fhact', batch: batch});
        } else {
          return cb(undefined, {message: 'Batch sent to MBaaS'});
        }
      });
    } else {
      return cb(undefined, {message: 'Batch empty...nothing to sync at this time'});
    }
  }
function syncBatch ( batch , cb ) { if ( batch && batch . length > 0 ) { var mbaasClient = new MBaaSClient ( ENVIRONMENT , { url : URL . format ( PROTOCOL + '://' + HOST ) , accessKey : ACCESS_KEY , project : PROJECT , app : GUID , appApiKey : API_KEY } ) ; // /api/app/:domain/:environment/:projectid/:appid/message/:topic with [] or messages for data (a batch) mbaasClient . app . message . sendbatch ( { 'host' : HOST , 'environment' : ENVIRONMENT , 'domain' : DOMAIN , 'data' : batch , 'topic' : 'fhact' //the only other topic is fhweb which is not longer used } , function ( err ) { if ( err ) { return cb ( err , { message : 'Error sending message batch to MBaaS' , host : HOST , environment : ENVIRONMENT , domain : DOMAIN , topic : 'fhact' , batch : batch } ) ; } else { return cb ( undefined , { message : 'Batch sent to MBaaS' } ) ; } } ) ; } else { return cb ( undefined , { message : 'Batch empty...nothing to sync at this time' } ) ; } }
send data to fhmbaas
send data to fhmbaas