mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 13:47:54 +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'
|
config = require './config'
|
||||||
dockerUtils = require './docker-utils'
|
dockerUtils = require './docker-utils'
|
||||||
Promise = require 'bluebird'
|
Promise = require 'bluebird'
|
||||||
PlatformAPI = require 'pinejs-client'
|
|
||||||
utils = require './utils'
|
utils = require './utils'
|
||||||
tty = require './lib/tty'
|
tty = require './lib/tty'
|
||||||
logger = require './lib/logger'
|
logger = require './lib/logger'
|
||||||
|
{ resinApi, cachedResinApi } = require './request'
|
||||||
|
|
||||||
{docker} = dockerUtils
|
{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 ]) ->
|
knex('config').select('value').where(key: 'uuid').then ([ uuid ]) ->
|
||||||
logger.init(
|
logger.init(
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
Promise = require 'bluebird'
|
Promise = require 'bluebird'
|
||||||
_ = require 'lodash'
|
_ = require 'lodash'
|
||||||
url = require 'url'
|
|
||||||
knex = require './db'
|
knex = require './db'
|
||||||
utils = require './utils'
|
utils = require './utils'
|
||||||
crypto = require 'crypto'
|
crypto = require 'crypto'
|
||||||
config = require './config'
|
{ resinApi } = require './request'
|
||||||
PlatformAPI = require 'pinejs-client'
|
|
||||||
fs = Promise.promisifyAll(require('fs'))
|
fs = Promise.promisifyAll(require('fs'))
|
||||||
|
|
||||||
PLATFORM_ENDPOINT = url.resolve(config.apiEndpoint, '/ewa/')
|
|
||||||
resinApi = new PlatformAPI(PLATFORM_ENDPOINT)
|
|
||||||
|
|
||||||
registerDevice = (apiKey, userId, applicationId, deviceType, uuid) ->
|
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
|
# 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
|
# 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'
|
_ = require 'lodash'
|
||||||
knex = require './db'
|
knex = require './db'
|
||||||
|
|
||||||
request = require './request'
|
{ request } = require './request'
|
||||||
|
|
||||||
docker = Promise.promisifyAll(new Docker(socketPath: config.dockerSocket))
|
docker = Promise.promisifyAll(new Docker(socketPath: config.dockerSocket))
|
||||||
# Hack dockerode to promisify internal classes' prototypes
|
# Hack dockerode to promisify internal classes' prototypes
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
request = require 'request'
|
config = require './config'
|
||||||
|
PlatformAPI = require 'pinejs-client'
|
||||||
Promise = require 'bluebird'
|
Promise = require 'bluebird'
|
||||||
|
request = require 'request'
|
||||||
|
url = require 'url'
|
||||||
|
|
||||||
request = request.defaults
|
requestOpts =
|
||||||
gzip: true
|
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