Files
RSSHub/lib/routes/github/branches.js
2019-06-03 18:03:05 +08:00

26 lines
658 B
JavaScript

const got = require('@/utils/got');
module.exports = async (ctx) => {
const user = ctx.params.user;
const repo = ctx.params.repo;
const host = `https://github.com/${user}/${repo}`;
const url = `https://api.github.com/repos/${user}/${repo}/branches`;
const response = await got({
method: 'get',
url,
});
const data = response.data;
ctx.state.data = {
title: `${user}/${repo} Branches`,
link: `${host}/branches/all`,
item: data.map((item) => ({
title: item.name,
description: item.name,
link: `${host}/commits/${item.name}`,
})),
};
};