From f76b38eb49b3d820e4d27589bb7aa07e7e98d24e Mon Sep 17 00:00:00 2001 From: Kostas Lekkas Date: Wed, 20 Apr 2016 19:43:16 +0300 Subject: [PATCH] Use exclusion lists for keys/columns to be omited from the /v1/apps endpoint --- src/api.coffee | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/api.coffee b/src/api.coffee index 1061ab32..759dff2b 100644 --- a/src/api.coffee +++ b/src/api.coffee @@ -10,6 +10,17 @@ config = require './config' device = require './device' _ = require 'lodash' +privateAppEnvVars = [ + 'RESIN_SUPERVISOR_API_KEY' + 'RESIN_API_KEY' +] + +ignoredAppTableColumns = [ + 'id' + 'name' + 'privileged' +] + module.exports = (application) -> api = express() api.use(bodyParser()) @@ -171,9 +182,9 @@ module.exports = (application) -> if !app? throw new Error('App not found') # Don't return keys on the endpoint - app.env = _.omit(JSON.parse(app.env), [ 'RESIN_SUPERVISOR_API_KEY', 'RESIN_API_KEY' ]) - # name and privileged are unused, and id makes no sense to the user here. - res.json(_.omit(app, [ 'id', 'name', 'privileged' ])) + app.env = _.omit(JSON.parse(app.env), privateAppEnvVars) + # Don't return data that will be of no use to the user + res.json(_.omit(app, ignoredAppTableColumns)) .catch (err) -> res.status(503).send(err?.message or err or 'Unknown error')