Skip to content

Commit 9fb5ec2

Browse files
committed
outpout of challenge 30146494
1 parent 4d2dd18 commit 9fb5ec2

23 files changed

+1371
-293
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- nodejs https://nodejs.org/en/ (v12+)
66
- Postgres
7+
- ElasticSearch (7.x)
78

89
## Configuration
910

@@ -15,27 +16,48 @@ The following parameters can be set in config files or in env variables:
1516
- `BASE_PATH`: the server api base path
1617
- `AUTH_SECRET`: The authorization secret used during token verification.
1718
- `VALID_ISSUERS`: The valid issuer of tokens, a json array contains valid issuer.
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
1825
- `POSTGRES_URL`: Postgres database url.
1926
- `DB_SCHEMA_NAME`: string - postgres database target schema
2027
- `PROJECT_API_URL`: the project service url
28+
- `TC_API`: the topcoder v5 url
29+
- `ORG_ID`: the organization id
30+
- `HOST`: the elasticsearch host
31+
- `ES_INDEX_JOB`: the job index
32+
- `ES_INDEX_JOB_CANDIDATE`: the job candidate index
33+
- `ES_INDEX_RESOURCE_BOOKING`: the resource booking index
2134

2235

2336
## Postgres Database Setup
2437
Go to https://www.postgresql.org/ download and install the Postgres.
2538
Modify `POSTGRES_URL` under `config/default.js` to meet your environment.
2639
Run `npm run init-db` to create table
2740

41+
## ElasticSearch Setup
42+
Go to https://www.elastic.co/downloads/ download and install the elasticsearch.
43+
Modify `esConfig` under `config/default.js` to meet your environment.
44+
Run `npm run create-index` to create ES index.
45+
Run `npm run delete-index` to delete ES index.
46+
2847
## Local Deployment
2948

3049
- Install dependencies `npm install`
3150
- Run lint `npm run lint`
3251
- Run lint fix `npm run lint:fix`
3352
- Clear and init db `npm run init-db`
53+
- Clear and create es index `npm run delete-index, npm run create-index`
3454
- Start app `npm start`
3555
- App is running at `http://localhost:3000`
3656

3757
## Testing
38-
- Run mock-project-service app
58+
- Run tools/mock-project-service app
59+
- Run `npm run init-db`
60+
- Run `npm run create-index`
3961
- Run `npm run test` to execute unit tests
4062
- Run `npm run cov` to execute unit tests and generate coverage report.
4163

Verification.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
# Topcoder Bookings API
22

33
## Postman test
4-
- Refer `mock-project-service/ReadMe.md` to start the mock app
4+
- Refer `tools/mock-project-service/ReadMe.md` to start the mock app
55
- Refer `ReadMe.md` to start the app and postgres database
66
- Run `npm run init-db` to init db before testing.
7+
- Run `npm run create-index` to create es index before testing
78
- Import Postman collection and environment file in the `docs` folder to Postman and execute the scripts to validate the app from top to bottom.
89

910

1011

1112
## Unit test Coverage
1213

1314

14-
62 passing (176ms)
15+
63 passing (43s)
1516

1617

1718
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
1819
----------------------------|---------|----------|---------|---------|-------------------
19-
All files | 99.36 | 96 | 100 | 99.67 |
20+
All files | 99.49 | 97.62 | 100 | 99.74 |
2021
config | 100 | 100 | 100 | 100 |
2122
default.js | 100 | 100 | 100 | 100 |
2223
test.js | 100 | 100 | 100 | 100 |
2324
src | 90.48 | 50 | 100 | 94.12 |
2425
bootstrap.js | 90.48 | 50 | 100 | 94.12 | 18
25-
src/common | 100 | 96.55 | 100 | 100 |
26-
errors.js | 100 | 50 | 100 | 100 | 23
26+
src/common | 100 | 100 | 100 | 100 |
27+
errors.js | 100 | 100 | 100 | 100 |
2728
helper.js | 100 | 100 | 100 | 100 |
2829
src/models | 100 | 92.86 | 100 | 100 |
2930
Job.js | 100 | 100 | 100 | 100 |
@@ -33,4 +34,4 @@ All files | 99.36 | 96 | 100 | 99.67 |
3334
src/services | 100 | 100 | 100 | 100 |
3435
JobCandidateService.js | 100 | 100 | 100 | 100 |
3536
JobService.js | 100 | 100 | 100 | 100 |
36-
ResourceBookingService.js | 100 | 100 | 100 | 100 |
37+
ResourceBookingService.js | 100 | 100 | 100 | 100 |

config/default.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,25 @@ module.exports = {
44
BASE_PATH: process.env.BASE_PATH || '/api/v5',
55

66
AUTH_SECRET: process.env.AUTH_SECRET || 'mysecret',
7-
VALID_ISSUERS: process.env.VALID_ISSUERS || '["https://api.topcoder-dev.com", "https://api.topcoder.com", "https://topcoder-dev.auth0.com/"]',
7+
VALID_ISSUERS: process.env.VALID_ISSUERS || '["https://api.topcoder-dev.com", "https://api.topcoder.com", "https://topcoder-dev.auth0.com/", "https://auth.topcoder-dev.com/"]',
8+
AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token',
9+
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE || 'https://u-bahn.topcoder.com',
10+
TOKEN_CACHE_TIME: process.env.TOKEN_CACHE_TIME || 90,
11+
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID || 'LEyCiuOrHc7UAFoY0EAAhMulWSX7SrQ5',
12+
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET || 'Q1sQ77w43F5pWsMguK9JsStQwoGNRAD6IN4nyUShzlf24w6-CXD0ubDDT79t28tQ',
13+
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL || 'https://auth0proxy.topcoder-dev.com/token',
14+
15+
TC_API: process.env.TC_API || 'https://api.topcoder-dev.com/v5',
16+
ORG_ID: process.env.ORG_ID || '36ed815b-3da1-49f1-a043-aaed0a4e81ad',
817

918
POSTGRES_URL: process.env.POSTGRES_URL || 'postgres://postgres:postgres@localhost:5432/postgres',
1019
DB_SCHEMA_NAME: process.env.DB_SCHEMA_NAME || 'bookings',
11-
PROJECT_API_URL: process.env.PROJECT_API_URL || 'http://localhost:4000'
20+
PROJECT_API_URL: process.env.PROJECT_API_URL || 'http://localhost:4000',
21+
22+
esConfig: {
23+
HOST: process.env.ES_HOST || 'http://localhost:9200',
24+
ES_INDEX_JOB: process.env.ES_INDEX_JOB || 'job',
25+
ES_INDEX_JOB_CANDIDATE: process.env.ES_INDEX_JOB_CANDIDATE || 'job_candidate',
26+
ES_INDEX_RESOURCE_BOOKING: process.env.ES_INDEX_RESOURCE_BOOKING || 'resource_booking'
27+
}
1228
}

0 commit comments

Comments
 (0)