mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-31 08:25:36 +00:00
Integrat resin-platform-api
This commit is contained in:
parent
6da7290d73
commit
e18bc83285
@ -4,4 +4,5 @@ module.exports =
|
||||
|
||||
# TODO: Should be configurable
|
||||
remoteUrl: 'https://staging.resin.io'
|
||||
apiPrefix: '/ewa/'
|
||||
dataPrefix: path.join(process.env.HOME, '.resin')
|
||||
|
23
lib/models/_canvas.coffee
Normal file
23
lib/models/_canvas.coffee
Normal file
@ -0,0 +1,23 @@
|
||||
_ = require('lodash')
|
||||
Canvas = require('resin-platform-api')
|
||||
Promise = require('bluebird')
|
||||
config = require('../config')
|
||||
server = require('../server/server')
|
||||
promisifiedServerRequest = Promise.promisify(server.request, server)
|
||||
|
||||
# TODO: I've copy and pasted request.coffee that comes with
|
||||
# resin-platform-api. In package.json, the main is set as
|
||||
# simply canvas.js, so I have no way of access this file.
|
||||
class CanvasRequestService extends Canvas(_, Promise)
|
||||
_request: (params) ->
|
||||
params.json = true
|
||||
params.gzip ?= true
|
||||
promisifiedServerRequest(params).spread (response, body) ->
|
||||
if 200 <= response.statusCode < 300
|
||||
return body
|
||||
throw new Error(body)
|
||||
|
||||
module.exports = new CanvasRequestService
|
||||
url: config.remoteUrl
|
||||
apiPrefix: config.apiPrefix
|
||||
withCredentials: true
|
@ -31,6 +31,7 @@
|
||||
"rimraf": "~2.2.8",
|
||||
"commander": "~2.5.0",
|
||||
"mkdirp": "~0.5.0",
|
||||
"resin-platform-api": "git+ssh://git@bitbucket.org/rulemotion/resin-platform-api.git#master"
|
||||
"resin-platform-api": "git+ssh://git@bitbucket.org/rulemotion/resin-platform-api.git#master",
|
||||
"bluebird": "~2.3.11"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user