{"size": 851, "ext": "js", "max_stars_repo_path": "src/controllers/partnerController.js", "max_stars_repo_name": "sophiemoustard/alenvi-api", "max_stars_repo_stars_event_min_datetime": "2019-01-03T14:21:13.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-03T14:21:13.000Z", "max_issues_repo_path": "src/controllers/partnerController.js", "max_issues_repo_name": "sophiemoustard/alenvi-api", "max_issues_repo_issues_event_min_datetime": "2019-06-12T07:14:45.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-19T12:52:05.000Z", "max_forks_repo_path": "src/controllers/partnerController.js", "max_forks_repo_name": "hofman-p/alenvi-api", "max_forks_repo_forks_event_min_datetime": "2021-03-31T07:13:44.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-31T07:13:44.000Z"}
{"max_stars_count": 1, "max_issues_count": 79, "max_forks_count": 1, "avg_line_length": 26.59375, "max_line_length": 106, "alphanum_fraction": 0.6486486486}
const Boom = require('@hapi/boom');
const translate = require('../helpers/translate');
const PartnersHelper = require('../helpers/partners');

const { language } = translate;

const list = async (req) => {
  try {
    const partners = await PartnersHelper.list(req.auth.credentials);

    return {
      message: partners.length ? translate[language].partnersFound : translate[language].partnersNotFound,
      data: { partners },
    };
  } catch (e) {
    req.log('error', e);
    return Boom.isBoom(e) ? e : Boom.badImplementation(e);
  }
};
const update = async (req) => {
  try {
    await PartnersHelper.update(req.params._id, req.payload);

    return { message: translate[language].partnerUpdated };
  } catch (e) {
    req.log('error', e);
    return Boom.isBoom(e) ? e : Boom.badImplementation(e);
  }
};

module.exports = { list, update };
