mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-18 22:33:26 +08:00
rss: add GitHub (#211)
* rss: add GitHub * rss: update github access_token config. * rss: update github router verify.
This commit is contained in:
36
routes/github/repos.js
Normal file
36
routes/github/repos.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const user = ctx.params.user;
|
||||
const uri = `https://api.github.com/users/${user}/repos` + `?access_token=${config.github.access_token}`;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: uri,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
Referer: uri,
|
||||
},
|
||||
});
|
||||
const data = response.data;
|
||||
ctx.state.data = {
|
||||
title: `GitHub Repos By ${user}`,
|
||||
link: uri,
|
||||
description: `GitHub Repos By ${user}`,
|
||||
item:
|
||||
data &&
|
||||
data.map((item) => {
|
||||
let repoDescription = item.description;
|
||||
if (repoDescription === null) {
|
||||
repoDescription = 'No description added';
|
||||
}
|
||||
return {
|
||||
title: `${item.name}`,
|
||||
guid: `${item.id}`,
|
||||
description: `${repoDescription}`,
|
||||
link: `${item.url}`,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user