mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-20 09:46:19 +00:00
Enable compression for all of our custom requests.
This commit is contained in:
parent
7f5052f274
commit
f5f6ee3a61
@ -7,7 +7,7 @@ utils = require './utils'
|
||||
crypto = require 'crypto'
|
||||
config = require './config'
|
||||
csrgen = Promise.promisify require 'csr-gen'
|
||||
request = Promise.promisify require 'request'
|
||||
request = require './request'
|
||||
PlatformAPI = require 'resin-platform-api/request'
|
||||
|
||||
PLATFORM_ENDPOINT = url.resolve(config.apiEndpoint, '/ewa/')
|
||||
@ -70,8 +70,7 @@ module.exports = ->
|
||||
console.log('Posting to the API..')
|
||||
userConfig.csr = keys.csr
|
||||
userConfig.uuid = uuid
|
||||
return request(
|
||||
method: 'POST'
|
||||
return request.postAsync(
|
||||
url: url.resolve(config.apiEndpoint, 'sign_certificate?apikey=' + userConfig.apiKey)
|
||||
json: userConfig
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ es = require 'event-stream'
|
||||
_ = require 'lodash'
|
||||
knex = require './db'
|
||||
|
||||
request = Promise.promisify(require 'request')
|
||||
request = require './request'
|
||||
|
||||
docker = Promise.promisifyAll(new Docker(socketPath: config.dockerSocket))
|
||||
# Hack dockerode to promisify internal classes' prototypes
|
||||
@ -98,7 +98,7 @@ do ->
|
||||
|
||||
# Get the id of an image on a given registry and tag.
|
||||
exports.getImageId = getImageId = (registry, imageName, tag='latest') ->
|
||||
request("http://#{registry}/v1/repositories/#{imageName}/tags")
|
||||
request.getAsync("http://#{registry}/v1/repositories/#{imageName}/tags")
|
||||
.spread (res, data) ->
|
||||
if res.statusCode == 404
|
||||
throw new Error("No such image #{imageName} on registry #{registry}")
|
||||
@ -109,7 +109,7 @@ do ->
|
||||
|
||||
# Return the ids of the layers of an image.
|
||||
exports.getImageHistory = getImageHistory = (registry, imageId) ->
|
||||
request("http://#{registry}/v1/images/#{imageId}/ancestry")
|
||||
request.getAsync("http://#{registry}/v1/images/#{imageId}/ancestry")
|
||||
.spread (res, data) ->
|
||||
if res.statusCode >= 400
|
||||
throw new Error("Failed to get image ancestry of #{imageId} from #{registry}. Status code: #{res.statusCode}")
|
||||
@ -123,7 +123,7 @@ do ->
|
||||
.then (exists) ->
|
||||
if exists
|
||||
return 0
|
||||
request("http://#{registry}/v1/images/#{imageId}/json")
|
||||
request.getAsync("http://#{registry}/v1/images/#{imageId}/json")
|
||||
.spread (res, data) ->
|
||||
if res.statusCode >= 400
|
||||
throw new Error("Failed to get image download size of #{imageId} from #{registry}. Status code: #{res.statusCode}")
|
||||
|
7
src/request.coffee
Normal file
7
src/request.coffee
Normal file
@ -0,0 +1,7 @@
|
||||
request = require 'request'
|
||||
Promise = require 'bluebird'
|
||||
|
||||
request = request.defaults
|
||||
gzip: true
|
||||
|
||||
module.exports = Promise.promisifyAll(request)
|
@ -3,7 +3,7 @@ _ = require 'lodash'
|
||||
fs = Promise.promisifyAll require 'fs'
|
||||
config = require './config'
|
||||
mixpanel = require 'mixpanel'
|
||||
request = Promise.promisifyAll require 'request'
|
||||
request = require './request'
|
||||
|
||||
# Parses package.json and returns resin-supervisor's version
|
||||
exports.supervisorVersion = require('../package.json').version
|
||||
|
Loading…
x
Reference in New Issue
Block a user