diff --git a/.circleci/config.yml b/.circleci/config.yml index ea9e3a7..aff788b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,6 +8,11 @@ defaults: &defaults LOG_LEVEL: debug AUTH_DOMAIN: topcoder-dev.com AUTH_SECRET: secret + API_URL_PROJECTS: http://localhost:3001/v4/projects + API_URL_MEMBERS: http://localhost:3001/v3/members + API_URL_USERS: http://localhost:3001/v3/users + API_URL_AUTHORIZATIONS: http://localhost:3001/v3/authorizations + API_URL_TOPICS: http://localhost:3001/v5/topics jobs: test: @@ -27,7 +32,7 @@ jobs: command: | echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add - - sudo apt-get update + sudo apt-get update --fix-missing sudo apt-get install rabbitmq-server sudo service rabbitmq-server start sudo cp local/rabbitmq_delayed_message_exchange-0.0.1.ez /usr/lib/rabbitmq/lib/rabbitmq_server-*/plugins diff --git a/README.md b/README.md index 22a63e1..2031032 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,11 @@ To override default settings please add them to a file `./config/local.js`: - `RABBITMQ.DELAY_DURATION`: Amount of delay before reposting unclaimed project - `RABBITMQ.NOTIFICATIONS_EXCHANGE_NAME`: the notification RabbitMQ's topic exchange name - `LOGENTRIES_TOKEN`: the Logentries token generated from https://logentries.com/ -- `API_BASE_URL`: the base url to the API server to get project/user info +- `API_URL_PROJECTS`: the projects service url +- `API_URL_MEMBERS`: `API_BASE_URL` the members service url +- `API_URL_USERS`: `API_BASE_URL` the users service url +- `API_URL_AUTHORIZATIONS`: `API_BASE_URL` the authorizations service url +- `API_URL_TOPICS`: `API_BASE_URL` the topics service url - `DISABLE_DELAY_EXCHANGE`: Disable exchage type delay and use 'direct' instead(Note: after changing this delete existing delay exchange ) - `TC_SLACK_WEBHOOK_URL`: slack webhook url - `SLACK_ICON_URL`: slack webhook icon url diff --git a/config/default.js b/config/default.js index 8b79921..aa0ffc0 100644 --- a/config/default.js +++ b/config/default.js @@ -31,8 +31,12 @@ module.exports = { // Token is generated from https://logentries.com/ LOGENTRIES_TOKEN: '', - // The base url to the project/user API server - API_BASE_URL: 'http://localhost:3001', + // The different services used by this project + API_URL_PROJECTS: 'http://localhost:3001/v4/projects', + API_URL_MEMBERS: 'http://localhost:3001/v3/members', + API_URL_USERS: 'http://localhost:3001/v3/users', + API_URL_AUTHORIZATIONS: 'http://localhost:3001/v3/authorizations', + API_URL_TOPICS: 'http://localhost:3001/v5/topics', // Disable delay exchange and use direct instead ( delete existing delay exchnge after changing) DISABLE_DELAY_EXCHANGE: false, diff --git a/config/development.json b/config/development.json index 5c21d36..cf2162c 100644 --- a/config/development.json +++ b/config/development.json @@ -8,5 +8,9 @@ "DELAYED_NOTIFICATIONS_EXCHANGE_NAME": "dev.connect-notifications-reminders" }, - "API_BASE_URL": "https://api.topcoder-dev.com" + "API_URL_PROJECTS": "http://api.topcoder-dev.com/v4/projects", + "API_URL_MEMBERS": "http://api.topcoder-dev.com/v3/members", + "API_URL_USERS": "http://api.topcoder-dev.com/v3/users", + "API_URL_AUTHORIZATIONS": "http://api.topcoder-dev.com/v3/authorizations", + "API_URL_TOPICS": "http://api.topcoder-dev.com/v5/topics" } diff --git a/config/production.json b/config/production.json index 314b319..0b861e1 100644 --- a/config/production.json +++ b/config/production.json @@ -11,5 +11,9 @@ "SLACK_CHANNEL_COPILOTS": "#connect-copilots", "SLACK_CHANNEL_NPS": "#customer-experience", - "API_BASE_URL": "https://api.topcoder.com" + "API_URL_PROJECTS": "http://api.topcoder.com/v4/projects", + "API_URL_MEMBERS": "http://api.topcoder.com/v3/members", + "API_URL_USERS": "http://api.topcoder.com/v3/users", + "API_URL_AUTHORIZATIONS": "http://api.topcoder.com/v3/authorizations", + "API_URL_TOPICS": "http://api.topcoder.com/v5/topics" } diff --git a/config/test.js b/config/test.js index 6fb73e3..b23cb28 100644 --- a/config/test.js +++ b/config/test.js @@ -22,7 +22,11 @@ module.exports = { DELAY_DURATION: 0, }, TC_SLACK_WEBHOOK_URL: 'http://localhost:3001/slack', - API_BASE_URL: 'http://localhost:3001', + API_URL_PROJECTS: 'http://localhost:3001/v4/projects', + API_URL_MEMBERS: 'http://localhost:3001/v3/members', + API_URL_USERS: 'http://localhost:3001/v3/users', + API_URL_AUTHORIZATIONS: 'http://localhost:3001/v3/authorizations', + API_URL_TOPICS: 'http://localhost:3001/v5/topics', AUTH0_URL: process.env.DEV_AUTH0_URL || '', AUTH0_AUDIENCE: process.env.DEV_AUTH0_AUDIENCE || '', TOKEN_CACHE_TIME: process.env.DEV_TOKEN_CACHE_TIME || 86400000, diff --git a/deploy.sh b/deploy.sh index d59a533..5dfa4a6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -86,6 +86,26 @@ make_task_def(){ { "name": "AUTH0_PROXY_SERVER_URL", "value": "%s" + }, + { + "name": "API_URL_PROJECTS", + "value": "%s" + }, + { + "name": "API_URL_MEMBERS", + "value": "%s" + }, + { + "name": "API_URL_USERS", + "value": "%s" + }, + { + "name": "API_URL_AUTHORIZATIONS", + "value": "%s" + }, + { + "name": "API_URL_TOPICS", + "value": "%s" } ], "logConfiguration": { @@ -108,6 +128,11 @@ make_task_def(){ AUTH0_CLIENT_ID=$(eval "echo \$${ENV}_AUTH0_CLIENT_ID") AUTH0_CLIENT_SECRET=$(eval "echo \$${ENV}_AUTH0_CLIENT_SECRET") AUTH0_PROXY_SERVER_URL=$(eval "echo \$${ENV}_AUTH0_PROXY_SERVER_URL") + API_URL_PROJECTS=$(eval "echo \$${ENV}_API_URL_PROJECTS") + API_URL_MEMBERS=$(eval "echo \$${ENV}_API_URL_MEMBERS") + API_URL_USERS=$(eval "echo \$${ENV}_API_URL_USERS") + API_URL_AUTHORIZATIONS=$(eval "echo \$${ENV}_API_URL_AUTHORIZATIONS") + API_URL_TOPICS=$(eval "echo \$${ENV}_API_URL_TOPICS") if [ "$ENV" = "PROD" ]; then NODE_ENV=production @@ -115,7 +140,7 @@ make_task_def(){ NODE_ENV=development fi - task_def=$(printf "$task_template" $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $RABBITMQ_URL $TC_SLACK_WEBHOOK_URL "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$AUTH0_PROXY_SERVER_URL" $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV) + task_def=$(printf "$task_template" $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $RABBITMQ_URL $TC_SLACK_WEBHOOK_URL "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$AUTH0_PROXY_SERVER_URL" "$API_URL_PROJECTS" "$API_URL_MEMBERS" "$API_URL_USERS" "$API_URL_AUTHORIZATIONS" "$API_URL_TOPICS" $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV) } push_ecr_image(){ diff --git a/src/common/constants.js b/src/common/constants.js index ee9bdee..07581fd 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -165,8 +165,8 @@ module.exports = { discourse: { project: { created: { - title: 'Your project has been created, and we\'re ready for your specification', - content: data => `Hello, Coder here! Your project '${data.projectName}' has been drafted. If you have your requirements documented, just verify it against our checklist and then upload it on the Scope section. Once you've finalized your scope, select the "Submit for Review" button. Topcoder will then review your drafted project and will assign a manager to get your delivery in-progress! Get stuck or need help? Email us at support@topcoder.com.`, + title: 'Share requirements and submit your draft project for review.', + content: data => `Your project '${data.projectName}' has been drafted. If you have requirements documented, share them for review under the Files or Links section. Once you’re ready, click the "Submit for Review" button. Topcoder will then review your drafted project and will get your project started! Get stuck or need help? Email us at support@topcoder.com.`, }, submittedForReview: { title: 'Your project has been submitted for review', diff --git a/src/handlers/util.js b/src/handlers/util.js index 525bca6..be53ddb 100644 --- a/src/handlers/util.js +++ b/src/handlers/util.js @@ -60,7 +60,7 @@ const createProjectDiscourseNotification = Promise.coroutine( return Promise.reject(new Error('Error retrieving system token')); } const options = { - url: `${config.get('API_BASE_URL')}/v5/topics/create`, + url: `${config.get('API_URL_TOPICS')}/create`, method: 'POST', headers: { Authorization: `Bearer ${token}`, @@ -138,7 +138,7 @@ function* getProjectById(id) { return Promise.reject(new Error('Error retrieving system token')); } return yield requestPromise({ - url: `${config.get('API_BASE_URL')}/v4/projects/${id}`, + url: `${config.get('API_URL_PROJECTS')}/${id}`, headers: { Authorization: `Bearer ${token}`, }, @@ -179,7 +179,7 @@ function* getUserById(id) { // eslint-disable-line require-yield } return reject(new Error('user not found')); }; - return requestPromise({ url: `${config.get('API_BASE_URL')}/v3/members/_search/?query=userId:${id}` }, cb); + return requestPromise({ url: `${config.get('API_URL_MEMBERS')}/_search/?query=userId:${id}` }, cb); } diff --git a/src/test/app.test.js b/src/test/app.test.js index a8dca54..80ebdab 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -216,33 +216,33 @@ describe('app', () => { // Stub the calls to API server stub = sinon.stub(request, 'get'); const stubArgs = { - url: `${config.API_BASE_URL}/v4/projects/1`, + url: `${config.API_URL_PROJECTS}/1`, }; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleProjects.project1); - stubArgs.url = `${config.API_BASE_URL}/v4/projects/1000`; + stubArgs.url = `${config.API_URL_PROJECTS}/1000`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 404 }); - stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:1`; + stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:1`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); - stubArgs.url = `${config.API_BASE_URL}/v3/users/1000`; + stubArgs.url = `${config.API_URL_USERS}/1000`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 404 }); - stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:40051331`; + stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:40051331`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); - stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:50051333`; + stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:50051333`; stub.withArgs(sinon.match.has('url', stubArgs.url)) .yields(null, { statusCode: 200 }, sampleUsers.user1); postStub = sinon.stub(request, 'post'); - postStub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/authorizations/`)) + postStub.withArgs(sinon.match.has('url', `${config.API_URL_AUTHORIZATIONS}/`)) .yields(null, { statusCode: 200 }, sampleAuth); postStub.withArgs(sinon.match.has('url', config.TC_SLACK_WEBHOOK_URL)) @@ -303,8 +303,8 @@ describe('app', () => { it('should create `Project.Created` notification', (done) => { sendTestEvent(sampleEvents.draftCreated, 'project.draft-created'); setTimeout(() => { - const expectedTitle = 'Your project has been created, and we\'re ready for your specification'; - const expectedBody = 'Hello, Coder here! Your project \'test\' has been drafted. If you have your requirements documented, just verify it against our checklist and then upload it on the Scope section. Once you\'ve finalized your scope, select the "Submit for Review" button. Topcoder will then review your drafted project and will assign a manager to get your delivery in-progress! Get stuck or need help? Email us at support@topcoder.com.'; + const expectedTitle = 'Share requirements and submit your draft project for review.'; + const expectedBody = 'Your project \'test\' has been drafted. If you have requirements documented, share them for review under the Files or Links section. Once you’re ready, click the "Submit for Review" button. Topcoder will then review your drafted project and will get your project started! Get stuck or need help? Email us at support@topcoder.com.'; const params = spy.lastCall.args; assert.equal(params[2], expectedTitle); assert.equal(params[3], expectedBody); @@ -319,7 +319,7 @@ describe('app', () => { const callbackCount = 1; request.get.restore(); stub = sinon.stub(request, 'get'); - stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/members/_search/?query=userId:8547900`)) + stub.withArgs(sinon.match.has('url', `${config.API_URL_MEMBERS}/_search/?query=userId:8547900`)) .yields(null, { statusCode: 200 }, sampleUsers.user1); sendTestEvent(sampleEvents.updatedInReview, 'project.updated');