mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 05:37:53 +00:00
Share request settings between request and pinejs-client, and make sure a 30s timeout is used.
This commit is contained in:
parent
c29e0720c6
commit
84b5746111
@ -5,16 +5,13 @@ path = require 'path'
|
||||
config = require './config'
|
||||
dockerUtils = require './docker-utils'
|
||||
Promise = require 'bluebird'
|
||||
PlatformAPI = require 'pinejs-client'
|
||||
utils = require './utils'
|
||||
tty = require './lib/tty'
|
||||
logger = require './lib/logger'
|
||||
{ resinApi, cachedResinApi } = require './request'
|
||||
|
||||
{docker} = dockerUtils
|
||||
|
||||
PLATFORM_ENDPOINT = url.resolve(config.apiEndpoint, '/ewa/')
|
||||
resinApi = new PlatformAPI(PLATFORM_ENDPOINT)
|
||||
cachedResinApi = resinApi.clone({}, cache: {})
|
||||
|
||||
knex('config').select('value').where(key: 'uuid').then ([ uuid ]) ->
|
||||
logger.init(
|
||||
|
@ -1,16 +1,11 @@
|
||||
Promise = require 'bluebird'
|
||||
_ = require 'lodash'
|
||||
url = require 'url'
|
||||
knex = require './db'
|
||||
utils = require './utils'
|
||||
crypto = require 'crypto'
|
||||
config = require './config'
|
||||
PlatformAPI = require 'pinejs-client'
|
||||
{ resinApi } = require './request'
|
||||
fs = Promise.promisifyAll(require('fs'))
|
||||
|
||||
PLATFORM_ENDPOINT = url.resolve(config.apiEndpoint, '/ewa/')
|
||||
resinApi = new PlatformAPI(PLATFORM_ENDPOINT)
|
||||
|
||||
registerDevice = (apiKey, userId, applicationId, deviceType, uuid) ->
|
||||
# I'd be nice if the UUID matched the output of a SHA-256 function, but although the length limit of the CN
|
||||
# attribute in a X.509 certificate is 64 chars, a 32 byte UUID (64 chars in hex) doesn't pass the certificate
|
||||
|
@ -6,7 +6,7 @@ es = require 'event-stream'
|
||||
_ = require 'lodash'
|
||||
knex = require './db'
|
||||
|
||||
request = require './request'
|
||||
{ request } = require './request'
|
||||
|
||||
docker = Promise.promisifyAll(new Docker(socketPath: config.dockerSocket))
|
||||
# Hack dockerode to promisify internal classes' prototypes
|
||||
|
@ -1,7 +1,20 @@
|
||||
request = require 'request'
|
||||
config = require './config'
|
||||
PlatformAPI = require 'pinejs-client'
|
||||
Promise = require 'bluebird'
|
||||
request = require 'request'
|
||||
url = require 'url'
|
||||
|
||||
request = request.defaults
|
||||
requestOpts =
|
||||
gzip: true
|
||||
timeout: 30000
|
||||
|
||||
module.exports = Promise.promisifyAll(request)
|
||||
PLATFORM_ENDPOINT = url.resolve(config.apiEndpoint, '/ewa/')
|
||||
exports.resinApi = resinApi = new PlatformAPI
|
||||
apiPrefix: PLATFORM_ENDPOINT
|
||||
passthrough: requestOpts
|
||||
exports.cachedResinApi = resinApi.clone({}, cache: {})
|
||||
|
||||
|
||||
request = request.defaults(requestOpts)
|
||||
|
||||
exports.request = Promise.promisifyAll(request)
|
||||
|
Loading…
Reference in New Issue
Block a user