{"size": 1187, "ext": "js", "max_stars_repo_path": "src/models/settings.js", "max_stars_repo_name": "yury-dymov/redux-oauth", "max_stars_repo_stars_event_min_datetime": "2016-07-29T17:06:12.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-04T19:41:27.000Z", "max_issues_repo_path": "src/models/settings.js", "max_issues_repo_name": "yury-dymov/redux-oauth", "max_issues_repo_issues_event_min_datetime": "2016-09-09T00:51:59.000Z", "max_issues_repo_issues_event_max_datetime": "2017-09-13T20:44:22.000Z", "max_forks_repo_path": "src/models/settings.js", "max_forks_repo_name": "yury-dymov/redux-oauth", "max_forks_repo_forks_event_min_datetime": "2016-09-29T16:42:25.000Z", "max_forks_repo_forks_event_max_datetime": "2019-04-23T07:58:43.000Z"}
{"max_stars_count": 79, "max_issues_count": 10, "max_forks_count": 15, "avg_line_length": 27.6046511628, "max_line_length": 102, "alphanum_fraction": 0.647851727}
export function getSettings(state) {
  return {
    backend:        getBackend(state),
    cookieOptions:  cookieOptions(state),
    tokenFormat:    getTokenFormat(state)
  };
}

function getBackend(state) {
  const apiUrl = `${state.auth.getIn(['config', 'backend', 'apiUrl'])}`;
  const authProviderPaths = {};

  state.auth.getIn(['config', 'backend', 'authProviderPaths'])
    .forEach((path, key) => authProviderPaths[key] = `${apiUrl}${path}`);

  const signOutPart = state.auth.getIn(['config', 'backend', 'signOutPath']);

  const signOutPath = signOutPart ? `${apiUrl}${signOutPart}` : null;

  return {
    tokenValidationPath: `${apiUrl}${state.auth.getIn(['config', 'backend', 'tokenValidationPath'])}`,
    signOutPath,
    authProviderPaths,
    apiUrl
  };
}

function cookieOptions(state) {
  return {
    key:    state.auth.getIn(['config', 'cookieOptions', 'key']),
    expires: state.auth.getIn(['config', 'cookieOptions', 'expires']),
    path:   state.auth.getIn(['config', 'cookieOptions', 'path'])
  };
}

function getTokenFormat(state) {
  const ret = {};

  state.auth.getIn(['config', 'tokenFormat']).forEach((value, key) => ret[key] = value);

  return ret;
}
