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

Commit 7b01428

Browse files
committed
Merge remote-tracking branch 'origin/develop'
# Conflicts: # gulp/ng-config.js # src/front/config.json
2 parents 9a86ff8 + 682180b commit 7b01428

File tree

17 files changed

+205
-165
lines changed

17 files changed

+205
-165
lines changed

TopcoderXDeploy.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ KAFKA_CLIENT_CERT_KEY: <cert string>
6161
6262
KAFKA_URL: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
6363
64+
KAFKA_GROUP_ID: topcoder-x-processor
65+
6466
TOPIC: topcoder-x
6567
```
6668

@@ -71,6 +73,7 @@ So it would be updated from this:
7173
```
7274
KAFKA_OPTIONS: {
7375
connectionString: process.env.KAFKA_URL || 'localhost:9092',
76+
groupId: process.env.KAFKA_GROUP_ID || 'topcoder-x-processor',
7477
ssl: {
7578
cert: process.env.KAFKA_CLIENT_CERT || fs.readFileSync('./kafka_client.cer'), // eslint-disable-line no-sync
7679
key: process.env.KAFKA_CLIENT_CERT_KEY || fs.readFileSync('./kafka_client.key'), // eslint-disable-line no-sync
@@ -82,7 +85,8 @@ To this:
8285

8386
```
8487
KAFKA_OPTIONS: {
85-
connectionString: process.env.KAFKA_URL || 'localhost:9092'
88+
connectionString: process.env.KAFKA_URL || 'localhost:9092',
89+
groupId: process.env.KAFKA_GROUP_ID || 'topcoder-x-processor'
8690
},
8791
```
8892

@@ -188,6 +192,7 @@ ISSUE_BID_EMAIL_RECEIVER: [email protected]
188192
KAFKA_CLIENT_CERT: <cert>
189193
KAFKA_CLIENT_CERT_KEY: <key>
190194
KAFKA_URL: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
195+
KAFKA_GROUP_ID topcoder-x-processor
191196
LOG_LEVEL: debug
192197
MAILGUN_API_KEY: key-5ebe7a0fae37a9008721ec0bfe5bdd95
193198
MAILGUN_DOMAIN: sandbox3fcf4920781449f2a5293f8ef18e4bb6.mailgun.org

gulp/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ gulp.task('lint', () => {
113113
.pipe(eslint.failAfterError());
114114
});
115115

116-
gulp.task('build', ['ng-config', 'lint', 'html', 'images', 'fonts', 'fontawesome', 'misc']);
116+
gulp.task('build', ['lint', 'html', 'images', 'fonts', 'fontawesome', 'misc']);
117117
gulp.task('build:watch', ['watch:build']);

gulp/ng-config.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
"gulp-load-plugins": "^2.0.1",
122122
"gulp-minify-html": "~1.0.6",
123123
"gulp-ng-annotate": "~1.0.0",
124-
"gulp-ng-config": "^1.5.1",
125124
"gulp-protractor": "^4.1.1",
126125
"gulp-rename": "~1.2.0",
127126
"gulp-replace": "~0.5.0",

src/app.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,50 @@ process.on('unhandledRejection', (err) => {
148148
logger.logFullError(err, 'system');
149149
});
150150

151+
// dump the configuration to logger
152+
const ignoreConfigLog = [
153+
'cert',
154+
'key',
155+
'AWS_ACCESS_KEY_ID',
156+
'AWS_SECRET_ACCESS_KEY',
157+
'AUTH0_CLIENT_ID',
158+
'AUTH0_CLIENT_SECRET',
159+
'GITHUB_CLIENT_ID',
160+
'GITHUB_CLIENT_SECRET',
161+
'GITLAB_CLIENT_ID',
162+
'GITLAB_CLIENT_SECRET'
163+
];
164+
/**
165+
* Print configs to logger
166+
* @param {Object} params the config params
167+
* @param {Number} level the level of param object
168+
*/
169+
function dumpConfigs(params, level) {
170+
Object.keys(params).forEach((key) => {
171+
if (_.includes(ignoreConfigLog, key)) {
172+
return;
173+
}
174+
const item = params[key];
175+
let str = '';
176+
let n = 0;
177+
while (n < level) { // eslint-disable-line no-restricted-syntax
178+
n++;
179+
str += ' ';
180+
}
181+
if (item && _.isObject(item)) {
182+
str += `${key}=`;
183+
logger.debug(str);
184+
dumpConfigs(item, level + 1);
185+
} else {
186+
str += `${key}=${item}`;
187+
logger.debug(str);
188+
}
189+
});
190+
}
191+
logger.debug('--- List of Configurations ---');
192+
dumpConfigs(config, 0);
193+
logger.debug('--- End of List of Configurations ---');
194+
151195
const port = config.PORT;
152196
app.listen(port, '0.0.0.0');
153197
logger.info('Topcoder X server listening on port %d', port);

src/config.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,108 @@ module.exports = {
6868
},
6969
},
7070
};
71+
72+
const frontendConfigs = {
73+
"local":{
74+
"JWT_V3_NAME":"v3jwt",
75+
"JWT_V2_NAME":"tcjwt",
76+
"COOKIES_SECURE":false,
77+
"TC_LOGIN_URL": "https://accounts.topcoder-dev.com/member",
78+
"TC_USER_PROFILE_URL": "http://api.topcoder-dev.com/v2/user/profile",
79+
"API_URL": "https://127.0.0.1:8443",
80+
"ADMIN_TOOL_URL": "http://localhost:8080/api/v2",
81+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html",
82+
"DIRECT_URL_BASE": "https://www.topcoder-dev/direct/projectOverview?formData.projectId=",
83+
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
84+
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
85+
"TOPCODER_URL": "https://topcoder-dev.com",
86+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
87+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
88+
89+
},
90+
"heroku":{
91+
"JWT_V3_NAME":"v3jwt",
92+
"JWT_V2_NAME":"tcjwt",
93+
"COOKIES_SECURE":false,
94+
"TC_LOGIN_URL": "https://accounts.topcoder-dev.com/member",
95+
"TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile",
96+
"API_URL": "https://api.topcoder-dev.com",
97+
"ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2",
98+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html",
99+
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
100+
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
101+
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
102+
"TOPCODER_URL": "https://topcoder-dev.com",
103+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
104+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
105+
},
106+
"dev":{
107+
"JWT_V3_NAME":"v3jwt",
108+
"JWT_V2_NAME":"tcjwt",
109+
"COOKIES_SECURE":false,
110+
"TC_LOGIN_URL": "https://accounts.topcoder-dev.com/member",
111+
"TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile",
112+
"API_URL": "https://api.topcoder-dev.com",
113+
"ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2",
114+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html",
115+
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
116+
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
117+
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
118+
"TOPCODER_URL": "https://topcoder-dev.com",
119+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
120+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
121+
},
122+
"qa":{
123+
"JWT_V3_NAME":"v3jwt",
124+
"JWT_V2_NAME":"tcjwt",
125+
"COOKIES_SECURE":false,
126+
"TC_LOGIN_URL": "https://accounts.topcoder-dev.com/member",
127+
"TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile",
128+
"API_URL": "https://api.topcoder-qa.com",
129+
"ADMIN_TOOL_URL": "https://api.topcoder-qa.com/v2",
130+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-qa.com/connector.html",
131+
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
132+
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
133+
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
134+
"TOPCODER_URL": "https://topcoder-dev.com",
135+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
136+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
137+
},
138+
"prod":{
139+
"JWT_V3_NAME":"v3jwt",
140+
"JWT_V2_NAME":"tcjwt",
141+
"COOKIES_SECURE":false,
142+
"TC_LOGIN_URL": "https://accounts.topcoder.com/member",
143+
"TC_USER_PROFILE_URL": "https://api.topcoder.com/v2/user/profile",
144+
"API_URL": "https://api.topcoder.com",
145+
"ADMIN_TOOL_URL": "https://api.topcoder.com/v2",
146+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder.com/connector.html",
147+
"DIRECT_URL_BASE": "https://www.topcoder.com/direct/projectOverview?formData.projectId=",
148+
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
149+
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
150+
"TOPCODER_URL": "https://topcoder-dev.com",
151+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
152+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
153+
}
154+
};
155+
156+
const activeEnv = module.exports.TOPCODER_ENV;
157+
module.exports.frontendConfigs = {
158+
helpLink: module.exports.HELP_LINK,
159+
copilotRole: module.exports.COPILOT_ROLE,
160+
administratorRoles: module.exports.ADMINISTRATOR_ROLES,
161+
JWT_V3_NAME: process.env.JWT_V3_NAME || frontendConfigs[activeEnv].JWT_V3_NAME,
162+
JWT_V2_NAME: process.env.JWT_V2_NAME || frontendConfigs[activeEnv].JWT_V2_NAME,
163+
COOKIES_SECURE: process.env.COOKIES_SECURE || frontendConfigs[activeEnv].COOKIES_SECURE,
164+
TC_LOGIN_URL: process.env.TC_LOGIN_URL || frontendConfigs[activeEnv].TC_LOGIN_URL,
165+
TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || frontendConfigs[activeEnv].TC_USER_PROFILE_URL,
166+
API_URL: process.env.API_URL || frontendConfigs[activeEnv].API_URL,
167+
ADMIN_TOOL_URL: process.env.ADMIN_TOOL_URL || frontendConfigs[activeEnv].ADMIN_TOOL_URL,
168+
ACCOUNTS_CONNECTOR_URL: process.env.ACCOUNTS_CONNECTOR_URL || frontendConfigs[activeEnv].ACCOUNTS_CONNECTOR_URL,
169+
DIRECT_URL_BASE: process.env.DIRECT_URL_BASE || frontendConfigs[activeEnv].DIRECT_URL_BASE,
170+
OWNER_LOGIN_GITHUB_URL: process.env.OWNER_LOGIN_GITHUB_URL || frontendConfigs[activeEnv].OWNER_LOGIN_GITHUB_URL,
171+
OWNER_LOGIN_GITLAB_URL: process.env.OWNER_LOGIN_GITLAB_URL || frontendConfigs[activeEnv].OWNER_LOGIN_GITLAB_URL,
172+
TOPCODER_URL: process.env.TOPCODER_URL || frontendConfigs[activeEnv].TOPCODER_URL,
173+
GITHUB_TEAM_URL: process.env.GITHUB_TEAM_URL || frontendConfigs[activeEnv].GITHUB_TEAM_URL,
174+
GITLAB_GROUP_URL: process.env.GITLAB_GROUP_URL || frontendConfigs[activeEnv].GITLAB_GROUP_URL
175+
};

src/front/config.json

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/front/src/app/app.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ angular.module('topcoderX', [
1111
'ngResource',
1212
'ui.router',
1313
'ui.bootstrap',
14-
'app.constants',
1514
'angular-clipboard',
1615
'angular-jwt'])
1716
// In the run phase of your Angular application
@@ -52,7 +51,9 @@ angular.module('topcoderX', [
5251
});
5352
}],
5453
currentUser: ['AuthService', function (AuthService) {
55-
return AuthService.getCurrentUser();
54+
return AuthService.getAppConfig().then(function () {
55+
return AuthService.getCurrentUser();
56+
});
5657
}],
5758

5859
}
@@ -63,11 +64,10 @@ angular.module('topcoderX', [
6364
templateUrl: 'components/common/content.html',
6465
resolve: {
6566
currentUser: ['AuthService', function (AuthService) {
66-
return AuthService.getCurrentUser();
67-
}],
68-
AppConfig: ['AuthService', function (AuthService) {
69-
return AuthService.getAppConfig();
70-
}],
67+
return AuthService.getAppConfig().then(function () {
68+
return AuthService.getCurrentUser();
69+
});
70+
}]
7171
},
7272
})
7373
.state('app.main', {

src/front/src/app/auth/auth.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ angular.module('topcoderX')
3131
jwtInterceptorProvider.tokenGetter = [
3232
'AuthService', '$http', 'Helper', '$rootScope', 'config',
3333
function (AuthService, $http, Helper, $rootScope, config) {
34+
if (!$rootScope.appConfig) return;
3435
// token V2 for API V2
35-
if (config.url.indexOf(Helper.config().ADMIN_TOOL_URL) > -1) {
36+
if (config.url.indexOf($rootScope.appConfig.ADMIN_TOOL_URL) > -1) {
3637
if (AuthService.getTokenV2()) {
3738
return AuthService.getTokenV2();
3839
}
@@ -45,7 +46,7 @@ angular.module('topcoderX')
4546
if (refreshingToken === null) {
4647
refreshingToken = $http({
4748
method: 'GET',
48-
url: Helper.config().API_URL + "/v3/authorizations/1",
49+
url: $rootScope.appConfig.API_URL + "/v3/authorizations/1",
4950
headers: {
5051
'Authorization': "Bearer " + currentToken
5152
}

0 commit comments

Comments
 (0)