Skip to content

Commit bb693d2

Browse files
Improve README
1 parent d6f52d9 commit bb693d2

File tree

3 files changed

+88
-46
lines changed

3 files changed

+88
-46
lines changed

README.md

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
# Topcoder Challenge API
22

3-
## Dependencies
3+
This microservice provides access and interaction with all sorts of Challenge data.
44

5-
- nodejs https://nodejs.org/en/ (v10)
6-
- DynamoDB
7-
- AWS S3
8-
- Elasticsearch v6
9-
- Docker, Docker Compose
5+
## Swagger definition
6+
7+
- [Swagger](https://api.topcoder.com/v5/challenges/docs/)
8+
9+
## Intended use
10+
11+
- Production API
12+
13+
## Related repos
14+
15+
- [Resources API](https://github.com/topcoder-platform/resources-api)
16+
- [ES Processor](https://github.com/topcoder-platform/challenge-processor-es)
17+
- [Legacy Processor](https://github.com/topcoder-platform/legacy-challenge-processor)
18+
- [Legacy Migration Script](https://github.com/topcoder-platform/legacy-challenge-migration-script)
19+
- [Frontend App](https://github.com/topcoder-platform/challenge-engine-ui)
20+
21+
## Prerequisites
22+
- [NodeJS](https://nodejs.org/en/) (v10)
23+
- [DynamoDB](https://aws.amazon.com/dynamodb/)
24+
- [AWS S3](https://aws.amazon.com/s3/)
25+
- [Elasticsearch v6](https://www.elastic.co/)
26+
- [Docker](https://www.docker.com/)
27+
- [Docker Compose](https://docs.docker.com/compose/)
1028

1129
## Configuration
1230

@@ -46,46 +64,9 @@ The following parameters can be set in config files or in env variables:
4664
- SCOPES: the configurable M2M token scopes, refer `config/default.js` for more details
4765
- M2M_AUDIT_HANDLE: the audit name used when perform create/update operation using M2M token
4866

49-
Set the following environment variables so that the app can get TC M2M token (use 'set' insted of 'export' for Windows OS):
50-
51-
- export AUTH0_CLIENT_ID=8QovDh27SrDu1XSs68m21A1NBP8isvOt
52-
- export AUTH0_CLIENT_SECRET=3QVxxu20QnagdH-McWhVz0WfsQzA1F8taDdGDI4XphgpEYZPcMTF4lX3aeOIeCzh
53-
- export AUTH0_URL=https://topcoder-dev.auth0.com/oauth/token
54-
- export AUTH0_AUDIENCE=https://m2m.topcoder-dev.com/
55-
56-
Also properly configure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, ATTACHMENT_S3_BUCKET, IS_LOCAL_DB config parameters.
57-
58-
Test configuration is at `config/test.js`. You don't need to change them.
59-
The following test parameters can be set in config file or in env variables:
60-
61-
- ADMIN_TOKEN: admin token
62-
- COPILOT_TOKEN: copilot token
63-
- USER_TOKEN: user token
64-
- EXPIRED_TOKEN: expired token
65-
- INVALID_TOKEN: invalid token
66-
- M2M_FULL_ACCESS_TOKEN: M2M full access token
67-
- M2M_READ_ACCESS_TOKEN: M2M read access token
68-
- M2M_UPDATE_ACCESS_TOKEN: M2M update (including 'delete') access token
69-
- S3_ENDPOINT: endpoint of AWS S3 API, for unit and e2e test only; default to `localhost:9000`
70-
71-
## AWS S3 Setup
72-
Go to https://console.aws.amazon.com/ and login. Choose S3 from Service folder and click `Create bucket`. Following the instruction to create S3 bucket.
73-
74-
## Local services setup
75-
In the `local` folder, run `docker-compose up`
76-
It starts Elasticsearch, DynamoDB and S3 compatible server.
77-
78-
## Mock api
79-
For postman verification, please use the mock api under mock-api folder. It provides mock endpoint to fetch challenge resources and groups.
80-
You need to ensure DynamoDB configuration in `mock-api/config/default.js` is consistent with `config/default.js`
81-
Go to `mock-api` folder and run commands `npm i` and `npm start` to start the mock-api listening on port 4000
82-
83-
## Create Tables
84-
1. Make sure DynamoDB are running as per instructions above.
85-
2. Make sure you have configured all config parameters. Refer [Configuration](#configuration)
86-
3. Run `npm run create-tables` to create tables.
67+
You can find sample `.env` files inside the `/docs` directory.
8768

88-
## Scripts
69+
## Available commands
8970
1. Drop/delete tables: `npm run drop-tables`
9071
2. Creating tables: `npm run create-tables`
9172
3. Seed/Insert data to tables: `npm run seed-tables`
@@ -99,6 +80,22 @@ Go to `mock-api` folder and run commands `npm i` and `npm start` to start the mo
9980

10081
## Local Deployment
10182

83+
### AWS S3 Setup
84+
Go to https://console.aws.amazon.com/ and login. Choose S3 from Service folder and click `Create bucket`. Following the instruction to create S3 bucket.
85+
86+
### Local services setup
87+
In the `local` folder, run `docker-compose up` to start Elasticsearch, DynamoDB and S3 compatible server.
88+
89+
### Create Tables
90+
1. Make sure DynamoDB are running as per instructions above.
91+
2. Make sure you have configured all config parameters. Refer [Configuration](#configuration)
92+
3. Run `npm run create-tables` to create tables.
93+
94+
### Mock API
95+
The provided mock API provides mock endpoint to fetch challenge resources and groups so you don't have to deploy the related services locally.
96+
You need to ensure DynamoDB configuration in `mock-api/config/default.js` is consistent with `config/default.js`
97+
Go to `mock-api` folder and run commands `npm i` and `npm start` to start the mock-api listening on port 4000
98+
10299
- Install dependencies `npm install`
103100
- Run lint `npm run lint`
104101
- Run lint fix `npm run lint:fix`
@@ -110,8 +107,27 @@ Go to `mock-api` folder and run commands `npm i` and `npm start` to start the mo
110107
- App is running at `http://localhost:3000`
111108
- Start mock-api, go to `mock-api` folder, run `npm i` and `npm start`, mock api is running at `http://localhost:4000`
112109

110+
## Production deployment
111+
112+
- TBD
113+
113114
## Running tests
114115

116+
### Configuration
117+
118+
Test configuration is at `config/test.js`. You don't need to change them.
119+
The following test parameters can be set in config file or in env variables:
120+
121+
- ADMIN_TOKEN: admin token
122+
- COPILOT_TOKEN: copilot token
123+
- USER_TOKEN: user token
124+
- EXPIRED_TOKEN: expired token
125+
- INVALID_TOKEN: invalid token
126+
- M2M_FULL_ACCESS_TOKEN: M2M full access token
127+
- M2M_READ_ACCESS_TOKEN: M2M read access token
128+
- M2M_UPDATE_ACCESS_TOKEN: M2M update (including 'delete') access token
129+
- S3_ENDPOINT: endpoint of AWS S3 API, for unit and e2e test only; default to `localhost:9000`
130+
115131
### Prepare
116132
- Start Local services.
117133
- Start Mock API.
@@ -159,4 +175,3 @@ Refer to the verification document `Verification.md`
159175

160176
- In the app-constants.js Topics field, the used topics are using a test topic,
161177
the suggested ones are commented out, because these topics are not created in TC dev Kafka yet.
162-

docs/dev.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
AUTH0_CLIENT_ID=8QovDh27SrDu1XSs68m21A1NBP8isvOt
2+
AUTH0_CLIENT_SECRET=3QVxxu20QnagdH-McWhVz0WfsQzA1F8taDdGDI4XphgpEYZPcMTF4lX3aeOIeCzh
3+
AUTH0_URL=https://topcoder-dev.auth0.com/oauth/token
4+
AUTH0_AUDIENCE=https://m2m.topcoder-dev.com/

docs/prod.env

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
AUTH0_CLIENT_ID=
2+
AUTH0_CLIENT_SECRET=
3+
AUTH0_URL=
4+
AUTH0_AUDIENCE=
5+
AUTH_SECRET=
6+
BUSAPI_URL=
7+
AWS_ACCESS_KEY_ID=
8+
AWS_SECRET_ACCESS_KEY=
9+
AWS_REGION=
10+
IS_LOCAL_DB=false
11+
DYNAMODB_URL=
12+
ATTACHMENT_S3_BUCKET=
13+
S3_API_VERSION=
14+
ES_HOST=
15+
ES_API_VERSION=
16+
ES_INDEX=
17+
ES_TYPE=
18+
ES_REFRESH=true
19+
RESOURCES_API_URL=
20+
GROUPS_API_URL=
21+
PROJECTS_API_URL=
22+
COPILOT_RESOURCE_ROLE_IDS=
23+
M2M_AUDIT_HANDLE=

0 commit comments

Comments
 (0)