Skip to content

Commit e9d5ef2

Browse files
authored
Merge branch 'dev-challenges' into dev-challenge-templates
2 parents 1e65c93 + 43859dd commit e9d5ef2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4653
-174
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ workflows:
7676
- test
7777
filters:
7878
branches:
79-
only: dev
79+
only: 'dev'
8080
- deployProd:
8181
requires:
8282
- test

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:6.9.4
1+
FROM node:8.2.1
22
LABEL version="1.0"
33
LABEL description="Projects microservice"
44

config/custom-environment-variables.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"apiVersion": "API_VERSION",
3-
"authSecret": "AUTH_SECRET",
3+
"AUTH_SECRET": "AUTH_SECRET",
44
"logLevel": "LOG_LEVEL",
55
"version": "APP_VERSION",
66
"captureLogs": "CAPTURE_LOGS",
@@ -28,8 +28,12 @@
2828
"minPoolSize": "DB_MIN_POOL_SIZE"
2929
},
3030
"analyticsKey": "SEGMENT_ANALYTICS_KEY",
31-
"validIssuers": "VALID_ISSUERS",
31+
"VALID_ISSUERS": "VALID_ISSUERS",
3232
"jwksUri": "JWKS_URI",
3333
"busApiUrl": "BUS_API_URL",
34-
"busApiToken": "BUS_API_TOKEN"
34+
"AUTH0_URL" : "AUTH0_URL",
35+
"AUTH0_CLIENT_ID": "AUTH0_CLIENT_ID",
36+
"AUTH0_CLIENT_SECRET": "AUTH0_CLIENT_SECRET",
37+
"AUTH0_AUDIENCE": "AUTH0_AUDIENCE",
38+
"TOKEN_CACHE_TIME" : "TOKEN_CACHE_TIME"
3539
}

config/default.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"apiVersion": "v4",
3-
"authSecret": "secret",
4-
"authDomain": "topcoder-dev.com",
3+
"AUTH_SECRET": "secret",
54
"logLevel": "info",
65
"version": "v4",
76
"captureLogs": "false",
@@ -33,9 +32,16 @@
3332
"idleTimeout": 1000
3433
},
3534
"analyticsKey": "",
35+
"VALID_ISSUERS": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
3636
"validIssuers": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
3737
"jwksUri": "",
38-
"busApiUrl": "http://api.topcoder-dev.com",
38+
"busApiUrl": "http://api.topcoder-dev.com/v5",
3939
"busApiToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoicHJvamVjdC1zZXJ2aWNlIiwiaWF0IjoxNTEyNzQ3MDgyLCJleHAiOjE1MjEzODcwODJ9.PHuNcFDaotGAL8RhQXQMdpL8yOKXxjB5DbBIodmt7RE",
40-
"HEALTH_CHECK_URL": "_health"
40+
"HEALTH_CHECK_URL": "_health",
41+
"maxPhaseProductCount": 1,
42+
"AUTH0_CLIENT_ID": "",
43+
"AUTH0_CLIENT_SECRET": "",
44+
"AUTH0_AUDIENCE": "",
45+
"AUTH0_URL": "",
46+
"TOKEN_CACHE_TIME": ""
4147
}

config/development.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"authDomain": "topcoder-dev.com",
32
"pubsubQueueName": "dev.project.service",
43
"pubsubExchangeName": "dev.projects",
54
"attachmentsS3Bucket": "topcoder-dev-media"

config/test.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"authSecret": "secret",
3-
"authDomain": "topcoder-dev.com",
2+
"AUTH_SECRET": "secret",
43
"logLevel": "debug",
54
"captureLogs": "false",
65
"logentriesToken": "",

deploy.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ make_task_def(){
117117
"name": "BUS_API_URL",
118118
"value": "%s"
119119
},
120-
{
121-
"name": "BUS_API_TOKEN",
122-
"value": "%s"
123-
},
124120
{
125121
"name": "SYSTEM_USER_CLIENT_ID",
126122
"value": "%s"
@@ -156,6 +152,26 @@ make_task_def(){
156152
{
157153
"name": "SEGMENT_ANALYTICS_KEY",
158154
"value": "%s"
155+
},
156+
{
157+
"name": "AUTH0_URL",
158+
"value": "%s"
159+
},
160+
{
161+
"name": "AUTH0_AUDIENCE",
162+
"value": "%s"
163+
},
164+
{
165+
"name": "AUTH0_CLIENT_ID",
166+
"value": "%s"
167+
},
168+
{
169+
"name": "AUTH0_CLIENT_SECRET",
170+
"value": "%s"
171+
},
172+
{
173+
"name": "TOKEN_CACHE_TIME",
174+
"value": "%s"
159175
}
160176
],
161177
"portMappings": [
@@ -180,7 +196,6 @@ make_task_def(){
180196
MEMBER_SERVICE_ENDPOINT=$(eval "echo \$${ENV}_MEMBER_SERVICE_ENDPOINT")
181197
IDENTITY_SERVICE_ENDPOINT=$(eval "echo \$${ENV}_IDENTITY_SERVICE_ENDPOINT")
182198
BUS_API_URL=$(eval "echo \$${ENV}_BUS_API_URL")
183-
BUS_API_TOKEN=$(eval "echo \$${ENV}_BUS_API_TOKEN")
184199
SYSTEM_USER_CLIENT_ID=$(eval "echo \$${ENV}_SYSTEM_USER_CLIENT_ID")
185200
SYSTEM_USER_CLIENT_SECRET=$(eval "echo \$${ENV}_SYSTEM_USER_CLIENT_SECRET")
186201
CAPTURE_LOGS=$(eval "echo \$${ENV}_CAPTURE_LOGS")
@@ -201,7 +216,14 @@ make_task_def(){
201216
echo "NODE_ENV"
202217
echo $NODE_ENV
203218

204-
task_def=$(printf "$task_template" $family $ACCOUNT_ID $AWS_ECS_CONTAINER_NAME $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $API_VERSION $AWS_REGION $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY $AUTH_DOMAIN $AUTH_SECRET $VALID_ISSUERS $DB_MASTER_URL $MEMBER_SERVICE_ENDPOINT $IDENTITY_SERVICE_ENDPOINT $BUS_API_URL $BUS_API_TOKEN $SYSTEM_USER_CLIENT_ID $SYSTEM_USER_CLIENT_SECRET $PROJECTS_ES_URL $PROJECTS_ES_INDEX_NAME $RABBITMQ_URL $DIRECT_PROJECT_SERVICE_ENDPOINT $FILE_SERVICE_ENDPOINT $CONNECT_PROJECTS_URL $SEGMENT_ANALYTICS_KEY $PORT $PORT $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV)
219+
AUTH0_URL=$(eval "echo \$${ENV}_AUTH0_URL")
220+
AUTH0_AUDIENCE=$(eval "echo \$${ENV}_AUTH0_AUDIENCE")
221+
AUTH0_CLIENT_ID=$(eval "echo \$${ENV}_AUTH0_CLIENT_ID")
222+
AUTH0_CLIENT_SECRET=$(eval "echo \$${ENV}_AUTH0_CLIENT_SECRET")
223+
TOKEN_CACHE_TIME=$(eval "echo \$${ENV}_TOKEN_CACHE_TIME")
224+
225+
226+
task_def=$(printf "$task_template" $family $ACCOUNT_ID $AWS_ECS_CONTAINER_NAME $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $API_VERSION $AWS_REGION $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY $AUTH_DOMAIN $AUTH_SECRET $VALID_ISSUERS $DB_MASTER_URL $MEMBER_SERVICE_ENDPOINT $IDENTITY_SERVICE_ENDPOINT $BUS_API_URL $SYSTEM_USER_CLIENT_ID $SYSTEM_USER_CLIENT_SECRET $PROJECTS_ES_URL $PROJECTS_ES_INDEX_NAME $RABBITMQ_URL $DIRECT_PROJECT_SERVICE_ENDPOINT $FILE_SERVICE_ENDPOINT $CONNECT_PROJECTS_URL $SEGMENT_ANALYTICS_KEY "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME $PORT $PORT $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV)
205227
}
206228

207229
push_ecr_image(){
@@ -240,4 +262,4 @@ check_service_status() {
240262
configure_aws_cli
241263
push_ecr_image
242264
deploy_cluster
243-
check_service_status
265+
check_service_status

local/mock-services/authMiddleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = function def(req, res, next) {
2-
if (req.method === 'POST' && req.url === '/authorizations/') {
2+
if (req.method === 'POST' && (req.url === '/authorizations/' || req.url === '/authorizations')) {
33
const resp = {
44
id: '1',
55
result: {

local/mock-services/server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ server.use(authMiddleware);
2323
// add additional search route for project members
2424
server.get('/v3/members/_search', (req, res) => {
2525
const fields = _.isString(req.query.fields) ? req.query.fields.split(',') : [];
26-
const filter = _.isString(req.query.query) ? req.query.query.split(' OR ') : [];
26+
const filter = _.isString(req.query.query) ?
27+
req.query.query.replace('%2520', ' ').replace('%20', ' ').split(' OR ') : [];
2728
const criteria = _.map(filter, (single) => {
28-
const ret = { };
29+
const ret = {};
2930
const splitted = single.split(':');
3031
// if the result can be parsed successfully
3132
const parsed = jsprim.parseInteger(splitted[1], { allowTrailing: true, trimWhitespace: true });

local/mock-services/services.json

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,156 @@
9999
}
100100
},
101101
"version": "v3"
102+
},
103+
{
104+
"id": "test_customer1",
105+
"result": {
106+
"success": true,
107+
"status": 200,
108+
"metadata": null,
109+
"content": {
110+
"maxRating": {
111+
"rating": 1114,
112+
"track": "DATA_SCIENCE",
113+
"subTrack": "SRM"
114+
},
115+
"createdBy": "40011578",
116+
"updatedBy": "40011578",
117+
"userId": 40051331,
118+
"firstName": "Firstname",
119+
"lastName": "Lastname",
120+
"quote": "It is a mistake to think you can solve any major problems just with potatoes.",
121+
"description": null,
122+
"otherLangName": null,
123+
"handle": "test_customer1",
124+
"handleLower": "test_customer1",
125+
"status": "ACTIVE",
126+
"email": "test_customer1@email.com",
127+
"addresses": [
128+
{
129+
"streetAddr1": "100 Main Street",
130+
"streetAddr2": "",
131+
"city": "Chicago",
132+
"zip": "60601",
133+
"stateCode": "IL",
134+
"type": "HOME",
135+
"updatedAt": null,
136+
"createdAt": null,
137+
"createdBy": null,
138+
"updatedBy": null
139+
}
140+
],
141+
"homeCountryCode": "USA",
142+
"competitionCountryCode": "USA",
143+
"photoURL": null,
144+
"tracks": [
145+
"DEVELOP"
146+
],
147+
"updatedAt": "2015-12-02T14:00Z",
148+
"createdAt": "2014-04-10T10:55Z"
149+
}
150+
},
151+
"version": "v3"
152+
},
153+
{
154+
"id": "test_copilot1",
155+
"result": {
156+
"success": true,
157+
"status": 200,
158+
"metadata": null,
159+
"content": {
160+
"maxRating": {
161+
"rating": 1114,
162+
"track": "DATA_SCIENCE",
163+
"subTrack": "SRM"
164+
},
165+
"createdBy": "40011578",
166+
"updatedBy": "40011578",
167+
"userId": 40051332,
168+
"firstName": "Firstname",
169+
"lastName": "Lastname",
170+
"quote": "It is a mistake to think you can solve any major problems just with potatoes.",
171+
"description": null,
172+
"otherLangName": null,
173+
"handle": "test_copilot1",
174+
"handleLower": "test_copilot1",
175+
"status": "ACTIVE",
176+
"email": "test_copilot1@email.com",
177+
"addresses": [
178+
{
179+
"streetAddr1": "100 Main Street",
180+
"streetAddr2": "",
181+
"city": "Chicago",
182+
"zip": "60601",
183+
"stateCode": "IL",
184+
"type": "HOME",
185+
"updatedAt": null,
186+
"createdAt": null,
187+
"createdBy": null,
188+
"updatedBy": null
189+
}
190+
],
191+
"homeCountryCode": "USA",
192+
"competitionCountryCode": "USA",
193+
"photoURL": null,
194+
"tracks": [
195+
"DEVELOP"
196+
],
197+
"updatedAt": "2015-12-02T14:00Z",
198+
"createdAt": "2014-04-10T10:55Z"
199+
}
200+
},
201+
"version": "v3"
202+
},
203+
{
204+
"id": "test_manager1",
205+
"result": {
206+
"success": true,
207+
"status": 200,
208+
"metadata": null,
209+
"content": {
210+
"maxRating": {
211+
"rating": 1114,
212+
"track": "DATA_SCIENCE",
213+
"subTrack": "SRM"
214+
},
215+
"createdBy": "40011578",
216+
"updatedBy": "40011578",
217+
"userId": 40051333,
218+
"firstName": "Firstname",
219+
"lastName": "Lastname",
220+
"quote": "It is a mistake to think you can solve any major problems just with potatoes.",
221+
"description": null,
222+
"otherLangName": null,
223+
"handle": "test_manager1",
224+
"handleLower": "test_manager1",
225+
"status": "ACTIVE",
226+
"email": "test_manager1@email.com",
227+
"addresses": [
228+
{
229+
"streetAddr1": "100 Main Street",
230+
"streetAddr2": "",
231+
"city": "Chicago",
232+
"zip": "60601",
233+
"stateCode": "IL",
234+
"type": "HOME",
235+
"updatedAt": null,
236+
"createdAt": null,
237+
"createdBy": null,
238+
"updatedBy": null
239+
}
240+
],
241+
"homeCountryCode": "USA",
242+
"competitionCountryCode": "USA",
243+
"photoURL": null,
244+
"tracks": [
245+
"DEVELOP"
246+
],
247+
"updatedAt": "2015-12-02T14:00Z",
248+
"createdAt": "2014-04-10T10:55Z"
249+
}
250+
},
251+
"version": "v3"
102252
}
103253
]
104254
}

migrations/elasticsearch_sync.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ function getRequestBody(indexName) {
293293
},
294294
},
295295
},
296+
phases: {
297+
type: 'nested',
298+
dynamic: true,
299+
},
296300
},
297301
};
298302
switch (indexName) {

migrations/seedElasticsearchIndex.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,21 @@ Promise.coroutine(function* wrapped() {
3333
config.get('pubsubQueueName'),
3434
);
3535

36-
3736
const projectIds = getProjectIds();
3837
const projectWhereClause = (projectIds.length > 0) ? { id: { $in: projectIds } } : { deletedAt: { $eq: null } };
39-
const projects = yield models.Project.findAll({
38+
let projects = yield models.Project.findAll({
4039
where: projectWhereClause,
41-
raw: true,
40+
include: [{
41+
model: models.ProjectPhase,
42+
as: 'phases',
43+
include: [{ model: models.PhaseProduct, as: 'products' }],
44+
}],
4245
});
4346
logger.info(`Retrieved #${projects.length} projects`);
4447

48+
// Convert to raw json
49+
projects = _.map(projects, project => project.toJSON());
50+
4551
const memberWhereClause = (projectIds.length > 0)
4652
? { projectId: { $in: projectIds } }
4753
: { deletedAt: { $eq: null } };
@@ -59,14 +65,14 @@ Promise.coroutine(function* wrapped() {
5965
promises.push(rabbit.publish('project.initial', p, {}));
6066
});
6167
Promise.all(promises)
62-
.then(() => {
63-
logger.info(`Published ${promises.length} msgs`);
64-
process.exit();
65-
})
66-
.catch((err) => {
67-
logger.error(err);
68-
process.exit();
69-
});
68+
.then(() => {
69+
logger.info(`Published ${promises.length} msgs`);
70+
process.exit();
71+
})
72+
.catch((err) => {
73+
logger.error(err);
74+
process.exit();
75+
});
7076
} catch (err) {
7177
logger.error(err);
7278
process.exit();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"pg": "^4.5.5",
5656
"pg-native": "^1.10.0",
5757
"sequelize": "^3.23.0",
58-
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.2",
58+
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.3",
5959
"traverse": "^0.6.6",
6060
"urlencode": "^1.1.0"
6161
},

0 commit comments

Comments
 (0)