# All files / src/sdk github.js

0% Statements 0/12
0% Branches 0/7
0% Functions 0/3
0% Lines 0/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38

     /// <reference path='.github.d.ts' />

    import fetch from "@36node/fetch";

    export default class SDK {
      /** @type {string} */
      base;

      /**
       * Init github sdk
       *
       * @param {Object} opt
       * @param {string} opt.base  base url
       */
      constructor(opt = {}) {
        this.base = opt.base || "https://api.github.com";
      }

      /**
       * repo's methods
       */

      repo = {
        /**
         * List all repos
         *
         * @param {ListReposRequest} req listRepos request
         * @returns {Promise<ListReposResponse>} A paged array of repos
         */
        listRepos: req => {
          const { org, query } = req;
          return fetch(`${this.base}/users/${org}/repos`, {
            query,
          });
        },
      };
    }