mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
Add GitHub branches (#1969)
This commit is contained in:
25
lib/routes/github/branches.js
Normal file
25
lib/routes/github/branches.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const axios = require('../../utils/axios');
|
||||
|
||||
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 axios({
|
||||
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}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user