mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-29 15:44:13 +00:00
On update get application info from the API
This commit is contained in:
parent
f10fb532c6
commit
563df5386d
@ -1,8 +1,10 @@
|
||||
Promise = require 'bluebird'
|
||||
fs = Promise.promisifyAll require 'fs'
|
||||
url = require 'url'
|
||||
knex = require './db'
|
||||
utils = require './utils'
|
||||
express = require 'express'
|
||||
dockerode = require 'dockerode'
|
||||
request = Promise.promisify require 'request'
|
||||
|
||||
api = express()
|
||||
|
||||
@ -22,7 +24,22 @@ api.post('/v1/blink', (req, res) ->
|
||||
)
|
||||
|
||||
api.post('/v1/update', (req, res) ->
|
||||
console.log('TODO: Update the application')
|
||||
res.send(204)
|
||||
Promise.all([
|
||||
knex('config').select('value').where(key: 'apiKey')
|
||||
knex('config').select('value').where(key: 'uuid')
|
||||
]).then(([[apiKey], [uuid]]) ->
|
||||
apiKey = apiKey.value
|
||||
uuid = uuid.value
|
||||
request(
|
||||
method: 'GET'
|
||||
url: url.resolve(process.env.API_ENDPOINT, "/ewa/application?$filter=device/uuid eq '#{uuid}'&apikey=#{apiKey}")
|
||||
json: true
|
||||
).spread((request, body) ->
|
||||
for app in body.d
|
||||
console.log("Got application", app)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
module.exports = api
|
||||
|
Loading…
x
Reference in New Issue
Block a user