mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 18:18:06 +08:00
fix(route): github pulls labels (#10682)
fix(route): github pulls labels
This commit is contained in:
@@ -4,33 +4,32 @@ const md = require('markdown-it')({
|
||||
html: true,
|
||||
linkify: true,
|
||||
});
|
||||
const queryString = require('query-string');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const user = ctx.params.user;
|
||||
const repo = ctx.params.repo;
|
||||
const state = ctx.params.state ?? 'open';
|
||||
const labels = ctx.params.labels;
|
||||
|
||||
const host = `https://github.com/${user}/${repo}/pulls`;
|
||||
const url = `https://api.github.com/repos/${user}/${repo}/pulls`;
|
||||
const url = `https://api.github.com/repos/${user}/${repo}/issues`; // every PR is also an issue
|
||||
|
||||
const headers = { Accept: 'application/vnd.github.v3+json' };
|
||||
if (config.github && config.github.access_token) {
|
||||
headers.Authorization = `token ${config.github.access_token}`;
|
||||
}
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
searchParams: queryString.stringify({
|
||||
const response = await got(url, {
|
||||
searchParams: {
|
||||
state,
|
||||
labels,
|
||||
sort: 'created',
|
||||
direction: 'desc',
|
||||
per_page: ctx.query.limit ? (parseInt(ctx.query.limit) <= 100 ? parseInt(ctx.query.limit) : 100) : 100,
|
||||
}),
|
||||
},
|
||||
headers,
|
||||
});
|
||||
const data = response.data;
|
||||
const data = response.data.filter((item) => item.pull_request);
|
||||
|
||||
ctx.state.data = {
|
||||
allowEmpty: true,
|
||||
|
||||
Reference in New Issue
Block a user