diff --git a/.circleci/config.yml b/.circleci/config.yml index 8e095a20..9b3e468f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,19 +1,15 @@ version: 2 defaults: &defaults docker: - - image: cimg/python:3.11.0-browsers + - image: cimg/python:3.12.1-browsers install_dependency: &install_dependency name: Installation of build and deployment dependencies. command: | - sudo apt update - sudo apt install jq - sudo apt install python3-pip - sudo pip3 install awscli --upgrade - sudo pip3 install docker-compose + pip3 install awscli --upgrade install_deploysuite: &install_deploysuite name: Installation of install_deploysuite. command: | - git clone --branch v1.4.15 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript + git clone --branch v1.4.17 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript cp ./../buildscript/master_deploy.sh . cp ./../buildscript/buildenv.sh . cp ./../buildscript/awsconfiguration.sh . @@ -90,7 +86,6 @@ workflows: branches: only: - dev - - CORE-40 - "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 ``` 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 d0183dc2..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"; @@ -1157,15 +1156,11 @@ 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}` }, - } + `${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); } }