mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 10:08:02 +08:00
fix(route): github pull requests (#9341)
* fix(route): github pull * fix: typo
This commit is contained in:
@@ -141,7 +141,7 @@ For instance, the `/github/topics/framework/l=php&o=desc&s=stars` route will gen
|
|||||||
|
|
||||||
### Repo Pull Requests
|
### Repo Pull Requests
|
||||||
|
|
||||||
<RouteEn author="hashman" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo" :paramsDesc="['User name', 'Repo name']" radar="1" rssbud="1"/>
|
<RouteEn author="hashman TonyRL" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo/:state?" :paramsDesc="['User name', 'Repo name', 'the state of pull requests. Can be either `open`, `closed`, or `all`. Default: `open`.']" radar="1" rssbud="1"/>
|
||||||
|
|
||||||
### User Followers
|
### User Followers
|
||||||
|
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ GitHub 官方也提供了一些 RSS:
|
|||||||
|
|
||||||
### 仓库 Pull Requests
|
### 仓库 Pull Requests
|
||||||
|
|
||||||
<Route author="hashman" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo" :paramsDesc="['用户名', '仓库名']" radar="1" rssbud="1"/>
|
<Route author="hashman" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo/:state?" :paramsDesc="['用户名', '仓库名', 'pull request 状态,`open`,`closed`或`all`,默认为`open`']" radar="1" rssbud="1"/>
|
||||||
|
|
||||||
### 用户 Followers
|
### 用户 Followers
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module.exports = {
|
|||||||
'/contributors/:user/:repo/:order?/:anon?': ['zoenglinghou'],
|
'/contributors/:user/:repo/:order?/:anon?': ['zoenglinghou'],
|
||||||
'/file/:user/:repo/:branch/:filepath+': ['zengxs'],
|
'/file/:user/:repo/:branch/:filepath+': ['zengxs'],
|
||||||
'/issue/:user/:repo/:state?/:labels?': ['HenryQW', 'AndreyMZ'],
|
'/issue/:user/:repo/:state?/:labels?': ['HenryQW', 'AndreyMZ'],
|
||||||
'/pull/:user/:repo': ['hashman'],
|
'/pull/:user/:repo/:state?': ['hashman', 'TonyRL'],
|
||||||
'/repos/:user': ['DIYgod'],
|
'/repos/:user': ['DIYgod'],
|
||||||
'/search/:query/:sort?/:order?': ['LogicJake'],
|
'/search/:query/:sort?/:order?': ['LogicJake'],
|
||||||
'/starred_repos/:user': ['LanceZhu'],
|
'/starred_repos/:user': ['LanceZhu'],
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ const md = require('markdown-it')({
|
|||||||
linkify: true,
|
linkify: true,
|
||||||
});
|
});
|
||||||
const queryString = require('query-string');
|
const queryString = require('query-string');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
const user = ctx.params.user;
|
const user = ctx.params.user;
|
||||||
const repo = ctx.params.repo;
|
const repo = ctx.params.repo;
|
||||||
|
const state = ctx.params.state ?? 'open';
|
||||||
|
|
||||||
const host = `https://github.com/${user}/${repo}/pulls`;
|
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 url = `https://api.github.com/repos/${user}/${repo}/pulls`;
|
||||||
|
|
||||||
const headers = {};
|
const headers = {};
|
||||||
@@ -22,7 +23,10 @@ module.exports = async (ctx) => {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
url,
|
url,
|
||||||
searchParams: queryString.stringify({
|
searchParams: queryString.stringify({
|
||||||
|
state,
|
||||||
sort: 'created',
|
sort: 'created',
|
||||||
|
direction: 'desc',
|
||||||
|
per_page: ctx.query.limit ? (parseInt(ctx.query.limit) <= 100 ? parseInt(ctx.query.limit) : 100) : 100,
|
||||||
}),
|
}),
|
||||||
headers,
|
headers,
|
||||||
});
|
});
|
||||||
@@ -36,8 +40,8 @@ module.exports = async (ctx) => {
|
|||||||
title: item.title,
|
title: item.title,
|
||||||
author: item.user.login,
|
author: item.user.login,
|
||||||
description: item.body ? md.render(item.body) : 'No description',
|
description: item.body ? md.render(item.body) : 'No description',
|
||||||
pubDate: new Date(item.created_at).toUTCString(),
|
pubDate: parseDate(item.created_at),
|
||||||
link: `${link}/${item.number}`,
|
link: item.html_url,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module.exports = function (router) {
|
|||||||
router.get('/contributors/:user/:repo/:order?/:anon?', require('./contributors'));
|
router.get('/contributors/:user/:repo/:order?/:anon?', require('./contributors'));
|
||||||
router.get('/file/:user/:repo/:branch/:filepath+', require('./file'));
|
router.get('/file/:user/:repo/:branch/:filepath+', require('./file'));
|
||||||
router.get('/issue/:user/:repo/:state?/:labels?', require('./issue'));
|
router.get('/issue/:user/:repo/:state?/:labels?', require('./issue'));
|
||||||
router.get('/pull/:user/:repo', require('./pulls'));
|
router.get('/pull/:user/:repo/:state?', require('./pulls'));
|
||||||
router.get('/repos/:user', require('./repos'));
|
router.get('/repos/:user', require('./repos'));
|
||||||
router.get('/search/:query/:sort?/:order?', require('./search'));
|
router.get('/search/:query/:sort?/:order?', require('./search'));
|
||||||
router.get('/starred_repos/:user', require('./starred_repos'));
|
router.get('/starred_repos/:user', require('./starred_repos'));
|
||||||
|
|||||||
Reference in New Issue
Block a user