From 1e37e81876c49abc2033cfea9ffbcbb2ff680ccb Mon Sep 17 00:00:00 2001 From: Aranyajit Date: Mon, 5 Feb 2024 20:47:18 +0530 Subject: [PATCH 1/5] remove m2m token for get skills endpoint --- src/common/helper.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/common/helper.js b/src/common/helper.js index d0183dc2..900f72fa 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -1157,16 +1157,10 @@ async function getStandSkills(ids) { queryBatches.push(queryString); const skillDataPromises = []; - const token = await m2mHelper.getM2MToken(); for (const batch of queryBatches) { skillDataPromises.push( (async () => { - const res = await axios.get( - `${config.API_BASE_URL}/v5/standardized-skills/skills?${batch}`, - { - headers: { Authorization: `Bearer ${token}` }, - } - ); + const res = await axios.get(`${config.API_BASE_URL}/v5/standardized-skills/skills?${batch}`); return res.data; })() ); From 5606a46ae5b9fd7239145f821b45bffec1f84042 Mon Sep 17 00:00:00 2001 From: Aranyajit Date: Tue, 6 Feb 2024 16:08:59 +0530 Subject: [PATCH 2/5] remove auth for get skills endpoint and lint fix --- src/common/challenge-helper.js | 6 +++--- src/common/helper.js | 5 +++-- src/common/s3ParseUrl.js | 8 ++------ src/controllers/AttachmentController.js | 6 +----- src/controllers/ChallengePhaseController.js | 10 ++-------- .../ChallengeTimelineTemplateController.js | 4 +--- src/controllers/HealthController.js | 9 ++------- src/controllers/SupportController.js | 4 +--- src/controllers/TimelineTemplateController.js | 13 +++---------- src/scripts/check-templates.js | 10 ++++------ src/scripts/seed-tables.js | 8 ++------ src/scripts/view-data.js | 8 ++------ 12 files changed, 26 insertions(+), 65 deletions(-) diff --git a/src/common/challenge-helper.js b/src/common/challenge-helper.js index 2868dd59..9ed4a3b6 100644 --- a/src/common/challenge-helper.js +++ b/src/common/challenge-helper.js @@ -377,9 +377,9 @@ class ChallengeHelper { if (data.prizeSets != null) { const type = data.prizeSets[0]?.prizes[0]?.type; if (type === constants.prizeTypes.USD) { - ChallengeHelper.convertPSValuesToCents(data.prizeSets) + ChallengeHelper.convertPSValuesToCents(data.prizeSets); } - + data.prizeSetUpdate = { prizeSets: [...data.prizeSets], }; @@ -489,7 +489,7 @@ class ChallengeHelper { } } - static convertPSValuesToCents(prizeSets){ + static convertPSValuesToCents(prizeSets) { prizeSets.forEach((prizeSet) => { prizeSet.prizes.forEach((prize) => { prize.amountInCents = new Decimal(prize.value).mul(100).toNumber(); diff --git a/src/common/helper.js b/src/common/helper.js index 900f72fa..b6355f29 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -1139,7 +1139,6 @@ async function getMembersByHandles(handles) { * @returns {Object} */ async function getStandSkills(ids) { - const queryBatches = []; const skillIdArg = "&skillId="; let queryString = "disablePagination=true"; @@ -1160,7 +1159,9 @@ async function getStandSkills(ids) { for (const batch of queryBatches) { skillDataPromises.push( (async () => { - const res = await axios.get(`${config.API_BASE_URL}/v5/standardized-skills/skills?${batch}`); + const res = await axios.get( + `${config.API_BASE_URL}/v5/standardized-skills/skills?${batch}` + ); return res.data; })() ); diff --git a/src/common/s3ParseUrl.js b/src/common/s3ParseUrl.js index 374dd887..e84f51ba 100644 --- a/src/common/s3ParseUrl.js +++ b/src/common/s3ParseUrl.js @@ -17,9 +17,7 @@ module.exports = function s3ParseUrl(url) { } // http://s3-aws-region.amazonaws.com/bucket/key1/key2 - match = decodedUrl.match( - /^https?:\/\/s3-([^.]+).amazonaws.com\/([^/]+)\/?(.*?)$/ - ); + match = decodedUrl.match(/^https?:\/\/s3-([^.]+).amazonaws.com\/([^/]+)\/?(.*?)$/); if (match) { return { bucket: match[2], @@ -40,9 +38,7 @@ module.exports = function s3ParseUrl(url) { // http://bucket.s3-aws-region.amazonaws.com/key1/key2 or, // http://bucket.s3.aws-region.amazonaws.com/key1/key2 - match = decodedUrl.match( - /^https?:\/\/([^.]+).(?:s3-|s3\.)([^.]+).amazonaws.com\/?(.*?)$/ - ); + match = decodedUrl.match(/^https?:\/\/([^.]+).(?:s3-|s3\.)([^.]+).amazonaws.com\/?(.*?)$/); if (match) { return { bucket: match[1], diff --git a/src/controllers/AttachmentController.js b/src/controllers/AttachmentController.js index 93c0d469..e5fa00af 100644 --- a/src/controllers/AttachmentController.js +++ b/src/controllers/AttachmentController.js @@ -12,11 +12,7 @@ const service = require("../services/AttachmentService"); */ async function createAttachment(req, res) { const body = _.isArray(req.body) ? req.body : [req.body]; - const result = await service.createAttachment( - req.authUser, - req.params.challengeId, - body - ); + const result = await service.createAttachment(req.authUser, req.params.challengeId, body); res.status(HttpStatus.CREATED).send(result); } diff --git a/src/controllers/ChallengePhaseController.js b/src/controllers/ChallengePhaseController.js index c9b404f3..b68914be 100644 --- a/src/controllers/ChallengePhaseController.js +++ b/src/controllers/ChallengePhaseController.js @@ -42,10 +42,7 @@ async function getPhase(req, res) { * @param {Object} res the response */ async function fullyUpdatePhase(req, res) { - const result = await service.fullyUpdatePhase( - req.params.challengePhaseId, - req.body - ); + const result = await service.fullyUpdatePhase(req.params.challengePhaseId, req.body); res.send(result); } @@ -55,10 +52,7 @@ async function fullyUpdatePhase(req, res) { * @param {Object} res the response */ async function partiallyUpdatePhase(req, res) { - const result = await service.partiallyUpdatePhase( - req.params.challengePhaseId, - req.body - ); + const result = await service.partiallyUpdatePhase(req.params.challengePhaseId, req.body); res.send(result); } diff --git a/src/controllers/ChallengeTimelineTemplateController.js b/src/controllers/ChallengeTimelineTemplateController.js index 9fb3ac76..ae69740e 100644 --- a/src/controllers/ChallengeTimelineTemplateController.js +++ b/src/controllers/ChallengeTimelineTemplateController.js @@ -32,9 +32,7 @@ async function createChallengeTimelineTemplate(req, res) { * @param {Object} res the response */ async function getChallengeTimelineTemplate(req, res) { - const result = await service.getChallengeTimelineTemplate( - req.params.challengeTimelineTemplateId - ); + const result = await service.getChallengeTimelineTemplate(req.params.challengeTimelineTemplateId); res.send(result); } diff --git a/src/controllers/HealthController.js b/src/controllers/HealthController.js index c07d03a0..3748b368 100644 --- a/src/controllers/HealthController.js +++ b/src/controllers/HealthController.js @@ -23,14 +23,9 @@ async function checkHealth(req, res) { try { await service.searchChallengeTypes({ page: 1, perPage: 1 }); } catch (e) { - throw new errors.ServiceUnavailableError( - `There is database operation error, ${e.message}` - ); + throw new errors.ServiceUnavailableError(`There is database operation error, ${e.message}`); } - if ( - new Date().getTime() - timestampMS > - Number(config.HEALTH_CHECK_TIMEOUT) - ) { + if (new Date().getTime() - timestampMS > Number(config.HEALTH_CHECK_TIMEOUT)) { throw new errors.ServiceUnavailableError("Database operation is slow."); } // there is no error, and it is quick, then return checks run count diff --git a/src/controllers/SupportController.js b/src/controllers/SupportController.js index 87b06fa4..f1ade8c4 100644 --- a/src/controllers/SupportController.js +++ b/src/controllers/SupportController.js @@ -12,9 +12,7 @@ const logger = require("../common/logger"); */ async function createRequest(req, res) { logger.debug( - `createRequest User: ${JSON.stringify( - req.authUser - )} - Body: ${JSON.stringify(req.body)}` + `createRequest User: ${JSON.stringify(req.authUser)} - Body: ${JSON.stringify(req.body)}` ); const result = await service.createRequest(req.authUser, req.body); res.status(HttpStatus.CREATED).send(result); diff --git a/src/controllers/TimelineTemplateController.js b/src/controllers/TimelineTemplateController.js index e17e140c..8dcbd0f4 100644 --- a/src/controllers/TimelineTemplateController.js +++ b/src/controllers/TimelineTemplateController.js @@ -32,9 +32,7 @@ async function createTimelineTemplate(req, res) { * @param {Object} res the response */ async function getTimelineTemplate(req, res) { - const result = await service.getTimelineTemplate( - req.params.timelineTemplateId - ); + const result = await service.getTimelineTemplate(req.params.timelineTemplateId); res.send(result); } @@ -44,10 +42,7 @@ async function getTimelineTemplate(req, res) { * @param {Object} res the response */ async function fullyUpdateTimelineTemplate(req, res) { - const result = await service.fullyUpdateTimelineTemplate( - req.params.timelineTemplateId, - req.body - ); + const result = await service.fullyUpdateTimelineTemplate(req.params.timelineTemplateId, req.body); res.send(result); } @@ -70,9 +65,7 @@ async function partiallyUpdateTimelineTemplate(req, res) { * @param {Object} res the response */ async function deleteTimelineTemplate(req, res) { - const result = await service.deleteTimelineTemplate( - req.params.timelineTemplateId - ); + const result = await service.deleteTimelineTemplate(req.params.timelineTemplateId); res.send(result); } diff --git a/src/scripts/check-templates.js b/src/scripts/check-templates.js index 1ba94d19..b8e50e00 100644 --- a/src/scripts/check-templates.js +++ b/src/scripts/check-templates.js @@ -11,13 +11,11 @@ async function main() { const phases = res.data; _.each(template.phases, (phase) => { const phaseInstance = _.find(phases, (p) => p.id === phase.phaseId); - const pred = phase.predecessor - ? _.find(phases, (p) => p.id === phase.predecessor) - : null; + const pred = phase.predecessor ? _.find(phases, (p) => p.id === phase.predecessor) : null; console.log( - `Phase Length: ${phase.defaultDuration / 60 / 60} hrs \t ${ - phaseInstance.name - } - Depends on ${pred ? pred.name : "nothing"}` + `Phase Length: ${phase.defaultDuration / 60 / 60} hrs \t ${phaseInstance.name} - Depends on ${ + pred ? pred.name : "nothing" + }` ); }); } diff --git a/src/scripts/seed-tables.js b/src/scripts/seed-tables.js index c2fc00f9..8a259fd6 100644 --- a/src/scripts/seed-tables.js +++ b/src/scripts/seed-tables.js @@ -18,9 +18,7 @@ Object.keys(models).forEach((modelName) => { } try { const data = require(`./seed/${modelName}.json`); - logger.info( - `Inserting ${get(data, "length")} records in table ${modelName}` - ); + logger.info(`Inserting ${get(data, "length")} records in table ${modelName}`); promises.push(models[modelName].batchPut(data)); } catch (e) { logger.warn(`No records will be inserted in table ${modelName}`); @@ -29,9 +27,7 @@ Object.keys(models).forEach((modelName) => { Promise.all(promises) .then(() => { - logger.info( - "All tables have been inserted with the data. The processes is run asynchronously" - ); + logger.info("All tables have been inserted with the data. The processes is run asynchronously"); process.exit(); }) .catch((err) => { diff --git a/src/scripts/view-data.js b/src/scripts/view-data.js index bcc1b465..7d321bf4 100644 --- a/src/scripts/view-data.js +++ b/src/scripts/view-data.js @@ -15,9 +15,7 @@ const viewData = async (modelName) => { }; if (process.argv.length === 2) { - logger.info( - `Please provide one of the following table name: [${_.keys(models)}]` - ); + logger.info(`Please provide one of the following table name: [${_.keys(models)}]`); process.exit(1); } else { const modelName = process.argv[2]; @@ -32,9 +30,7 @@ if (process.argv.length === 2) { process.exit(1); }); } else { - logger.info( - `Please provide one of the following table name: [${_.keys(models)}]` - ); + logger.info(`Please provide one of the following table name: [${_.keys(models)}]`); process.exit(1); } } From d2c123078eb58a8393838bbe3cfb4f79a1c2e25b Mon Sep 17 00:00:00 2001 From: Aranyajit Date: Tue, 6 Feb 2024 16:39:38 +0530 Subject: [PATCH 3/5] Deploy from feature and documentation changes --- .circleci/config.yml | 2 +- .nvmrc | 1 + README.md | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .nvmrc diff --git a/.circleci/config.yml b/.circleci/config.yml index 8e095a20..11ef4f61 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -90,7 +90,7 @@ workflows: branches: only: - dev - - CORE-40 + - feature/tsjr-365-remove-auth-get-skills - "build-qa": context: org-global diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..436d5c5d --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18.19.0 \ No newline at end of file diff --git a/README.md b/README.md index 4456de08..f2453a51 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,10 @@ You can find sample `.env` files inside the `/docs` directory. 1. 📦 Install npm dependencies ```bash + # export the production AWS credentials to access the topcoder-framework private repos in AWS codeartifact + aws codeartifact login --tool npm --repository topcoder-framework --domain topcoder --domain-owner 409275337247 --region us-east-1 --namespace @topcoder-framework + + # install dependencies yarn install ``` From 15553fb1a40e97f1eec31e38631072af07fca3b0 Mon Sep 17 00:00:00 2001 From: Aranyajit Date: Tue, 6 Feb 2024 17:09:44 +0530 Subject: [PATCH 4/5] docker fix for deployment --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 11ef4f61..96bca083 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,6 +9,7 @@ install_dependency: &install_dependency sudo apt install jq sudo apt install python3-pip sudo pip3 install awscli --upgrade + sudo pip3 install docker==6.1.3 sudo pip3 install docker-compose install_deploysuite: &install_deploysuite name: Installation of install_deploysuite. From 725aa5bab13ce20f39c434a3ac731ceef67580cb Mon Sep 17 00:00:00 2001 From: Aranyajit Date: Wed, 7 Feb 2024 15:01:40 +0530 Subject: [PATCH 5/5] remove deployment from feature as it has passed qa --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 96bca083..d6b7a729 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,7 +91,6 @@ workflows: branches: only: - dev - - feature/tsjr-365-remove-auth-get-skills - "build-qa": context: org-global