Skip to content

Commit a373fdb

Browse files
author
vikasrohit
authored
Merge pull request #186 from topcoder-platform/dev
Production Release: To support Connect 2.4.6
2 parents 38406b9 + 0642013 commit a373fdb

File tree

129 files changed

+6544
-1274
lines changed

Some content is hidden

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

129 files changed

+6544
-1274
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', 'feature/timeline-milestone']
79+
only: ['dev']
8080
- deployProd:
8181
requires:
8282
- test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
# Created by https://www.gitignore.io/api/node
33
config/local.js
4+
# can be used locally to config some env variables and after apply them using `source .env`
5+
.env
46
### Node ###
57
# Logs
68
logs

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Microservice to manage CRUD operations for all things Projects.
1818
Copy config/sample.local.js as config/local.js, update the properties and according to your env setup
1919

2020
#### Database
21-
Once you start your PostgreSQL database through docker, it will create a projectsDB.
21+
Once you start your PostgreSQL database through docker, it will create a projectsdb.
2222
*To create tables - note this will drop tables if they already exist*
2323
```
2424
NODE_ENV=development npm run sync:db
@@ -40,6 +40,33 @@ Run `npm run sync:es` from the root of project to execute the script.
4040
4141
**NOTE**: In production these dependencies / services are hosted & managed outside tc-projects-service.
4242

43+
#### Kafka
44+
Kafka must be installed and configured prior starting the application.
45+
Following topics must be created:
46+
```
47+
notifications.connect.project.updated
48+
notifications.connect.project.files.updated
49+
notifications.connect.project.team.updated
50+
notifications.connect.project.plan.updated
51+
notifications.connect.project.topic.created
52+
notifications.connect.project.topic.updated
53+
notifications.connect.project.post.created
54+
notifications.connect.project.post.edited
55+
```
56+
57+
New Kafka related configuration options has been introduced:
58+
```
59+
"kafkaConfig": {
60+
"hosts": List of Kafka brokers. Default: localhost: 9092
61+
"clientCert": SSL certificate
62+
"clientCertKey": Certificate key
63+
}
64+
```
65+
Environment variables:
66+
KAFKA_HOSTS - same as "hosts"
67+
KAFKA_CLIENT_CERT - same as "clientCert"
68+
KAFKA_CLIENT_CERT_KEY - same as "clientCertKey"
69+
4370
### Test
4471

4572
Each of the individual modules/services are unit tested.

config/custom-environment-variables.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"logLevel": "LOG_LEVEL",
55
"version": "APP_VERSION",
66
"captureLogs": "CAPTURE_LOGS",
7+
"enableFileUpload": "ENABLE_FILE_UPLOAD",
78
"logentriesToken": "LOGENTRIES_TOKEN",
89
"elasticsearchConfig": {
910
"host": "PROJECTS_ES_URL",
@@ -29,6 +30,12 @@
2930
"maxPoolSize": "DB_MAX_POOL_SIZE",
3031
"minPoolSize": "DB_MIN_POOL_SIZE"
3132
},
33+
"kafkaConfig": {
34+
"groupId": "KAFKA_GROUP_ID",
35+
"url": "KAFKA_URL",
36+
"clientCert": "KAFKA_CLIENT_CERT",
37+
"clientCertKey": "KAFKA_CLIENT_CERT_KEY"
38+
},
3239
"analyticsKey": "SEGMENT_ANALYTICS_KEY",
3340
"VALID_ISSUERS": "VALID_ISSUERS",
3441
"jwksUri": "JWKS_URI",
@@ -38,5 +45,6 @@
3845
"AUTH0_CLIENT_ID": "AUTH0_CLIENT_ID",
3946
"AUTH0_CLIENT_SECRET": "AUTH0_CLIENT_SECRET",
4047
"AUTH0_AUDIENCE": "AUTH0_AUDIENCE",
41-
"TOKEN_CACHE_TIME" : "TOKEN_CACHE_TIME"
48+
"TOKEN_CACHE_TIME" : "TOKEN_CACHE_TIME",
49+
"whitelistedOriginsForUserIdAuth": "WHITELISTED_ORIGINS_FOR_USERID_AUTH"
4250
}

config/default.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"logLevel": "info",
55
"version": "v4",
66
"captureLogs": "false",
7+
"enableFileUpload": "true",
78
"logentriesToken": "",
89
"rabbitmqURL": "",
910
"pubsubQueueName": "project.service",
@@ -33,6 +34,8 @@
3334
"minPoolSize": 4,
3435
"idleTimeout": 1000
3536
},
37+
"kafkaConfig": {
38+
},
3639
"analyticsKey": "",
3740
"VALID_ISSUERS": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
3841
"validIssuers": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
@@ -46,5 +49,6 @@
4649
"AUTH0_CLIENT_SECRET": "",
4750
"AUTH0_AUDIENCE": "",
4851
"AUTH0_URL": "",
49-
"TOKEN_CACHE_TIME": ""
52+
"TOKEN_CACHE_TIME": "",
53+
"whitelistedOriginsForUserIdAuth": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]"
5054
}

config/sample.local.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if (process.env.NODE_ENV === 'test') {
55
config = require('./test.json');
66
} else {
77
config = {
8+
identityServiceEndpoint: "http://dockerhost:3001/",
89
authSecret: 'secret',
910
authDomain: 'topcoder-dev.com',
1011
logLevel: 'debug',
@@ -14,9 +15,9 @@ if (process.env.NODE_ENV === 'test') {
1415
fileServiceEndpoint: 'https://api.topcoder-dev.com/v3/files/',
1516
directProjectServiceEndpoint: 'https://api.topcoder-dev.com/v3/direct',
1617
connectProjectsUrl: 'https://connect.topcoder-dev.com/projects/',
17-
memberServiceEndpoint: 'http://dockerhost:3001/members',
18+
memberServiceEndpoint: 'http://dockerhost:3001/v3/members',
1819
dbConfig: {
19-
masterUrl: 'postgres://coder:mysecretpassword@dockerhost:54321/projectsdb',
20+
masterUrl: 'postgres://coder:mysecretpassword@dockerhost:5432/projectsdb',
2021
maxPoolSize: 50,
2122
minPoolSize: 4,
2223
idleTimeout: 1000,
@@ -28,6 +29,7 @@ if (process.env.NODE_ENV === 'test') {
2829
indexName: 'projects',
2930
docType: 'projectV4'
3031
},
32+
whitelistedOriginsForUserIdAuth: "[\"\"]",
3133
};
3234
}
3335
module.exports = config;

config/test.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
"maxPoolSize": 50,
1919
"minPoolSize": 4,
2020
"idleTimeout": 1000
21-
}
21+
},
22+
"whitelistedOriginsForUserIdAuth": "[\"\"]"
2223
}

deploy.sh

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ make_task_def(){
5454
"name": "%s",
5555
"image": "%s.dkr.ecr.%s.amazonaws.com/%s:%s",
5656
"essential": true,
57-
"memory": 200,
58-
"cpu": 10,
57+
"memory": 1536,
58+
"cpu": 768,
5959
"environment": [
6060
{
6161
"name": "NODE_ENV",
6262
"value": "%s"
6363
},
64+
{
65+
"name": "ENABLE_FILE_UPLOAD",
66+
"value": "%s"
67+
},
6468
{
6569
"name": "LOG_LEVEL",
6670
"value": "%s"
@@ -176,6 +180,22 @@ make_task_def(){
176180
{
177181
"name": "TOKEN_CACHE_TIME",
178182
"value": "%s"
183+
},
184+
{
185+
"name": "KAFKA_CLIENT_CERT",
186+
"value": "%s"
187+
},
188+
{
189+
"name": "KAFKA_CLIENT_CERT_KEY",
190+
"value": "%s"
191+
},
192+
{
193+
"name": "KAFKA_GROUP_ID",
194+
"value": "%s"
195+
},
196+
{
197+
"name": "KAFKA_URL",
198+
"value": "%s"
179199
}
180200
],
181201
"portMappings": [
@@ -220,15 +240,20 @@ make_task_def(){
220240
fi
221241
echo "NODE_ENV"
222242
echo $NODE_ENV
243+
ENABLE_FILE_UPLOAD=$(eval "echo \$${ENV}_ENABLE_FILE_UPLOAD")
223244

224245
AUTH0_URL=$(eval "echo \$${ENV}_AUTH0_URL")
225246
AUTH0_AUDIENCE=$(eval "echo \$${ENV}_AUTH0_AUDIENCE")
226247
AUTH0_CLIENT_ID=$(eval "echo \$${ENV}_AUTH0_CLIENT_ID")
227248
AUTH0_CLIENT_SECRET=$(eval "echo \$${ENV}_AUTH0_CLIENT_SECRET")
228249
TOKEN_CACHE_TIME=$(eval "echo \$${ENV}_TOKEN_CACHE_TIME")
250+
KAFKA_CLIENT_CERT=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT")
251+
KAFKA_CLIENT_CERT_KEY=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT_KEY")
252+
KAFKA_GROUP_ID=$(eval "echo \$${ENV}_KAFKA_GROUP_ID")
253+
KAFKA_URL=$(eval "echo \$${ENV}_KAFKA_URL")
229254

230255

231-
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 $MESSAGE_SERVICE_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)
256+
task_def=$(printf "$task_template" $family $ACCOUNT_ID $AWS_ECS_CONTAINER_NAME $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $ENABLE_FILE_UPLOAD $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 $MESSAGE_SERVICE_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 "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID $KAFKA_URL $PORT $PORT $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV)
232257
}
233258

234259
push_ecr_image(){

local/mock-services/services.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,56 @@
249249
}
250250
},
251251
"version": "v3"
252+
},
253+
{
254+
"id": "test_admin1",
255+
"result": {
256+
"success": true,
257+
"status": 200,
258+
"metadata": null,
259+
"content": {
260+
"maxRating": {
261+
"rating": 1114,
262+
"track": "DATA_SCIENCE",
263+
"subTrack": "SRM"
264+
},
265+
"createdBy": "40011578",
266+
"updatedBy": "40011578",
267+
"userId": 40135978,
268+
"firstName": "Adminname",
269+
"lastName": "Adminlastname",
270+
"quote": "It is a mistake to think you can solve any major problems just with potatoes.",
271+
"description": null,
272+
"otherLangName": null,
273+
"handle": "test_admin1",
274+
"handleLower": "test_admin1",
275+
"status": "ACTIVE",
276+
"email": "pshah1@test.com",
277+
"addresses": [
278+
{
279+
"streetAddr1": "100 Main Street",
280+
"streetAddr2": "",
281+
"city": "Chicago",
282+
"zip": "60601",
283+
"stateCode": "IL",
284+
"type": "HOME",
285+
"updatedAt": null,
286+
"createdAt": null,
287+
"createdBy": null,
288+
"updatedBy": null
289+
}
290+
],
291+
"homeCountryCode": "USA",
292+
"competitionCountryCode": "USA",
293+
"photoURL": null,
294+
"tracks": [
295+
"DEVELOP"
296+
],
297+
"updatedAt": "2015-12-02T14:00Z",
298+
"createdAt": "2014-04-10T10:55Z"
299+
}
300+
},
301+
"version": "v3"
252302
}
253303
]
254304
}

migrations/20180608_project_add_templateId_and_new_tables.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ CREATE TABLE milestones (
4545
"activeText" character varying(512) NOT NULL,
4646
"completedText" character varying(512) NOT NULL,
4747
"blockedText" character varying(512) NOT NULL,
48+
"hidden" boolean DEFAULT false,
4849
"deletedAt" timestamp with time zone,
4950
"createdAt" timestamp with time zone,
5051
"updatedAt" timestamp with time zone,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--
2+
-- UPDATE EXISTING TABLES:
3+
-- product_milestone_templates:
4+
-- removed constraint `product_milestone_templates_productTemplateId_fkey`
5+
-- changed column `productTemplateId` to `referenceId`
6+
-- added column `reference`
7+
-- added column `metadata`
8+
-- changed table name to `milestone_templates`
9+
10+
--
11+
-- product_milestone_templates
12+
--
13+
ALTER TABLE product_milestone_templates DROP CONSTRAINT "product_milestone_templates_productTemplateId_fkey";
14+
15+
ALTER TABLE product_milestone_templates RENAME COLUMN "productTemplateId" TO "referenceId";
16+
17+
ALTER TABLE product_milestone_templates ADD COLUMN "reference" character varying(45);
18+
UPDATE product_milestone_templates set reference='productTemplate' where reference is null;
19+
ALTER TABLE product_milestone_templates ALTER COLUMN "reference" SET NOT NULL;
20+
21+
ALTER TABLE product_milestone_templates ADD COLUMN "metadata" json;
22+
UPDATE product_milestone_templates set metadata='{}' where metadata is null;
23+
ALTER TABLE product_milestone_templates ALTER COLUMN "metadata" SET NOT NULL;
24+
25+
ALTER TABLE product_milestone_templates RENAME TO milestone_templates;
26+
27+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--
2+
-- UPDATE EXISTING TABLES:
3+
-- project_phases:
4+
-- added column `order`
5+
6+
--
7+
-- project_phases
8+
--
9+
ALTER TABLE project_phases ADD COLUMN "order" integer NULL;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--
2+
-- UPDATE EXISTING TABLES:
3+
-- projects:
4+
-- added column `lastActivityAt`
5+
-- added column `lastActivityUserId`
6+
7+
--
8+
-- projects
9+
10+
-- Add new columns
11+
ALTER TABLE projects ADD COLUMN "lastActivityAt" timestamp with time zone;
12+
ALTER TABLE projects ADD COLUMN "lastActivityUserId" character varying(45);
13+
-- Update new colums
14+
UPDATE projects SET "lastActivityAt"="updatedAt" WHERE "lastActivityAt" is NULL;
15+
UPDATE projects SET "lastActivityUserId"=cast("updatedBy" as varchar) WHERE "lastActivityUserId" is NULL;
16+
-- Set not null
17+
ALTER TABLE projects ALTER COLUMN "lastActivityAt" SET NOT NULL;
18+
ALTER TABLE projects ALTER COLUMN "lastActivityUserId" SET NOT NULL;

migrations/elasticsearch_sync.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ function getRequestBody(indexName) {
281281
updatedBy: {
282282
type: 'integer',
283283
},
284+
lastActivityAt: {
285+
type: 'date',
286+
format: 'strict_date_optional_time||epoch_millis',
287+
},
288+
lastActivityUserId: {
289+
type: 'string',
290+
},
284291
utm: {
285292
properties: {
286293
campaign: {

0 commit comments

Comments
 (0)