mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 18:18:06 +08:00
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
const got = require('@/utils/got');
|
|
const config = require('@/config').value;
|
|
|
|
module.exports = async (ctx) => {
|
|
if (!config.github || !config.github.access_token) {
|
|
throw 'GitHub follower RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
|
|
}
|
|
const user = ctx.params.user;
|
|
|
|
const host = `https://github.com/${user}`;
|
|
const url = 'https://api.github.com/graphql';
|
|
|
|
const response = await got({
|
|
method: 'post',
|
|
url,
|
|
headers: {
|
|
Authorization: `bearer ${config.github.access_token}`,
|
|
},
|
|
json: {
|
|
query: `
|
|
{
|
|
user(login: "${user}") {
|
|
followers(first: 10) {
|
|
edges {
|
|
node {
|
|
login
|
|
avatarUrl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
},
|
|
});
|
|
|
|
const data = response.data.data.user.followers.edges;
|
|
|
|
ctx.state.data = {
|
|
allowEmpty: true,
|
|
title: `${user}'s followers`,
|
|
link: host,
|
|
item: data.map((follower) => ({
|
|
title: `${follower.node.login} started following ${user}`,
|
|
author: follower.node.login,
|
|
description: `<a href="https://github.com/${follower.node.login}">${follower.node.login}</a> <br> <img sytle="width:50px;" src='${follower.node.avatarUrl}'>`,
|
|
link: `https://github.com/${follower.node.login}`,
|
|
})),
|
|
};
|
|
};
|