You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

31 lines
758 B

const axios = require('../axios.js')
const millify = require('millify')
module.exports = async (topic, namespace, name) => {
if (!['stars', 'pulls'].includes(topic)) {
return {
subject: 'docker',
status: 'unknown topic',
color: 'grey'
}
}
/* eslint-disable camelcase */
const endpoint = `https://hub.docker.com/v2/repositories/${namespace}/${name}`
const { pull_count, star_count } = await axios(endpoint).then(res => res.data)
switch (topic) {
case 'stars':
return {
subject: 'docker stars',
status: millify(star_count),
color: 'blue'
}
case 'pulls':
return {
subject: 'docker pulls',
status: millify(pull_count),
color: 'blue'
}
}
}