mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 10:38:03 +08:00
* Fix(route): fix route parameter conflict at trending.js and change to V2 * Fix(route): modify the judgment condition of language parameter * Fix(docs): Update docs/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Fix(docs): Update docs/en/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(docs/route): add author and sort routes * Fix(route): Update docs/en/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Fix(route): sort routes Co-authored-by: Tony <TonyRL@users.noreply.github.com>
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
const got = require('@/utils/got');
|
|
const config = require('@/config').value;
|
|
const md = require('markdown-it')({
|
|
html: true,
|
|
linkify: true,
|
|
});
|
|
const queryString = require('query-string');
|
|
|
|
module.exports = async (ctx) => {
|
|
const user = ctx.params.user;
|
|
const repo = ctx.params.repo;
|
|
|
|
const host = `https://github.com/${user}/${repo}/pulls`;
|
|
const link = `https://github.com/${user}/${repo}/pull`;
|
|
const url = `https://api.github.com/repos/${user}/${repo}/pulls`;
|
|
|
|
const headers = {};
|
|
if (config.github && config.github.access_token) {
|
|
headers.Authorization = `token ${config.github.access_token}`;
|
|
}
|
|
const response = await got({
|
|
method: 'get',
|
|
url,
|
|
searchParams: queryString.stringify({
|
|
sort: 'created',
|
|
}),
|
|
headers,
|
|
});
|
|
const data = response.data;
|
|
|
|
ctx.state.data = {
|
|
allowEmpty: true,
|
|
title: `${user}/${repo} Pull requests`,
|
|
link: host,
|
|
item: data.map((item) => ({
|
|
title: item.title,
|
|
author: item.user.login,
|
|
description: item.body ? md.render(item.body) : 'No description',
|
|
pubDate: new Date(item.created_at).toUTCString(),
|
|
link: `${link}/${item.number}`,
|
|
})),
|
|
};
|
|
};
|