Ensure that location and domain are provided together

in our db, {location,domain} is unique. If we replace them one
by one in the database, it will cause conflicts.
This commit is contained in:
Girish Ramakrishnan
2018-12-11 12:10:22 -08:00
parent e7294f2950
commit 0266a46b32
3 changed files with 13 additions and 11 deletions

View File

@@ -175,6 +175,10 @@ function configureApp(req, res, next) {
if ('location' in data && typeof data.location !== 'string') return next(new HttpError(400, 'location must be string'));
if ('domain' in data && typeof data.domain !== 'string') return next(new HttpError(400, 'domain must be string'));
// domain, location must both be provided since they are unique together
if ('location' in data && !('domain' in data)) return next(new HttpError(400, 'domain must be provided'));
if (!('location' in data) && 'domain' in data) return next(new HttpError(400, 'location must be provided'));
if ('portBindings' in data && typeof data.portBindings !== 'object') return next(new HttpError(400, 'portBindings must be an object'));
if ('accessRestriction' in data && typeof data.accessRestriction !== 'object') return next(new HttpError(400, 'accessRestriction must be an object'));