mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-05 18:38:14 +00:00
Use exclusion lists for keys/columns to be omited from the /v1/apps endpoint
This commit is contained in:
parent
e03e5ed0ae
commit
f76b38eb49
@ -10,6 +10,17 @@ config = require './config'
|
|||||||
device = require './device'
|
device = require './device'
|
||||||
_ = require 'lodash'
|
_ = require 'lodash'
|
||||||
|
|
||||||
|
privateAppEnvVars = [
|
||||||
|
'RESIN_SUPERVISOR_API_KEY'
|
||||||
|
'RESIN_API_KEY'
|
||||||
|
]
|
||||||
|
|
||||||
|
ignoredAppTableColumns = [
|
||||||
|
'id'
|
||||||
|
'name'
|
||||||
|
'privileged'
|
||||||
|
]
|
||||||
|
|
||||||
module.exports = (application) ->
|
module.exports = (application) ->
|
||||||
api = express()
|
api = express()
|
||||||
api.use(bodyParser())
|
api.use(bodyParser())
|
||||||
@ -171,9 +182,9 @@ module.exports = (application) ->
|
|||||||
if !app?
|
if !app?
|
||||||
throw new Error('App not found')
|
throw new Error('App not found')
|
||||||
# Don't return keys on the endpoint
|
# Don't return keys on the endpoint
|
||||||
app.env = _.omit(JSON.parse(app.env), [ 'RESIN_SUPERVISOR_API_KEY', 'RESIN_API_KEY' ])
|
app.env = _.omit(JSON.parse(app.env), privateAppEnvVars)
|
||||||
# name and privileged are unused, and id makes no sense to the user here.
|
# Don't return data that will be of no use to the user
|
||||||
res.json(_.omit(app, [ 'id', 'name', 'privileged' ]))
|
res.json(_.omit(app, ignoredAppTableColumns))
|
||||||
.catch (err) ->
|
.catch (err) ->
|
||||||
res.status(503).send(err?.message or err or 'Unknown error')
|
res.status(503).send(err?.message or err or 'Unknown error')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user