Browse Source

chore: stick with axios

No clear benefits for switching to got
github-label
Amio 6 years ago
parent
commit
c0a7402abc
  1. 6
      libs/got.js
  2. 6
      libs/live-fns/codeclimate.js
  3. 9
      libs/live-fns/github.js
  4. 131
      package-lock.json
  5. 1
      package.json

6
libs/got.js

@ -1,6 +0,0 @@
const got = require('got')
module.exports = got.extend({
json: true,
timeout: 3200
})

6
libs/live-fns/codeclimate.js

@ -1,9 +1,9 @@
const got = require('../got.js')
const axios = require('../axios.js')
const scale = require('../utils/scale.js')
module.exports = async (topic, user, repo) => {
const api = `https://api.codeclimate.com/v1/repos?github_slug=${user}/${repo}`
const meta = await got(api).then(res => res.body.data[0])
const meta = await axios.get(api).then(res => res.data.data[0])
if (!meta) {
return {
@ -32,7 +32,7 @@ module.exports = async (topic, user, repo) => {
const getReport = async (repoId, reportId, type, topic) => {
const api = `https://api.codeclimate.com/v1/repos/${repoId}/${type}/${reportId}`
const { meta, attributes } = await got(api).then(res => res.body.data)
const { meta, attributes } = await axios.get(api).then(res => res.body.data)
switch (topic) {
case 'issues':

9
libs/live-fns/github.js

@ -2,7 +2,6 @@ const cheerio = require('cheerio')
const distanceInWordsToNow = require('date-fns/distance_in_words_to_now')
const millify = require('millify')
const axios = require('../axios.js')
const got = require('../got.js')
const v = require('../utils/version-formatter.js')
const token = process.env.GH_TOKEN
@ -51,22 +50,22 @@ module.exports = async (topic, ...args) => {
}
// request github api v3 (rest)
const restGithub = path => got(`https://api.github.com/${path}`, {
const restGithub = path => axios.get(`https://api.github.com/${path}`, {
headers: {
...tokenHeader,
Accept: 'application/vnd.github.hellcat-preview+json'
}
}).then(res => res.body)
}).then(res => res.data)
// request github api v4 (graphql)
const queryGithub = query => {
return got.post('https://api.github.com/graphql', {
return axios.post('https://api.github.com/graphql', {
body: { query },
headers: {
...tokenHeader,
Accept: 'application/vnd.github.hawkgirl-preview+json'
}
}).then(res => res.body)
}).then(res => res.data)
}
const release = async (user, repo, channel) => {

131
package-lock.json

@ -3,14 +3,6 @@
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"@sindresorhus/is": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.11.0.tgz",
"integrity": "sha512-i5Zh5+3QARyXtzq3Bd2Lg3aBRFLcgYbNoap3Hyu1uRN8X+D+0JMqqc4uk4XjhNxfVdCnL8WHUA2wxa33QCC50w==",
"requires": {
"symbol-observable": "^1.2.0"
}
},
"@types/node": {
"version": "10.5.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.6.tgz",
@ -462,20 +454,6 @@
"unset-value": "^1.0.0"
}
},
"cacheable-request": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-4.0.1.tgz",
"integrity": "sha512-sJJ9ivV+1DytIdAgQG1CsRjAESGD5WnjTr4BsQ3X4xZKp3O9i6Es7MWeQ1pOTuE0bTLVEf86YFjSGpr53wz7nw==",
"requires": {
"clone-response": "^1.0.2",
"get-stream": "^3.0.0",
"http-cache-semantics": "^4.0.0",
"keyv": "^3.0.0",
"lowercase-keys": "^1.0.1",
"normalize-url": "^3.1.0",
"responselike": "^1.0.2"
}
},
"caller-path": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz",
@ -678,14 +656,6 @@
"wrap-ansi": "^2.0.0"
}
},
"clone-response": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
"integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=",
"requires": {
"mimic-response": "^1.0.0"
}
},
"co": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
@ -883,14 +853,6 @@
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=",
"dev": true
},
"decompress-response": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz",
"integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=",
"requires": {
"mimic-response": "^1.0.0"
}
},
"deep-is": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
@ -1065,11 +1027,6 @@
"integrity": "sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow==",
"dev": true
},
"duplexer3": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz",
"integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI="
},
"ecc-jsbn": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
@ -2357,7 +2314,8 @@
"get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=",
"dev": true
},
"get-value": {
"version": "2.0.6",
@ -2429,22 +2387,6 @@
"pinkie-promise": "^2.0.0"
}
},
"got": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/got/-/got-9.0.0.tgz",
"integrity": "sha512-TumaTIc9kYMFTkLwtvELc1IQYpQDqKqVuLx07I+kQmWHF6LELztdtHoy7w6UYkLfSkNnvzMRkasC/75aJMNiHw==",
"requires": {
"@sindresorhus/is": "^0.11.0",
"cacheable-request": "^4.0.1",
"decompress-response": "^3.3.0",
"duplexer3": "^0.1.4",
"get-stream": "^3.0.0",
"mimic-response": "^1.0.0",
"p-cancelable": "^0.5.0",
"to-readable-stream": "^1.0.0",
"url-parse-lax": "^3.0.0"
}
},
"graceful-fs": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
@ -2581,11 +2523,6 @@
}
}
},
"http-cache-semantics": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
"integrity": "sha512-NtexGRtaV5z3ZUX78W9UDTOJPBdpqms6RmwQXmOhHws7CuQK3cqIoQtnmeqi1VvVD6u6eMMRL0sKE9BCZXTDWQ=="
},
"http-errors": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz",
@ -2959,11 +2896,6 @@
"yargs": "^11.0.0"
}
},
"json-buffer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz",
"integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg="
},
"json-parse-better-errors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
@ -3015,14 +2947,6 @@
"array-includes": "^3.0.3"
}
},
"keyv": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz",
"integrity": "sha512-eguHnq22OE3uVoSYG0LVWNP+4ppamWr9+zWBe1bsNcovIMy6huUJFPgy4mGwCd/rnl3vOLGW1MTlu4c57CT1xA==",
"requires": {
"json-buffer": "3.0.0"
}
},
"kind-of": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
@ -3104,11 +3028,6 @@
"js-tokens": "^3.0.0 || ^4.0.0"
}
},
"lowercase-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz",
"integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA=="
},
"lru-cache": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz",
@ -3298,11 +3217,6 @@
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",
"dev": true
},
"mimic-response": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
"integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
@ -3436,11 +3350,6 @@
"remove-trailing-separator": "^1.0.1"
}
},
"normalize-url": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-3.2.0.tgz",
"integrity": "sha512-WvF3Myk0NhXkG8S9bygFM4IC1KOvnVJGq0QoGeoqOYOBeinBZp5ybW3QuYbTc89lkWBMM9ZBO4QGRoc0353kKA=="
},
"npm-run-path": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
@ -6237,11 +6146,6 @@
"own-or": "^1.0.0"
}
},
"p-cancelable": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.5.0.tgz",
"integrity": "sha512-UTykUaG4vhPAMNi1/GZKGdCNDj4qGnq6taAjnOG0KCx5Fva3b1vtskXtagAePmgIhUrdcoDGEvAQIHaSPXEZWg=="
},
"p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
@ -6477,11 +6381,6 @@
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
"dev": true
},
"prepend-http": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz",
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
},
"pretty-error": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.1.tgz",
@ -6741,14 +6640,6 @@
"integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=",
"dev": true
},
"responselike": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz",
"integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=",
"requires": {
"lowercase-keys": "^1.0.0"
}
},
"restore-cursor": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
@ -7304,11 +7195,6 @@
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
"dev": true
},
"symbol-observable": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
},
"table": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz",
@ -7466,11 +7352,6 @@
}
}
},
"to-readable-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz",
"integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q=="
},
"to-regex": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz",
@ -7669,14 +7550,6 @@
"integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=",
"dev": true
},
"url-parse-lax": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz",
"integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=",
"requires": {
"prepend-http": "^2.0.0"
}
},
"use": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",

1
package.json

@ -23,7 +23,6 @@
"cheerio": "^1.0.0-rc.2",
"chrome-webstore": "^1.0.0",
"date-fns": "^1.29.0",
"got": "^9.0.0",
"micro": "^9.3.3",
"micro-fork": "^0.1.0",
"millify": "^2.0.1",

Loading…
Cancel
Save