lib/middleware.js
function projectProvider(req, res, next) {
  var project = req.project;

  req.providerConfig = function (config, next) {
    if (arguments.length === 0) {
      return project.provider.config;
    }

    project.provider.config = config;
    project.markModified('provider');
    project.save(next);
  };
  // make this conditional?
  if (project.provider.account) {
    var account = project.creator.account(project.provider.id, project.provider.account);

    req.accountConfig = function (config, next) {
      if (arguments.length === 0) {
        return account.config;
      }

      account.config = config;
      project.creator.markModified('accounts');
      project.creator.save(next);
    };
  }

  next();
}
function projectProvider(req, res, next) {
  var project = req.project;

  req.providerConfig = function (config, next) {
    if (arguments.length === 0) {
      return project.provider.config;
    }

    project.provider.config = config;
    project.markModified('provider');
    project.save(next);
  };
  // make this conditional?
  if (project.provider.account) {
    var account = project.creator.account(project.provider.id, project.provider.account);

    req.accountConfig = function (config, next) {
      if (arguments.length === 0) {
        return account.config;
      }

      account.config = config;
      project.creator.markModified('accounts');
      project.creator.save(next);
    };
  }

  next();
}
Create helper function to get or set the provifer config. Expects req.project `req.providerConfig` function providerConfig() -> return the config providerConfig(config, next(err)). save the config  For hosted providers, the following function is also available accountConfig() -> return the account confi acountConfig(config, next(err)). save the account config