mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 08:25:36 +00:00
Use the new status/send/sendStatus style.
This commit is contained in:
parent
6144ea3aeb
commit
d578bbfba3
@ -14,43 +14,43 @@ module.exports = (secret) ->
|
||||
if req.query.apikey is secret
|
||||
next()
|
||||
else
|
||||
res.send(401)
|
||||
res.sendStatus(401)
|
||||
|
||||
api.post '/v1/blink', (req, res) ->
|
||||
utils.mixpanelTrack('Device blink')
|
||||
utils.blink.pattern.start()
|
||||
setTimeout(utils.blink.pattern.stop, 15000)
|
||||
res.send(200)
|
||||
res.sendStatus(200)
|
||||
|
||||
api.post '/v1/update', (req, res) ->
|
||||
utils.mixpanelTrack('Update notification')
|
||||
application.update()
|
||||
res.send(204)
|
||||
res.sendStatus(204)
|
||||
|
||||
api.post '/v1/spawn-tty', (req, res) ->
|
||||
appId = req.body.appId
|
||||
utils.mixpanelTrack('Spawn tty', appId)
|
||||
if !appId?
|
||||
res.send(400, 'Missing app id')
|
||||
res.status(400).send('Missing app id')
|
||||
knex('app').select().where({appId})
|
||||
.then ([ app ]) ->
|
||||
if !app?
|
||||
throw new Error('App not found')
|
||||
tty.start(app)
|
||||
.then (url) ->
|
||||
res.send(200, url)
|
||||
res.status(200).send(url)
|
||||
.catch (err) ->
|
||||
res.send(503, err?.message or err or 'Unknown error')
|
||||
res.status(503).send(err?.message or err or 'Unknown error')
|
||||
|
||||
api.post '/v1/despawn-tty', (req, res) ->
|
||||
appId = req.body.appId
|
||||
utils.mixpanelTrack('Despawn tty', appId)
|
||||
if !appId?
|
||||
res.send(400, 'Missing app id')
|
||||
res.status(400).send('Missing app id')
|
||||
tty.stop(appId)
|
||||
.then ->
|
||||
res.send(200)
|
||||
res.sendStatus(200)
|
||||
.catch (err) ->
|
||||
res.send(503, err?.message or err or 'Unknown error')
|
||||
res.status(503).send(err?.message or err or 'Unknown error')
|
||||
|
||||
return api
|
||||
|
Loading…
x
Reference in New Issue
Block a user