balena-supervisor/src/api.coffee

27 lines
505 B
CoffeeScript
Raw Normal View History

fs = require 'fs'
express = require 'express'
dockerode = require 'dockerode'
api = express()
LED_FILE = '/sys/class/leds/led0/brightness'
blink = (ms = 200, callback) ->
fs.writeFileSync(LED_FILE, 1)
2013-12-17 06:04:53 +00:00
setTimeout(->
fs.writeFile(LED_FILE, 0, callback)
, ms)
api.post('/blink', (req, res) ->
interval = setInterval(blink, 400)
2013-12-17 06:04:53 +00:00
setTimeout(->
clearInterval(interval)
, 5000)
res.send(200)
)
api.post('/update', (req, res) ->
console.log('TODO: Update the application')
)
module.exports = api