aboutsummaryrefslogtreecommitdiffhomepage
path: root/api/services/github/installations.js
blob: 73b1764c55266945b16d57b046ebc6224feaa00a (plain)
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
const api = require('./api')
const { createAppToken } = require('./auth')

function fetchInstallation (user) {
  const token = createAppToken()
  return api.request({ url: `/users/${user}/installation`, token }).catch(err => {
    if (err.response && err.response.status === 404) {
      return { data: null }
    }

    throw err
  })
}

function fetchInstallationRepos (installationToken, installationId) {
  return api.request({
    url: `/user/installations/${installationId}/repositories`,
    token: installationToken
  })
}

module.exports = {
  fetchInstallation,
  fetchInstallationRepos
}