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

Commit a04de8b

Browse files
Merge pull request #629 from topcoder-platform/develop
Sync develop with master
2 parents 3dcfbad + 26590ce commit a04de8b

File tree

184 files changed

+26268
-16513
lines changed

Some content is hidden

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

184 files changed

+26268
-16513
lines changed

.circleci/config.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
version: 2
2+
defaults: &defaults
3+
docker:
4+
- image: circleci/python:2.7.18-stretch-browsers
5+
install_dependency: &install_dependency
6+
name: Installation of build and deployment dependencies.
7+
command: |
8+
sudo apt install jq
9+
sudo pip install awscli --upgrade
10+
sudo pip install docker-compose
11+
install_deploysuite: &install_deploysuite
12+
name: Installation of install_deploysuite.
13+
command: |
14+
git clone --branch v1.4.2 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
15+
cp ./../buildscript/master_deploy.sh .
16+
cp ./../buildscript/buildenv.sh .
17+
cp ./../buildscript/awsconfiguration.sh .
18+
restore_cache_settings_for_build: &restore_cache_settings_for_build
19+
key: docker-node-modules-{{ checksum "package-lock.json" }}
20+
21+
save_cache_settings: &save_cache_settings
22+
key: docker-node-modules-{{ checksum "package-lock.json" }}
23+
paths:
24+
- node_modules
25+
26+
builddeploy_steps: &builddeploy_steps
27+
- checkout
28+
- setup_remote_docker
29+
- run: *install_dependency
30+
- run: *install_deploysuite
31+
- restore_cache: *restore_cache_settings_for_build
32+
- run:
33+
name: Running MasterScript.
34+
command: |
35+
./awsconfiguration.sh $DEPLOY_ENV
36+
source awsenvconf
37+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar
38+
./build.sh ${APPNAME}
39+
rm -f buildenvvar
40+
- save_cache: *save_cache_settings
41+
- deploy:
42+
name: Running MasterScript.
43+
command: |
44+
# ./awsconfiguration.sh $DEPLOY_ENV
45+
source awsenvconf
46+
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
47+
source buildenvvar
48+
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
49+
50+
51+
jobs:
52+
# Build & Deploy against development backend
53+
"build-dev":
54+
<<: *defaults
55+
environment:
56+
DEPLOY_ENV: "DEV"
57+
LOGICAL_ENV: "dev"
58+
APPNAME: "ubahn_app"
59+
steps: *builddeploy_steps
60+
61+
"build-prod":
62+
<<: *defaults
63+
environment:
64+
DEPLOY_ENV: "PROD"
65+
LOGICAL_ENV: "prod"
66+
APPNAME: "ubahn_app"
67+
steps: *builddeploy_steps
68+
69+
workflows:
70+
version: 2
71+
build:
72+
jobs:
73+
# Development builds are executed on "develop" branch only.
74+
- "build-dev":
75+
context : org-global
76+
filters:
77+
branches:
78+
only:
79+
- develop
80+
- dev-circleci
81+
82+
# Production builds are exectuted only on tagged commits to the
83+
# master branch.
84+
- "build-prod":
85+
context : org-global
86+
filters:
87+
branches:
88+
only: master

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.idea
3+
**/.DS_Store
4+
.env
5+
coverage

.gitignore

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
.idea/
2-
.vscode/
3-
node_modules/
4-
build
5-
.DS_Store
6-
*.tgz
7-
my-app*
8-
template/src/__tests__/__snapshots__/
9-
lerna-debug.log
10-
npm-debug.log*
11-
yarn-debug.log*
12-
yarn-error.log*
13-
/.changelog
14-
.npm/
15-
yarn.lock
1+
node_modules
2+
.idea
3+
**/.DS_Store
4+
upload
5+
scripts/generate
6+
.nyc_output
7+
.env
8+
coverage
9+
docker/api.env

README.md

100644100755
Lines changed: 66 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,66 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2-
3-
## Available Scripts
4-
5-
In the project directory, you can run:
6-
7-
### `npm start`
8-
9-
Runs the app in the development mode.<br />
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11-
12-
The page will reload if you make edits.<br />
13-
You will also see any lint errors in the console.
14-
15-
### `npm test`
16-
17-
Launches the test runner in the interactive watch mode.<br />
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19-
20-
### `npm run build`
21-
22-
Builds the app for production to the `build` folder.<br />
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
24-
25-
The build is minified and the filenames include the hashes.<br />
26-
Your app is ready to be deployed!
27-
28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29-
30-
### `npm run eject`
31-
32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33-
34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35-
36-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37-
38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39-
40-
## Learn More
41-
42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43-
44-
To learn React, check out the [React documentation](https://reactjs.org/).
45-
46-
### Code Splitting
47-
48-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49-
50-
### Analyzing the Bundle Size
51-
52-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53-
54-
### Making a Progressive Web App
55-
56-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57-
58-
### Advanced Configuration
59-
60-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61-
62-
### Deployment
63-
64-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65-
66-
### `npm run build` fails to minify
67-
68-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
1+
# UBahn App
2+
3+
## Install software
4+
5+
- node 12.x
6+
- npm 6.x
7+
- docker
8+
- S3
9+
10+
## Deployment
11+
12+
There are two apps involved - a front end build using create react app and a backend which is a nodejs api
13+
14+
When working locally, you will run the following commands (after setting the necessary environment variables):
15+
16+
- npm install
17+
- cd client && npm install
18+
- cd .. && npm run dev
19+
20+
The front end proxies request (some of them) to localhost:3001, which is the backend api code base. This configuration is located in `client/package.json` file itself
21+
22+
Note that the environment variables for the React App start with REACT_APP_
23+
24+
## Local database deployment
25+
26+
1. Navigate to docker-db run `docker-compose up -d`
27+
2. Follow *Configuration* section to update config values
28+
3. Run `npm i` and `npm run lint`
29+
4. Create table, `npm run create-tables`, this will create tables (if you need this)
30+
5. Startup server `npm run start`
31+
32+
## Configuration
33+
34+
Configuration for the application is at `config/default.js` and `config/production.js`. The following parameters can be set in config files or in env variables:
35+
36+
- LOG_LEVEL: the log level
37+
- PORT: the server port
38+
- API_VERSION: the API version
39+
- AUTH_SECRET: TC Authentication secret
40+
- VALID_ISSUERS: valid issuers for TC authentication
41+
- AMAZON.AWS_ACCESS_KEY_ID: The AWS access key
42+
- AMAZON.AWS_SECRET_ACCESS_KEY: The AWS secret key
43+
- AMAZON.AWS_REGION: The Amazon region to use when connecting. For local dynamodb you can set fake value.
44+
- AMAZON.IS_LOCAL_DB: Use local or AWS Amazon DynamoDB
45+
- AMAZON.DYNAMODB_URL: The local url, if using local Amazon DynamoDB
46+
- AMAZON.DYNAMODB_READ_CAPACITY_UNITS: the AWS DynamoDB read capacity units, if using local Amazon DynamoDB
47+
- AMAZON.DYNAMODB_WRITE_CAPACITY_UNITS: the AWS DynamoDB write capacity units, if using local Amazon DynamoDB
48+
- AMAZON.DYNAMODB_UPLOAD_TABLE: DynamoDB table name for upload
49+
- AMAZON.DYNAMODB_TEMPLATE_TABLE: DynamoDB table name for template
50+
- AUTH0_URL: Auth0 URL, used to get TC M2M token
51+
- AUTH0_AUDIENCE: Auth0 audience, used to get TC M2M token
52+
- TOKEN_CACHE_TIME: Auth0 token cache time, used to get TC M2M token
53+
- AUTH0_CLIENT_ID: Auth0 client id, used to get TC M2M token
54+
- AUTH0_CLIENT_SECRET: Auth0 client secret, used to get TC M2M token
55+
- AUTH0_PROXY_SERVER_URL: Proxy Auth0 URL, used to get TC M2M token
56+
- BUSAPI_URL: the bus api, default value is `https://api.topcoder-dev.com/v5`
57+
- KAFKA_ERROR_TOPIC: Kafka error topic, default value is 'common.error.reporting'
58+
- KAFKA_MESSAGE_ORIGINATOR: the Kafka message originator, default value is 'ubahn-search-ui-api'
59+
- UPLOAD_CREATE_TOPIC: the upload create Kafka topic, default value is 'ubahn.action.create'
60+
- TEMPLATE_FILE_MAX_SIZE: the template file restrict size, default value is '2MB'
61+
- TEMPLATE_FILE_MIMETYPE: the template file accept type, default value is 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
62+
- TEMPLATE_S3_BUCKET: the template s3 bucket name, default value is 'ubahn'
63+
- UPLOAD_S3_BUCKET: the upload s3 bucket name, default value is 'ubahn'
64+
- S3_OBJECT_URL_EXPIRY_TIME: the s3 url expiry time, default value is '1 hour'
65+
66+
Also check out the client folder's README file for additional configurations to set for the front end. You can find the required configurations under client/src/config.js

app-bootstrap.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* App bootstrap
3+
*/
4+
global.Promise = require('bluebird')
5+
const Joi = require('joi')
6+
7+
Joi.id = () => Joi.string().uuid().required()

app-constants.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* App constants
3+
*/
4+
const UserRoles = {
5+
admin: 'Admin',
6+
administrator: 'Administrator',
7+
topcoderUser: 'Topcoder User',
8+
copilot: 'Copilot'
9+
}
10+
11+
const Scopes = {
12+
CreateUpload: 'create:upload',
13+
GetUpload: 'read:upload',
14+
UpdateUpload: 'update:upload',
15+
AllUpload: 'all:upload',
16+
CreateTemplate: 'create:template',
17+
GetTemplate: 'read:template',
18+
AllTemplate: 'all:template',
19+
GetSkill: 'read:skill',
20+
AllSkill: 'all:skill'
21+
}
22+
23+
const AllAuthenticatedUsers = [UserRoles.admin, UserRoles.administrator, UserRoles.topcoderUser, UserRoles.copilot]
24+
25+
module.exports = {
26+
Scopes,
27+
AllAuthenticatedUsers
28+
}

0 commit comments

Comments
 (0)