Integrat resin-platform-api

This commit is contained in:
Juan Cruz Viotti 2014-11-18 10:11:07 -04:00
parent 6da7290d73
commit e18bc83285
3 changed files with 26 additions and 1 deletions

View File

@ -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
View 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

View File

@ -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"
}
}