Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit cb3c452

Browse files
committed
merge dev
2 parents fe58dad + 3302c59 commit cb3c452

File tree

7 files changed

+37
-17
lines changed

7 files changed

+37
-17
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ To override default settings please add them to a file `./config/local.js`:
1919
- `RABBITMQ.DELAY_DURATION`: Amount of delay before reposting unclaimed project
2020
- `RABBITMQ.NOTIFICATIONS_EXCHANGE_NAME`: the notification RabbitMQ's topic exchange name
2121
- `LOGENTRIES_TOKEN`: the Logentries token generated from https://logentries.com/
22-
- `API_BASE_URL`: the base url to the API server to get project/user info
22+
- `API_URL_PROJECTS`: the projects service url
23+
- `API_URL_MEMBERS`: `API_BASE_URL` the members service url
24+
- `API_URL_USERS`: `API_BASE_URL` the users service url
25+
- `API_URL_AUTHORIZATIONS`: `API_BASE_URL` the authorizations service url
26+
- `API_URL_TOPICS`: `API_BASE_URL` the topics service url
2327
- `DISABLE_DELAY_EXCHANGE`: Disable exchage type delay and use 'direct' instead(Note: after changing this delete existing delay exchange )
2428
- `TC_SLACK_WEBHOOK_URL`: slack webhook url
2529
- `SLACK_ICON_URL`: slack webhook icon url

config/default.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ module.exports = {
3131
// Token is generated from https://logentries.com/
3232
LOGENTRIES_TOKEN: '',
3333

34-
// The base url to the project/user API server
35-
API_BASE_URL: 'http://localhost:3001',
34+
// The different services used by this project
35+
API_URL_PROJECTS: 'http://localhost:3001/v4/projects',
36+
API_URL_MEMBERS: 'http://localhost:3001/v3/members',
37+
API_URL_USERS: 'http://localhost:3001/v3/users',
38+
API_URL_AUTHORIZATIONS: 'http://localhost:3001/v3/authorizations',
39+
API_URL_TOPICS: 'http://localhost:3001/v5/topics',
3640

3741
// Disable delay exchange and use direct instead ( delete existing delay exchnge after changing)
3842
DISABLE_DELAY_EXCHANGE: false,

config/development.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
"DELAYED_NOTIFICATIONS_EXCHANGE_NAME": "dev.connect-notifications-reminders"
99
},
1010

11-
"API_BASE_URL": "https://api.topcoder-dev.com"
11+
"API_URL_PROJECTS": "http://api.topcoder-dev.com/v4/projects",
12+
"API_URL_MEMBERS": "http://api.topcoder-dev.com/v3/members",
13+
"API_URL_USERS": "http://api.topcoder-dev.com/v3/users",
14+
"API_URL_AUTHORIZATIONS": "http://api.topcoder-dev.com/v3/authorizations",
15+
"API_URL_TOPICS": "http://api.topcoder-dev.com/v5/topics"
1216
}

config/production.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@
1111
"SLACK_CHANNEL_COPILOTS": "#connect-copilots",
1212
"SLACK_CHANNEL_NPS": "#customer-experience",
1313

14-
"API_BASE_URL": "https://api.topcoder.com"
14+
"API_URL_PROJECTS": "http://api.topcoder.com/v4/projects",
15+
"API_URL_MEMBERS": "http://api.topcoder.com/v3/members",
16+
"API_URL_USERS": "http://api.topcoder.com/v3/users",
17+
"API_URL_AUTHORIZATIONS": "http://api.topcoder.com/v3/authorizations",
18+
"API_URL_TOPICS": "http://api.topcoder.com/v5/topics"
1519
}

config/test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ module.exports = {
2222
DELAY_DURATION: 0,
2323
},
2424
TC_SLACK_WEBHOOK_URL: 'http://localhost:3001/slack',
25-
API_BASE_URL: 'http://localhost:3001',
25+
API_URL_PROJECTS: 'http://localhost:3001/v4/projects',
26+
API_URL_MEMBERS: 'http://localhost:3001/v3/members',
27+
API_URL_USERS: 'http://localhost:3001/v3/users',
28+
API_URL_AUTHORIZATIONS: 'http://localhost:3001/v3/authorizations',
29+
API_URL_TOPICS: 'http://localhost:3001/v5/topics',
2630
AUTH0_URL: process.env.DEV_AUTH0_URL || '',
2731
AUTH0_AUDIENCE: process.env.DEV_AUTH0_AUDIENCE || '',
2832
TOKEN_CACHE_TIME: process.env.DEV_TOKEN_CACHE_TIME || 86400000,

src/handlers/util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const createProjectDiscourseNotification = Promise.coroutine(
6060
return Promise.reject(new Error('Error retrieving system token'));
6161
}
6262
const options = {
63-
url: `${config.get('API_BASE_URL')}/v5/topics/create`,
63+
url: `${config.get('API_URL_TOPICS')}/create`,
6464
method: 'POST',
6565
headers: {
6666
Authorization: `Bearer ${token}`,
@@ -138,7 +138,7 @@ function* getProjectById(id) {
138138
return Promise.reject(new Error('Error retrieving system token'));
139139
}
140140
return yield requestPromise({
141-
url: `${config.get('API_BASE_URL')}/v4/projects/${id}`,
141+
url: `${config.get('API_URL_PROJECTS')}/${id}`,
142142
headers: {
143143
Authorization: `Bearer ${token}`,
144144
},
@@ -179,7 +179,7 @@ function* getUserById(id) { // eslint-disable-line require-yield
179179
}
180180
return reject(new Error('user not found'));
181181
};
182-
return requestPromise({ url: `${config.get('API_BASE_URL')}/v3/members/_search/?query=userId:${id}` }, cb);
182+
return requestPromise({ url: `${config.get('API_URL_MEMBERS')}/_search/?query=userId:${id}` }, cb);
183183
}
184184

185185

src/test/app.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,33 +216,33 @@ describe('app', () => {
216216
// Stub the calls to API server
217217
stub = sinon.stub(request, 'get');
218218
const stubArgs = {
219-
url: `${config.API_BASE_URL}/v4/projects/1`,
219+
url: `${config.API_URL_PROJECTS}/1`,
220220
};
221221
stub.withArgs(sinon.match.has('url', stubArgs.url))
222222
.yields(null, { statusCode: 200 }, sampleProjects.project1);
223223

224-
stubArgs.url = `${config.API_BASE_URL}/v4/projects/1000`;
224+
stubArgs.url = `${config.API_URL_PROJECTS}/1000`;
225225
stub.withArgs(sinon.match.has('url', stubArgs.url))
226226
.yields(null, { statusCode: 404 });
227227

228-
stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:1`;
228+
stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:1`;
229229
stub.withArgs(sinon.match.has('url', stubArgs.url))
230230
.yields(null, { statusCode: 200 }, sampleUsers.user1);
231231

232-
stubArgs.url = `${config.API_BASE_URL}/v3/users/1000`;
232+
stubArgs.url = `${config.API_URL_USERS}/1000`;
233233
stub.withArgs(sinon.match.has('url', stubArgs.url))
234234
.yields(null, { statusCode: 404 });
235235

236-
stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:40051331`;
236+
stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:40051331`;
237237
stub.withArgs(sinon.match.has('url', stubArgs.url))
238238
.yields(null, { statusCode: 200 }, sampleUsers.user1);
239239

240-
stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:50051333`;
240+
stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:50051333`;
241241
stub.withArgs(sinon.match.has('url', stubArgs.url))
242242
.yields(null, { statusCode: 200 }, sampleUsers.user1);
243243

244244
postStub = sinon.stub(request, 'post');
245-
postStub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/authorizations/`))
245+
postStub.withArgs(sinon.match.has('url', `${config.API_URL_AUTHORIZATIONS}/`))
246246
.yields(null, { statusCode: 200 }, sampleAuth);
247247

248248
postStub.withArgs(sinon.match.has('url', config.TC_SLACK_WEBHOOK_URL))
@@ -319,7 +319,7 @@ describe('app', () => {
319319
const callbackCount = 1;
320320
request.get.restore();
321321
stub = sinon.stub(request, 'get');
322-
stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/members/_search/?query=userId:8547900`))
322+
stub.withArgs(sinon.match.has('url', `${config.API_URL_MEMBERS}/_search/?query=userId:8547900`))
323323
.yields(null, { statusCode: 200 }, sampleUsers.user1);
324324

325325
sendTestEvent(sampleEvents.updatedInReview, 'project.updated');

0 commit comments

Comments
 (0)