On update get application info from the API

This commit is contained in:
Petros Aggelatos 2013-12-23 04:31:33 +00:00 committed by Pablo Carranza Vélez
parent f10fb532c6
commit 563df5386d

View File

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