MCPcopy Create free account
hub / github.com/DIYgod/RSSHub / handler

Function handler

lib/routes/github/pulls.ts:59–97  ·  view source on GitHub ↗
(ctx)

Source from the content-addressed store, hash-verified

57};
58
59async function handler(ctx) {
60 const user = ctx.req.param('user');
61 const repo = ctx.req.param('repo');
62 const state = ctx.req.param('state') ?? 'open';
63 const labels = ctx.req.param('labels');
64
65 const host = `https://github.com/${user}/${repo}/pulls`;
66 const url = `https://api.github.com/repos/${user}/${repo}/issues`; // every PR is also an issue
67
68 const headers = { Accept: 'application/vnd.github.v3+json' };
69 if (config.github && config.github.access_token) {
70 headers.Authorization = `token ${config.github.access_token}`;
71 }
72 const limit = ctx.req.query('limit');
73 const response = await ofetch(url, {
74 query: {
75 state,
76 labels,
77 sort: 'created',
78 direction: 'desc',
79 per_page: limit ? Number.parseInt(limit) : 100,
80 },
81 headers,
82 });
83 const data = response.filter((item) => item.pull_request);
84
85 return {
86 allowEmpty: true,
87 title: `${user}/${repo} ${state.replace(/^\S/, (s) => s.toUpperCase())} Pull Requests${labels ? ' - ' + labels : ''}`,
88 link: host,
89 item: data.map((item) => ({
90 title: item.title,
91 author: item.user.login,
92 description: item.body ? md.render(item.body) : 'No description',
93 pubDate: parseDate(item.created_at),
94 link: item.html_url,
95 })),
96 };
97}

Callers

nothing calls this directly

Calls 1

parseDateFunction · 0.90

Tested by

no test coverage detected