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

Commit 9757202

Browse files
committed
fixes issues from #1-9
1 parent c03ec5f commit 9757202

Some content is hidden

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

54 files changed

+874
-1249
lines changed

src/front/.editorconfig renamed to .editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ root = true
22

33
[*]
44
indent_style = space
5-
indent_size = 2
5+
indent_size = 4
66
charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
image: starefossen/ruby-node:latest
2-
3-
4-
variables:
5-
PORT: 3000
6-
APP_TITLE: "Lagertha app"
7-
NODE_ENV: development
8-
9-
services:
10-
- mongo
11-
12-
cache:
13-
paths:
14-
- node_modules/
15-
16-
stages:
17-
- build
18-
- test
19-
- deploy
20-
21-
building:
22-
script:
23-
- echo "Building the app"
24-
- npm i
25-
stage: build
26-
27-
testing:
28-
script:
29-
- echo "Running tests"
30-
- npm i
31-
- npm test
32-
stage: test
33-
34-
deploy_dev:
35-
stage: deploy
36-
script:
37-
- echo "Deploying the app"
38-
- apt-get update -qy
39-
- apt-get install -y rubygems ruby-dev
40-
- gem install dpl
41-
- dpl --provider=heroku --app=$HEROKU_DEV_APP --api-key=$HEROKU_DEV_API_KEY
42-
only:
43-
- develop
44-
environment:
45-
name: dev
46-
url: $HEROKU_DEV_URL
47-
48-
deploy_stage:
49-
stage: deploy
50-
script:
51-
- echo "Deploying the app"
52-
- apt-get update -qy
53-
- apt-get install -y rubygems ruby-dev
54-
- gem install dpl
55-
- dpl --provider=heroku --app=$HEROKU_STAGING_APP --api-key=$HEROKU_STAGING_API_KEY
56-
only:
57-
- master
58-
environment:
59-
name: stage
60-
url: $HEROKU_STAGING_URL
61-
variables:
62-
GIT_STRATEGY: fetch
63-
GIT_SUBMODULE_STRATEGY: recursive
64-
MONGODB_URI: mongodb://mongo:27017/ragnar'
1+
image: starefossen/ruby-node:latest
2+
3+
4+
variables:
5+
PORT: 3000
6+
APP_TITLE: "topcoder x app"
7+
NODE_ENV: development
8+
9+
services:
10+
- mongo
11+
12+
cache:
13+
paths:
14+
- node_modules/
15+
16+
stages:
17+
- build
18+
- test
19+
- deploy
20+
21+
building:
22+
script:
23+
- echo "Building the app"
24+
- npm i
25+
stage: build
26+
27+
testing:
28+
script:
29+
- echo "Running tests"
30+
- npm i
31+
- npm test
32+
stage: test
33+
34+
deploy_dev:
35+
stage: deploy
36+
script:
37+
- echo "Deploying the app"
38+
- apt-get update -qy
39+
- apt-get install -y rubygems ruby-dev
40+
- gem install dpl
41+
- dpl --provider=heroku --app=$HEROKU_DEV_APP --api-key=$HEROKU_DEV_API_KEY
42+
only:
43+
- develop
44+
environment:
45+
name: dev
46+
url: $HEROKU_DEV_URL
47+
48+
deploy_stage:
49+
stage: deploy
50+
script:
51+
- echo "Deploying the app"
52+
- apt-get update -qy
53+
- apt-get install -y rubygems ruby-dev
54+
- gem install dpl
55+
- dpl --provider=heroku --app=$HEROKU_STAGING_APP --api-key=$HEROKU_STAGING_API_KEY
56+
only:
57+
- master
58+
environment:
59+
name: stage
60+
url: $HEROKU_STAGING_URL
61+
variables:
62+
GIT_STRATEGY: fetch
63+
GIT_SUBMODULE_STRATEGY: recursive
64+
MONGODB_URI: mongodb://mongo:27017/topcoderx'

README.md

+14-90
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lagertha
1+
# Topcoder X app
22

33
## Requirements
44

@@ -50,91 +50,26 @@ npm run lint
5050

5151
## Configuration
5252

53-
Map the localhost to topcoderx.topcoder.com by editing `hosts` file.
54-
55-
The following config parameters are supported, they are defined in `config.js` and can be configured in system environment:
56-
57-
58-
| Name | Description | Default |
59-
| :------------------------------------- | :----------------------------------------: | :------------------------------: |
60-
| PORT | the port the application will listen on | 80 |
61-
| API_VERSION | the API version | v1 |
62-
| LOG_LEVEL | the log level | info |
63-
| MONGODB_URI | the MongoDB URI | mongodb://localhost:27017/topcoderx |
64-
| PASSWORD_HASH_SALT_LENGTH | the password hash salt length | 10 |
65-
| SESSION_SECRET | the session secret | kjsdfkj34857 |
66-
| GITHUB_CLIENT_ID | the GitHub client id | |
67-
| GITHUB_CLIENT_SECRET | the GitHub client secret | |
68-
| GITLAB_CLIENT_ID | the GitLab client id | |
69-
| GITLAB_CLIENT_SECRET | the GitLab client secret | |
70-
| WEBSITE | used as base to construct various URLs | http://topcoderx.topcoder-dev.com/ |
71-
72-
| GITLAB_API_BASE_URL | The Gitlab API base URL | https://gitlab.com/api/v4 |
73-
74-
| TC_LOGIN_URL | URL to do TopCoder login | |
75-
| TC_USER_PROFILE_URL | URL to to call TopCoder API to get profile from token | https://accounts.topcoder-dev.com/member?retUrl=http:%2F%2Ftopcoderx.topcoder-dev.com%2Fapi%2Fv1%2Ftclogin |
76-
|TOPIC | kafka topic| |
77-
|KAFKA_OPTIONS | kafka options| |
78-
79-
Other are just constants which don't need to be changed unless modified in code level.
80-
81-
## FE Configs
82-
83-
The frontend config file contains following variables to be configured in `src/front/config.js`
84-
85-
| Name | Description |
86-
|--------------------------|---------------------------------|
87-
| ADMIN_TOOL_URL | URL of the admin tool API |
88-
| COOKIES_SECURE | If true the cookies set by this App will only be transmitted over secure protocols like https. |
89-
| AUTH_URL | Url of Topcoder auth form |
90-
| ACCOUNTS_CONNECTOR_URL | Url to TC account connector |
91-
| JWT_V3_NAME | jwt V3 cookie name |
92-
| JWT_V2_NAME | jwt V2 cookie name |
93-
| DIRECT_URL_BASE | URL to be used for constructing the direct url|
94-
| LABELS | Labels we are going to add to the repository|
95-
| LABELS_COLOR | The colors for each label above |
96-
| HOOK_BASE_URL | The generated ngrok url of receiver service|
97-
98-
## GitHub OAuth App Setup
99-
100-
- login into github.com
101-
- click the upper right avatar, then click `Settings`
102-
- click the left panel --> Developer settings --> OAuth Apps
103-
- click the `Register a new application`, fill in the fields,
104-
note that the `Authorization callback URL` should be the deployed web site,
105-
for local deployment, it should be `http://topcoderx.topcoder-dev.com`
106-
- after creating the OAuth app, you can see its client id and client secret,
107-
these should be set to GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET environment variables
108-
109-
## GitLab OAuth App Setup
110-
111-
- login into gitlab.com
112-
- click the upper right avatar, then click `Settings`
113-
- click the `Applications` tab
114-
- enter application name, e.g. `Topcoder-x`
115-
- for Redirect URI, enter two callback URLs, one callback URL per line, so there are two lines:
116-
http://topcoderx.topcoder-dev.com/api/v1/gitlab/owneruser/callback
117-
http://topcoderx.topcoder-dev.com/api/v1/gitlab/normaluser/callback
118-
- for Scopes, check the `api` and `read_user`, the `api` is for owner user, the `read_user` is for normal user
119-
- finally click `Save application` to save the OAuth app, then you will see its generated Application Id and Secret,
120-
these should be set to GITLAB_CLIENT_ID and GITLAB_CLIENT_SECRET environment variables
121-
122-
## Local Setup
53+
please see [configuration.md](configuration.md).
54+
55+
## Local Deployment
12356

12457
```shell
12558
npm run serve
12659
```
12760

128-
Server should be started at port 80.
129-
130-
## Postman
61+
Server should be started at port 80.
13162

132-
Import docs/Ragnar.postman_collection.json and docs/Ragnar.postman_environment.json to Postman.
63+
## Heroku Deployment
64+
Follow the below steps to deploy the app to heroku
65+
1. `heroku login`
66+
1. `heroku create`
67+
1. `heroku addons:create mongolab`
68+
1. `heroku config:set NPM_CONFIG_PRODUCTION=false` so that heroku will install dev dependencies
69+
1. `git push heroku master` or `git push heroku develop:master` to deploy develop branch
70+
1. `heroku open` to load the app on browser
13371

134-
After admin login, the admin token is automatically set to ADMIN-TOKEN environment variable,
135-
then you may run the `Save GitHub User` and `Save GitLab User` tests to create owner user of your GitHub/GitLab usernames,
136-
note that you must modify the request body username to use your GitHub/GitLab user names.
137-
For the `Get User Mapping` test, you may query mapping by providing either topcoderUsername, githubUsername or gitlabUsername.
72+
Note: heroku domain should match subdomain of topcoder-dev or topcoder depending upon target topcoder environment
13873

13974
## Verification
14075

@@ -146,14 +81,3 @@ For the `Get User Mapping` test, you may query mapping by providing either topco
14681
- go to git access control menu and check list of groups have authorized
14782
- click get link button to get the shareable link which can be used by topcoder member to self assign to the repository.
14883

149-
## Heroku Deployment
150-
Follow the below steps to deploy the app to heroku
151-
1. `heroku login`
152-
1. `heroku create`
153-
1. `heroku addons:create mongolab`
154-
1. `heroku config:set NPM_CONFIG_PRODUCTION=false` so that heroku will install dev dependencies
155-
1. `git push heroku master` or `git push heroku develop:master` to deploy develop branch
156-
1. `heroku open` to load the app on browser
157-
158-
NOTE: Once environment variable are changed in heroku please run
159-
`heroku run npm run build`

configuration.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Topcoder x configuration
2+
3+
Map the localhost to topcoderx.topcoder-dev.com or topcoderx.topcoder.com depending upon target topcoder environment by editing `hosts` file.
4+
5+
The following config parameters are supported, they are defined in `src/config.js` and can be configured in system environment:
6+
7+
8+
| Name | Description | Default |
9+
| :------------------------------------- | :----------------------------------------: | :------------------------------: |
10+
| PORT | the port the application will listen on | 80 |
11+
| API_VERSION | the API version | v1 |
12+
| LOG_LEVEL | the log level | info |
13+
| MONGODB_URI | the MongoDB URI | mongodb://localhost:27017/topcoderx |
14+
| SESSION_SECRET | the session secret | kjsdfkj34857 |
15+
| GITHUB_CLIENT_ID | the GitHub client id | |
16+
| GITHUB_CLIENT_SECRET | the GitHub client secret | |
17+
| GITLAB_CLIENT_ID | the GitLab client id | |
18+
| GITLAB_CLIENT_SECRET | the GitLab client secret | |
19+
| WEBSITE | used as base to construct various URLs | http://topcoderx.topcoder-dev.com/ |
20+
| GITLAB_API_BASE_URL | The Gitlab API base URL | https://gitlab.com|
21+
|TOPIC | kafka topic| |
22+
|KAFKA_OPTIONS | kafka options| |
23+
| HOOK_BASE_URL | The generated ngrok url of receiver service|
24+
| TOPCODER_ENV | The topcoder environment to use, can support 'dev' or 'prod' | 'dev' |
25+
|LABELS| Labels we are going to add to the repository in the form of array of object with `name` and `colo` property. color should be hex code without hash||
26+
27+
## GitHub OAuth App Setup
28+
29+
- login into github.com
30+
- click the upper right avatar, then click `Settings`
31+
- click the left panel --> Developer settings --> OAuth Apps
32+
- click the `Register a new application`, fill in the fields,
33+
note that the `Authorization callback URL` should be the deployed web site,
34+
for local deployment, it should be `http://topcoderx.topcoder-dev.com`
35+
- after creating the OAuth app, you can see its client id and client secret,
36+
these should be set to GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET environment variables
37+
38+
## GitLab OAuth App Setup
39+
40+
- login into gitlab.com
41+
- click the upper right avatar, then click `Settings`
42+
- click the `Applications` tab
43+
- enter application name, e.g. `Topcoder-x`
44+
- for Redirect URI, enter two callback URLs, one callback URL per line, so there are two lines:
45+
http://topcoderx.topcoder-dev.com/api/v1/gitlab/owneruser/callback
46+
http://topcoderx.topcoder-dev.com/api/v1/gitlab/normaluser/callback
47+
- for Scopes, check the `api` and `read_user`, the `api` is for owner user, the `read_user` is for normal user
48+
- finally click `Save application` to save the OAuth app, then you will see its generated Application Id and Secret,
49+
these should be set to GITLAB_CLIENT_ID and GITLAB_CLIENT_SECRET environment variables
50+
51+
## Topcoder environment
52+
When application depends upon the environment of Topcoder based on TOPCODER_ENV configuration. When this value is 'dev'
53+
you should be using topcoderx.topcoder-dev.com.
54+
55+
To switch to production, simply change the TOPCODER_DEV to 'prod' and use topcoderx.topcoder.com
56+
57+
58+
Default configuration is for topcoder-dev environment.
59+
60+
## Credentials
61+
- for topcoder login in dev environment you can use any valid topcoder handle with default password 'appirio123'
62+
- for gitlab/github, you can use your own user account

gulp/build.js

+1-1
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/e2e-tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function runProtractor (done) {
1717

1818
gulp.src(paths.e2e + '/**/*.js')
1919
.pipe($.protractor.protractor({
20-
configFile: 'protractor.conf.js',
20+
configFile: 'src/front/protractor.conf.js',
2121
}))
2222
.on('error', function (err) {
2323
// Make sure failed tests cause gulp to exit non-zero

gulp/ng-config.js

-17
This file was deleted.

0 commit comments

Comments
 (0)