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
+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}`,
})),
};
};