{"size": 1000, "ext": "js", "max_stars_repo_path": "refresh-token/src/mock/test.js", "max_stars_repo_name": "ZhangZhongren/demo-project", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "refresh-token/src/mock/test.js", "max_issues_repo_name": "ZhangZhongren/demo-project", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "refresh-token/src/mock/test.js", "max_forks_repo_name": "ZhangZhongren/demo-project", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 17.8571428571, "max_line_length": 55, "alphanum_fraction": 0.545}
/* eslint-disable no-debugger */
let token = '000000000'
let refresh_token = '111111111'



export const login = () => {
  setTimeout(() => {
    token = new Date().getTime().toString()
  }, 3000)
  return {
    code: 'success',
    data: {
      token: token,
      refresh_token: refresh_token
    }
  }
}

export const refresh = ({ body }) => {
  const _refresh_token = JSON.parse(body).refresh_token
  if (_refresh_token === refresh_token) {
    refresh_token = new Date().getTime().toString()
    return {
      code: 'success',
      data: {
        token: token,
        refresh_token: refresh_token
      }
    }
  } else {
    return {
      code: 'CODE_LOGGED_OTHER',
      data: null
    }
  }
}

export const data = (data) => {
  const { body } = data
  const _token = JSON.parse(body).token
  if (_token === token) {
    return {
      code: 'success',
      data: {
        a: '111'
      }
    }
  } else {
    return {
      code: 'CODE_TOKEN_EXPIRED',
      data: null
    }
  }
  
}