Move removeInternalAppFields to model code

This commit is contained in:
Girish Ramakrishnan
2018-04-29 10:47:34 -07:00
parent 1a27009fb5
commit b1b664ceca
2 changed files with 13 additions and 30 deletions

View File

@@ -43,32 +43,6 @@ function auditSource(req) {
return { ip: ip, username: req.user ? req.user.username : null, userId: req.user ? req.user.id : null };
}
function removeInternalAppFields(app) {
return {
id: app.id,
appStoreId: app.appStoreId,
installationState: app.installationState,
installationProgress: app.installationProgress,
runState: app.runState,
health: app.health,
location: app.location,
domain: app.domain,
accessRestriction: app.accessRestriction,
manifest: app.manifest,
portBindings: app.portBindings,
iconUrl: app.iconUrl,
fqdn: app.fqdn,
memoryLimit: app.memoryLimit,
xFrameOptions: app.xFrameOptions,
sso: app.sso,
debugMode: app.debugMode,
robotsTxt: app.robotsTxt,
enableBackup: app.enableBackup,
creationTime: app.creationTime.toISOString(),
updateTime: app.updateTime.toISOString()
};
}
function getApp(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
@@ -76,7 +50,7 @@ function getApp(req, res, next) {
if (error && error.reason === AppsError.NOT_FOUND) return next(new HttpError(404, 'No such app'));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, removeInternalAppFields(app)));
next(new HttpSuccess(200, apps.removeInternalAppFields(app)));
});
}
@@ -86,7 +60,7 @@ function getApps(req, res, next) {
apps.getAll(function (error, allApps) {
if (error) return next(new HttpError(500, error));
allApps = allApps.map(removeInternalAppFields);
allApps = allApps.map(apps.removeInternalAppFields);
next(new HttpSuccess(200, { apps: allApps }));
});
@@ -98,7 +72,7 @@ function getAllByUser(req, res, next) {
apps.getAllByUser(req.user, function (error, allApps) {
if (error) return next(new HttpError(500, error));
allApps = allApps.map(removeInternalAppFields);
allApps = allApps.map(apps.removeInternalAppFields);
next(new HttpSuccess(200, { apps: allApps }));
});