Add GitHub Issue closes #351 (#445)

This commit is contained in:
Henry Wang
2018-08-13 00:59:04 +08:00
committed by DIYgod
parent 58ae45a4d5
commit 77fb8cb05a
4 changed files with 47 additions and 0 deletions
+2
View File
@@ -133,6 +133,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 分类
- GitHub
- 用户仓库
- Trending
- Issue
- Konachan.com Anime Wallpapers
- posts
- Popular Recent Posts
+9
View File
@@ -1165,6 +1165,15 @@ since,时间跨度,可在 [Trending 页](https://github.com/trending/javascr
language,语言,可在 [Trending 页](https://github.com/trending/javascript?since=monthly) URL 中找到
### Issue
举例: [https://rsshub.app/github/issue/DIYgod/RSSHub](https://rsshub.app/github/issue/DIYgod/RSSHub)
路由: `/github/issue/:user/:repo`
参数: user,用户名
参数: repo,仓库名
## 纽约时报
::: tip 提示
+1
View File
@@ -263,6 +263,7 @@ if (config.github && config.github.access_token) {
logger.warn('GitHub Repos RSS is disabled for lacking config.');
}
router.get('/github/trending/:since/:language?', require('./routes/github/trending'));
router.get('/github/issue/:user/:repo', require('./routes/github/issue'));
// konachan
router.get('/konachan/post', require('./routes/konachan/post'));
+35
View File
@@ -0,0 +1,35 @@
const axios = require('../../utils/axios');
const config = require('../../config');
module.exports = async (ctx) => {
const user = ctx.params.user;
const repo = ctx.params.repo;
const host = `https://github.com/repos/${user}/${repo}/issues`;
const url = `https://api.github.com/repos/${user}/${repo}/issues`;
const response = await axios({
method: 'get',
url,
headers: {
'User-Agent': config.ua,
},
params: {
sort: 'created',
access_token: config.github.access_token,
},
});
const data = response.data;
ctx.state.data = {
title: `${user}/${repo} Issues`,
link: host,
item:
data &&
data.map((item) => ({
title: item.title,
description: item.body || 'No description',
pubDate: new Date(item.created_at),
link: `${host}/${item.number}`,
})),
};
};