validateStar.js 595 B

123456789101112131415161718192021222324252627282930
  1. async function validateStar(username) {
  2. try {
  3. const response = await fetch(`https://api.github.com/users/${username}/starred`);
  4. if (response.ok) {
  5. const data = await response.json();
  6. const hasStarred = data.some(repo => repo.name === 'cursor-auto-free');
  7. return {
  8. code: 0,
  9. hasStarred
  10. };
  11. }
  12. return {
  13. code: -1,
  14. error: `验证star失败: ${response.status}`
  15. };
  16. } catch (error) {
  17. return {
  18. code: -1,
  19. error: `请求出错: ${error.message}`
  20. };
  21. }
  22. }
  23. module.exports = {
  24. validateStar
  25. };