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

Commit 1c25683

Browse files
1. Update api to support create / update and deletion of leaderboard
2. Update get api to support groupId based filter
1 parent 4ee9b2b commit 1c25683

24 files changed

+4663
-150
lines changed

README.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## Dependencies
44

55
- nodejs (v10)
6-
- Kafka (v2)
76
- Mongodb (v4)
87

98
## Configuration
@@ -14,6 +13,15 @@ The following parameters can be set in config files or in env variables:
1413
- LOG_LEVEL: the log level
1514
- PORT: the server port
1615
- MONGODB_URL: Mongo DB URL
16+
- CHALLENGE_API_URL: the Topcoder challenge API URL
17+
- MEMBER_API_URL: the Topcoder member API URL
18+
- GROUP_IDS: the valid group ids
19+
- AUTH0_URL: Auth0 URL, used to get TC M2M token
20+
- AUTH0_AUDIENCE: Auth0 audience, used to get TC M2M token
21+
- TOKEN_CACHE_TIME: Auth0 token cache time, used to get TC M2M token
22+
- AUTH0_CLIENT_ID: Auth0 client id, used to get TC M2M token
23+
- AUTH0_CLIENT_SECRET: Auth0 client secret, used to get TC M2M token
24+
- AUTH0_PROXY_SERVER_URL: Proxy Auth0 URL, used to get TC M2M token
1725

1826
## Local deployment
1927

@@ -31,12 +39,23 @@ npm run lint
3139
npm run lint:fix # To fix possible lint errors
3240
```
3341

42+
- Clear and Insert data into database
43+
44+
```bash
45+
npm run init-db
46+
47+
npm run test-data
48+
```
49+
3450
- Start the express server
3551

3652
```bash
3753
npm start
3854
```
3955

56+
## Mock API
57+
For verification purpose, we need a mock app for Topcoder Challenge API and Topcoder Member API. You can run command `npm run mock-api` to start the mock app.
58+
4059
## Heroku Deployment
4160

4261
- git init
@@ -48,4 +67,36 @@ npm start
4867

4968
## Verification
5069

51-
- Import the collection and environment into your POSTMAN app and check out the endpoints
70+
### Tests
71+
72+
- Run the following command to execute unit test and generate coverage report
73+
74+
```bash
75+
npm run test
76+
```
77+
78+
- Run the following command to execute e2e test and generate coverage report
79+
80+
```bash
81+
npm run e2e
82+
```
83+
84+
### Postman
85+
86+
- Start mock app and it will listen on 3001 PORT.
87+
88+
```bash
89+
npm run mock-api
90+
```
91+
92+
- Ensure you have start MongoDB and properly configure `MONGODB_URL`. Run the following commands to clear and insert test data, step up environment variables and start the app.
93+
94+
```bash
95+
npm run init-db
96+
npm run test-data
97+
export CHALLENGE_API_URL=http://localhost:3001/challenges
98+
export MEMBER_API_URL=http://localhost:3001/users
99+
npm start
100+
```
101+
102+
- Import the collection and environment into your POSTMAN app and run the test case from top to down.

config/default.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,16 @@ module.exports = {
66
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',
77
PORT: process.env.PORT || 3000,
88

9-
MONGODB_URL: process.env.MONGODB_URL || 'mongodb://localhost:27017/leaderboardDB'
9+
MONGODB_URL: process.env.MONGODB_URL || 'mongodb://localhost:27017/leaderboardDB',
10+
CHALLENGE_API_URL: process.env.CHALLENGE_API_URL || 'https://api.topcoder-dev.com/v3/challenges',
11+
MEMBER_API_URL: process.env.MEMBER_API_URL || 'https://api.topcoder-dev.com/v3/users',
12+
13+
GROUP_IDS: process.env.GROUP_IDS || '202343,20000000', // Comma separated string of Group IDs
14+
15+
AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token',
16+
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE || 'https://m2m.topcoder-dev.com/',
17+
TOKEN_CACHE_TIME: process.env.TOKEN_CACHE_TIME || 90,
18+
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID || '8QovDh27SrDu1XSs68m21A1NBP8isvOt',
19+
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET || '3QVxxu20QnagdH-McWhVz0WfsQzA1F8taDdGDI4XphgpEYZPcMTF4lX3aeOIeCzh',
20+
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL
1021
}

config/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Test configuration file
3+
*/
4+
5+
module.exports = {
6+
CHALLENGE_API_URL: 'https://api.topcoder-dev.com/v3/challenges',
7+
MEMBER_API_URL: 'https://api.topcoder-dev.com/v3/users',
8+
MOCK_API_PORT: 3001
9+
}

0 commit comments

Comments
 (0)