Advertisement
Guest User

Untitled

a guest
Jul 7th, 2021
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import fetch from 'node-fetch';
  2.  
  3. export interface Repos {
  4.     id:                number;
  5.     node_id:           string;
  6.     name:              string;
  7.     full_name:         string;
  8.     private:           boolean;
  9.     owner:             Owner;
  10.     html_url:          string;
  11.     description:       null | string;
  12.     fork:              boolean;
  13.     url:               string;
  14.     forks_url:         string;
  15.     keys_url:          string;
  16.     collaborators_url: string;
  17.     teams_url:         string;
  18.     hooks_url:         string;
  19.     issue_events_url:  string;
  20.     events_url:        string;
  21.     assignees_url:     string;
  22.     branches_url:      string;
  23.     tags_url:          string;
  24.     blobs_url:         string;
  25.     git_tags_url:      string;
  26.     git_refs_url:      string;
  27.     trees_url:         string;
  28.     statuses_url:      string;
  29.     languages_url:     string;
  30.     stargazers_url:    string;
  31.     contributors_url:  string;
  32.     subscribers_url:   string;
  33.     subscription_url:  string;
  34.     commits_url:       string;
  35.     git_commits_url:   string;
  36.     comments_url:      string;
  37.     issue_comment_url: string;
  38.     contents_url:      string;
  39.     compare_url:       string;
  40.     merges_url:        string;
  41.     archive_url:       string;
  42.     downloads_url:     string;
  43.     issues_url:        string;
  44.     pulls_url:         string;
  45.     milestones_url:    string;
  46.     notifications_url: string;
  47.     labels_url:        string;
  48.     releases_url:      string;
  49.     deployments_url:   string;
  50.     created_at:        string;
  51.     updated_at:        string;
  52.     pushed_at:         string;
  53.     git_url:           string;
  54.     ssh_url:           string;
  55.     clone_url:         string;
  56.     svn_url:           string;
  57.     homepage:          null | string;
  58.     size:              number;
  59.     stargazers_count:  number;
  60.     watchers_count:    number;
  61.     language:          null | string;
  62.     has_issues:        boolean;
  63.     has_projects:      boolean;
  64.     has_downloads:     boolean;
  65.     has_wiki:          boolean;
  66.     has_pages:         boolean;
  67.     forks_count:       number;
  68.     mirror_url:        null;
  69.     archived:          boolean;
  70.     disabled:          boolean;
  71.     open_issues_count: number;
  72.     license:           License | null;
  73.     forks:             number;
  74.     open_issues:       number;
  75.     watchers:          number;
  76.     default_branch:    string;
  77. }
  78.  
  79. export interface License {
  80.     key:     string;
  81.     name:    string;
  82.     spdx_id: string;
  83.     url:     string;
  84.     node_id: string;
  85. }
  86.  
  87. export interface Owner {
  88.     login:               string;
  89.     id:                  number;
  90.     node_id:             string;
  91.     avatar_url:          string;
  92.     gravatar_id:         string;
  93.     url:                 string;
  94.     html_url:            string;
  95.     followers_url:       string;
  96.     following_url:       string;
  97.     gists_url:           string;
  98.     starred_url:         string;
  99.     subscriptions_url:   string;
  100.     organizations_url:   string;
  101.     repos_url:           string;
  102.     events_url:          string;
  103.     received_events_url: string;
  104.     type:                string;
  105.     site_admin:          boolean;
  106. }
  107.  
  108. const githubUsername = 'diamantdev'
  109. const githubUrl = `https://api.github.com/users/${githubUsername}/repos`
  110.  
  111. export const getRepos = async () => {
  112.     const response = await fetch(githubUrl);
  113.     const repos: [Repos] = await response.json();
  114.     const sortedRepos = repos.sort()
  115.     return sortedRepos.filter((repo) => repo.name != githubUsername || !repo.archived)
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement