import { Meteor } from 'meteor/meteor';
import { ServiceConfiguration } from 'meteor/service-configuration';

const externalServices = Meteor.settings.private.externalServices;

if (externalServices) {
  Object.keys(externalServices).forEach((service) => {
    ServiceConfiguration.configurations.upsert(
      { service },
      { $set: externalServices[service] },
    );
  });
}

import { Meteor } from 'meteor/meteor';
import { ServiceConfiguration } from 'meteor/service-configuration';

const externalServices = Meteor.settings.private.externalServices;

if (externalServices) {
  Object.keys(externalServices).forEach((service) => {
    if (externalServices[service].clientId !== '' || externalServices[service].secret !== '') {
      ServiceConfiguration.configurations.upsert(
        { service },
        { $set: externalServices[service] },
      );
    }
  });
}

Update startup server accounts externalServices, with checks before upsert service configuration