Skip to content

Commit

Permalink
Merge pull request #4517 from airqo-platform/staging
Browse files Browse the repository at this point in the history
move to production
  • Loading branch information
Baalmart authored Mar 3, 2025
2 parents 1cfefd3 + aa9a26a commit 043ca4f
Show file tree
Hide file tree
Showing 18 changed files with 862 additions and 70 deletions.
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

0 comments on commit 043ca4f

Please sign in to comment.