Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to production #4517

Merged
merged 16 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
709f39b
Update workflows staging image tag to stage-49c61b4d-1740828876
github-actions[bot] Mar 1, 2025
ed4c996
Update data mgt production image tag to prod-1cfefd36-1740828978
github-actions[bot] Mar 1, 2025
c088264
Update auth service production image tag to prod-1cfefd36-1740828978
github-actions[bot] Mar 1, 2025
83048f5
Update device registry production image tag to prod-1cfefd36-1740828978
github-actions[bot] Mar 1, 2025
a1f368b
Update workflows prod image tag to prod-1cfefd36-1740828978
github-actions[bot] Mar 1, 2025
ac5ec47
Update spatial production image tag to prod-1cfefd36-1740828978
github-actions[bot] Mar 1, 2025
7179ab2
Update predict production image tag to prod-1cfefd36-1740828978
github-actions[bot] Mar 1, 2025
a507070
Feat: Implement Tenant-Specific Default Settings Management
Baalmart Mar 2, 2025
adf3034
Fix: Implement Date Range Validation for Activity Dates
Baalmart Mar 3, 2025
cf25aa8
creating a reusable function outside the validation definitions
Baalmart Mar 3, 2025
3c01ed0
Merge pull request #4515 from airqo-platform/activity-date-validation
Baalmart Mar 3, 2025
ca6473b
Update device registry staging image tag to stage-3c01ed08-1741003992
github-actions[bot] Mar 3, 2025
54efb54
Merge branch 'staging' into tenant-specific-settings
Baalmart Mar 3, 2025
164065f
properly unwinding the role documents before looking up their permiss…
Baalmart Mar 3, 2025
0b57b6d
Merge pull request #4511 from airqo-platform/tenant-specific-settings
Baalmart Mar 3, 2025
aa9a26a
Update auth service staging image tag to stage-0b57b6d6-1741008627
github-actions[bot] Mar 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion k8s/auth-service/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-auth-api
tag: prod-a5891acb-1740669362
tag: prod-1cfefd36-1740828978
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/auth-service/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-stage-auth-api
tag: stage-c19b9d1b-1740578709
tag: stage-0b57b6d6-1741008627
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/data-mgt/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-data-mgt-api
tag: prod-a5891acb-1740669362
tag: prod-1cfefd36-1740828978
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/device-registry/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-device-registry-api
tag: prod-a5891acb-1740669362
tag: prod-1cfefd36-1740828978
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/device-registry/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 2
image:
repository: eu.gcr.io/airqo-250220/airqo-stage-device-registry-api
tag: stage-d6023000-1740329829
tag: stage-3c01ed08-1741003992
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/predict/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ images:
predictJob: eu.gcr.io/airqo-250220/airqo-predict-job
trainJob: eu.gcr.io/airqo-250220/airqo-train-job
predictPlaces: eu.gcr.io/airqo-250220/airqo-predict-places-air-quality
tag: prod-a5891acb-1740669362
tag: prod-1cfefd36-1740828978
api:
name: airqo-prediction-api
label: prediction-api
Expand Down
2 changes: 1 addition & 1 deletion k8s/spatial/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ app:
replicaCount: 3
image:
repository: eu.gcr.io/airqo-250220/airqo-spatial-api
tag: prod-a5891acb-1740669362
tag: prod-1cfefd36-1740828978
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/workflows/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ images:
initContainer: eu.gcr.io/airqo-250220/airqo-workflows-xcom
redisContainer: eu.gcr.io/airqo-250220/airqo-redis
containers: eu.gcr.io/airqo-250220/airqo-workflows
tag: prod-a5891acb-1740669362
tag: prod-1cfefd36-1740828978
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
2 changes: 1 addition & 1 deletion k8s/workflows/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ images:
initContainer: eu.gcr.io/airqo-250220/airqo-stage-workflows-xcom
redisContainer: eu.gcr.io/airqo-250220/airqo-stage-redis
containers: eu.gcr.io/airqo-250220/airqo-stage-workflows
tag: stage-d5a5f567-1740669230
tag: stage-49c61b4d-1740828876
nameOverride: ''
fullnameOverride: ''
podAnnotations: {}
Expand Down
230 changes: 230 additions & 0 deletions src/auth-service/controllers/tenant-settings.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
// tenantSettings.controller.js
const tenantSettingsUtil = require("@utils/tenant-settings.util");
const {
logObject,
logText,
logElement,
HttpError,
extractErrorsFromRequest,
} = require("@utils/shared");
const constants = require("@config/constants");
const isEmpty = require("is-empty");
const httpStatus = require("http-status");
const log4js = require("log4js");
const logger = log4js.getLogger(
`${constants.ENVIRONMENT} -- tenantSettings-controller`
);

const tenantSettings = {
create: async (req, res, next) => {
try {
const errors = extractErrorsFromRequest(req);
if (errors) {
next(
new HttpError("bad request errors", httpStatus.BAD_REQUEST, errors)
);
return;
}
const request = req;
const defaultTenant = constants.DEFAULT_TENANT || "airqo";
request.query.tenant = isEmpty(req.query.tenant)
? defaultTenant
: req.query.tenant;

const result = await tenantSettingsUtil.create(request, next);

if (isEmpty(result) || res.headersSent) {
return;
}

if (result.success === true) {
const status = result.status ? result.status : httpStatus.OK;
return res.status(status).json({
success: true,
message: result.message ? result.message : "",
tenantSettings: result.data ? result.data : [],
});
} else if (result.success === false) {
const status = result.status
? result.status
: httpStatus.INTERNAL_SERVER_ERROR;
return res.status(status).json({
success: false,
message: result.message ? result.message : "",
errors: result.errors ? result.errors : { message: "" },
});
}
} catch (error) {
logger.error(`🐛🐛 Internal Server Error ${error.message}`);
next(
new HttpError(
"Internal Server Error",
httpStatus.INTERNAL_SERVER_ERROR,
{ message: error.message }
)
);
return;
}
},

list: async (req, res, next) => {
try {
const errors = extractErrorsFromRequest(req);
if (errors) {
next(
new HttpError("bad request errors", httpStatus.BAD_REQUEST, errors)
);
return;
}
const request = req;
const defaultTenant = constants.DEFAULT_TENANT || "airqo";
request.query.tenant = isEmpty(req.query.tenant)
? defaultTenant
: req.query.tenant;

const result = await tenantSettingsUtil.list(request, next);

if (isEmpty(result) || res.headersSent) {
return;
}

if (result.success === true) {
const status = result.status ? result.status : httpStatus.OK;
return res.status(status).json({
success: true,
message: result.message ? result.message : "",
tenantSettings: result.data ? result.data : [],
});
} else if (result.success === false) {
const status = result.status
? result.status
: httpStatus.INTERNAL_SERVER_ERROR;
return res.status(status).json({
success: false,
message: result.message ? result.message : "",
errors: result.errors
? result.errors
: { message: "Internal Server Error" },
});
}
} catch (error) {
logger.error(`🐛🐛 Internal Server Error ${error.message}`);
next(
new HttpError(
"Internal Server Error",
httpStatus.INTERNAL_SERVER_ERROR,
{ message: error.message }
)
);
return;
}
},

update: async (req, res, next) => {
try {
const errors = extractErrorsFromRequest(req);
if (errors) {
next(
new HttpError("bad request errors", httpStatus.BAD_REQUEST, errors)
);
return;
}
const request = req;
const defaultTenant = constants.DEFAULT_TENANT || "airqo";
request.query.tenant = isEmpty(req.query.tenant)
? defaultTenant
: req.query.tenant;

const result = await tenantSettingsUtil.update(request, next);

if (isEmpty(result) || res.headersSent) {
return;
}

if (result.success === true) {
const status = result.status ? result.status : httpStatus.OK;
return res.status(status).json({
success: true,
message: result.message ? result.message : "",
updatedTenantSettings: result.data ? result.data : [],
});
} else if (result.success === false) {
const status = result.status
? result.status
: httpStatus.INTERNAL_SERVER_ERROR;
return res.status(status).json({
success: false,
message: result.message ? result.message : "",
errors: result.errors
? result.errors
: { message: "Internal Server Error" },
});
}
} catch (error) {
logger.error(`🐛🐛 Internal Server Error ${error.message}`);
next(
new HttpError(
"Internal Server Error",
httpStatus.INTERNAL_SERVER_ERROR,
{ message: error.message }
)
);
return;
}
},

delete: async (req, res, next) => {
try {
const errors = extractErrorsFromRequest(req);
if (errors) {
next(
new HttpError("bad request errors", httpStatus.BAD_REQUEST, errors)
);
return;
}
const request = req;
const defaultTenant = constants.DEFAULT_TENANT || "airqo";
request.query.tenant = isEmpty(req.query.tenant)
? defaultTenant
: req.query.tenant;

const result = await tenantSettingsUtil.delete(request, next);

if (isEmpty(result) || res.headersSent) {
return;
}

if (result.success === true) {
const status = result.status ? result.status : httpStatus.OK;
return res.status(status).json({
success: true,
message: result.message ? result.message : "",
deletedTenantSettings: result.data ? result.data : [],
});
} else if (result.success === false) {
const status = result.status
? result.status
: httpStatus.INTERNAL_SERVER_ERROR;
return res.status(status).json({
success: false,
message: result.message ? result.message : "",
errors: result.errors
? result.errors
: { message: "Internal Server Error" },
});
}
} catch (error) {
logger.error(`🐛🐛 Internal Server Error ${error.message}`);
next(
new HttpError(
"Internal Server Error",
httpStatus.INTERNAL_SERVER_ERROR,
{ message: error.message }
)
);
return;
}
},
};

module.exports = tenantSettings;
Loading
Loading