{"size": 834, "ext": "js", "max_stars_repo_path": "api/views.js", "max_stars_repo_name": "lonelyion/bilibili-stats-badge", "max_stars_repo_stars_event_min_datetime": "2021-07-31T18:34:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-01T01:54:02.000Z", "max_issues_repo_path": "api/views.js", "max_issues_repo_name": "lonelyion/bilibili-stats-badges", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "api/views.js", "max_forks_repo_name": "lonelyion/bilibili-stats-badges", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 13, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.0625, "max_line_length": 63, "alphanum_fraction": 0.6294964029}
const utils = require('../src/utils');
const constructor = require('../src/badge_constructor');

let defaults = {
  color: 'blue',
  logo_color: '00A1D6',
  style: 'flat-square',
  format: 'none',
  label: 'Bilibili 播放数',
  label_color: 'grey',
  uid: '7564991'
}

module.exports = (req, res) => {
  switch(req.query.type) {
    case 'likes':
      defaults.label = 'Bilibili 获赞数'; break;
    case 'article':
      defaults.label = 'Bilibili 阅读数'; break;
    default:
      defaults.label = 'Bilibili 播放数';
  }
  
  utils.fetch_upstat(req.query.uid, req.query.type)
  .then(count => {
    req.query.content = count;
    let svg = constructor.get_shields_svg(req.query, defaults);
      res.setHeader('Content-Type', 'image/svg+xml');
      res.setHeader('Cache-Control', 'max-age=900, public');
      res.status(200).send(svg);
  })
}