Files
RSSHub/lib/routes/github/pulls.js
Hash Lin 6410c2f876 add Github Pull requests rss feed (#1549)
add Github pull requests rss feed with `github/pull/{user}/{repo}` this pattern
2019-02-19 11:30:13 +08:00

35 lines
953 B
JavaScript

const axios = require('../../utils/axios');
const config = require('../../config');
const md = require('markdown-it')({
html: true,
});
module.exports = async (ctx) => {
const user = ctx.params.user;
const repo = ctx.params.repo;
const host = `https://github.com/${user}/${repo}/pull`;
const url = `https://api.github.com/repos/${user}/${repo}/pulls`;
const response = await axios({
method: 'get',
url,
params: {
sort: 'created',
access_token: config.github.access_token,
},
});
const data = response.data;
ctx.state.data = {
title: `${user}/${repo} Pull requests`,
link: host,
item: data.map((item) => ({
title: item.title,
description: md.render(item.body) || 'No description',
pubDate: new Date(item.created_at).toUTCString(),
link: `${host}/${item.number}`,
})),
};
};