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

Commit 37ff38d

Browse files
author
vikasrohit
authored
Merge pull request #15 from topcoder-platform/develop
Prod Release - v1.0.0
2 parents c008322 + 7ea0be4 commit 37ff38d

37 files changed

+2080
-1162
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ workflows:
6868
branches:
6969
only:
7070
- develop
71+
- feature/enrich
7172

7273
# Production builds are exectuted only on tagged commits to the
7374
# master branch.
7475
- "build-prod":
7576
context : org-global
7677
filters:
7778
branches:
78-
only: master
79+
only: master

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

README.md

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,49 @@
2121

2222
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:
2323

24-
- LOG_LEVEL: the log level
25-
- PORT: the server port
26-
- AUTH_SECRET: TC Authentication secret
27-
- VALID_ISSUERS: valid issuers for TC authentication
28-
- PAGE_SIZE: the default pagination limit
29-
- MAX_PAGE_SIZE: the maximum pagination size
30-
- API_VERSION: the API version
31-
- DB_NAME: the database name
32-
- DB_USERNAME: the database username
33-
- DB_PASSWORD: the database password
34-
- DB_HOST: the database host
35-
- DB_PORT: the database port
36-
- ES_HOST: Elasticsearch host
37-
- ES_REFRESH: Should elastic search refresh. Default is 'true'. Values can be 'true', 'wait_for', 'false'
38-
- ELASTICCLOUD_ID: The elastic cloud id, if your elasticsearch instance is hosted on elastic cloud. DO NOT provide a value for ES_HOST if you are using this
39-
- ELASTICCLOUD_USERNAME: The elastic cloud username for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
40-
- ELASTICCLOUD_PASSWORD: The elastic cloud password for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
41-
- ES.DOCUMENTS: Elasticsearch index, type and id mapping for resources.
42-
- SKILL_INDEX: The Elastic search index for skill. Default is `skill`
43-
- SKILL_ENRICH_POLICYNAME: The enrich policy for skill. Default is `skill-policy`
44-
- TAXONOMY_INDEX: The Elastic search index for taxonomy. Default is `taxonomy`
45-
- TAXONOMY_PIPELINE_ID: The pipeline id for enrichment with taxonomy. Default is `taxonomy-pipeline`
46-
- TAXONOMY_ENRICH_POLICYNAME: The enrich policy for taxonomy. Default is `taxonomy-policy`
47-
- MAX_BATCH_SIZE: Restrict number of records in memory during bulk insert (Used by the db to es migration script)
48-
- MAX_BULK_SIZE: The Bulk Indexing Maximum Limits. Default is `100` (Used by the db to es migration script)
24+
- `LOG_LEVEL`: the log level
25+
- `PORT`: the server port
26+
- `AUTH_SECRET`: TC Authentication secret
27+
- `VALID_ISSUERS`: valid issuers for TC authentication
28+
- `PAGE_SIZE`: the default pagination limit
29+
- `MAX_PAGE_SIZE`: the maximum pagination size
30+
- `API_VERSION`: the API version
31+
- `DB_NAME`: the database name
32+
- `DB_USERNAME`: the database username
33+
- `DB_PASSWORD`: the database password
34+
- `DB_HOST`: the database host
35+
- `DB_PORT`: the database port
36+
- `ES_HOST`: Elasticsearch host
37+
- `ES_REFRESH`: Should elastic search refresh. Default is 'true'. Values can be 'true', 'wait_for', 'false'
38+
- `ELASTICCLOUD_ID`: The elastic cloud id, if your elasticsearch instance is hosted on elastic cloud. DO NOT provide a value for ES_HOST if you are using this
39+
- `ELASTICCLOUD_USERNAME`: The elastic cloud username for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
40+
- `ELASTICCLOUD_PASSWORD`: The elastic cloud password for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
41+
- `ES`.DOCUMENTS: Elasticsearch index, type and id mapping for resources.
42+
- `SKILL_INDEX`: The Elastic search index for skill. Default is `skill`
43+
- `TAXONOMY_INDEX`: The Elastic search index for taxonomy. Default is `taxonomy`
44+
- `MAX_BATCH_SIZE`: Restrict number of records in memory during bulk insert (Used by the db to es migration script)
45+
- `MAX_BULK_SIZE`: The Bulk Indexing Maximum Limits. Default is `100` (Used by the db to es migration script)
46+
47+
- `AUTH0_URL`: Auth0 URL, used to get TC M2M token
48+
- `AUTH0_AUDIENCE`: Auth0 audience, used to get TC M2M token
49+
- `TOKEN_CACHE_TIME`: Auth0 token cache time, used to get TC M2M token
50+
- `AUTH0_CLIENT_ID`: Auth0 client id, used to get TC M2M token
51+
- `AUTH0_CLIENT_SECRET`: Auth0 client secret, used to get TC M2M token
52+
- `AUTH0_PROXY_SERVER_URL`: Proxy Auth0 URL, used to get TC M2M token
53+
54+
- `BUSAPI_URL`: Topcoder Bus API URL
55+
- `KAFKA_ERROR_TOPIC`: The error topic at which bus api will publish any errors
56+
- `KAFKA_MESSAGE_ORIGINATOR`: The originator value for the kafka messages
57+
- `SKILLS_ERROR_TOPIC`: Kafka topic for report operation error
58+
59+
**NOTE** AUTH0 related configuration normally is shared on challenge forum.
60+
61+
## DB and Elasticsearch In Docker
62+
- Navigate to the directory `docker-pgsql-es` folder. Rename `sample.env` to `.env` and change any values if required.
63+
- Run `docker-compose up -d` to have docker instances of pgsql and elasticsearch to use with the api
4964

65+
**NOTE** To completely restart the services, run `docker-compose down --volumes` and then `docker-compose up`.
66+
Notice the `--volumes` argument is passed to the `docker-compose down` command to remove the volume that stores DB data. Without the `--volumes` argument the DB data will be persistent after the services are put down.
5067

5168
## Local deployment
5269

@@ -58,17 +75,16 @@ Setup your Postgresql DB and Elasticsearch instance and ensure that they are up
5875
- Run the migrations - `npm run migrations up`. This will create the tables.
5976
- Then run `npm run insert-data` and insert mock data into the database.
6077
- Run `npm run migrate-db-to-es` to sync data with ES.
61-
- Startup server `npm run start`
78+
- Startup server `npm run start:dev`
6279

6380
## Migrations
6481

6582
Migrations are located under the `./scripts/db/` folder. Run `npm run migrations up` and `npm run migrations down` to execute the migrations or remove the earlier ones
6683

6784
## Local Deployment with Docker
85+
Setup your Postgresql DB and Elasticsearch instance and ensure that they are up and running.
6886

69-
- Navigate to the directory `docker-pgsql-es` folder. Rename `sample.env` to `.env` and change any values if required.
70-
- Run `docker-compose up -d` to have docker instances of pgsql and elasticsearch to use with the api
71-
87+
- Configure AUTH0 related parameters via ENV variables. Note that normally you don't need to change other configuration.
7288
- Create database using `npm run create-db`.
7389
- Run the migrations - `npm run migrations up`. This will create the tables.
7490
- Then run `npm run insert-data` and insert mock data into the database.
@@ -102,6 +118,8 @@ Migrations are located under the `./scripts/db/` folder. Run `npm run migrations
102118
| `npm run delete-data` | Delete the data from the database |
103119
| `npm run migrations up` | Run up migration |
104120
| `npm run migrations down` | Run down migration |
121+
| `npm run create-index` | Create Elasticsearch indexes. Use `-- --force` flag to skip confirmation |
122+
| `npm run delete-index` | Delete Elasticsearch indexes. Use `-- --force` flag to skip confirmation |
105123
| `npm run generate:doc:permissions` | Generate [permissions.html](docs/permissions.html) |
106124
| `npm run generate:doc:permissions:dev` | Generate [permissions.html](docs/permissions.html) on any changes (useful during development). |
107125

config/default.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,25 @@ module.exports = {
2020
DB_HOST: process.env.DB_HOST || 'localhost',
2121
DB_PORT: process.env.DB_PORT || 5432,
2222

23+
AUTH0_URL: process.env.AUTH0_URL,
24+
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE,
25+
TOKEN_CACHE_TIME: process.env.TOKEN_CACHE_TIME,
26+
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
27+
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET,
28+
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL,
29+
30+
BUSAPI_URL: process.env.BUSAPI_URL || 'https://api.topcoder-dev.com/v5',
31+
32+
KAFKA_ERROR_TOPIC: process.env.KAFKA_ERROR_TOPIC || 'common.error.reporting',
33+
KAFKA_MESSAGE_ORIGINATOR: process.env.KAFKA_MESSAGE_ORIGINATOR || 'skills-api',
34+
35+
SKILLS_ERROR_TOPIC: process.env.SKILLS_ERROR_TOPIC || 'skills.action.error',
36+
2337
// ElasticSearch
2438
ES: {
2539
HOST: process.env.ES_HOST || 'http://localhost:9200',
2640
ES_REFRESH: process.env.ES_REFRESH || 'true',
41+
ES_API_VERSION: process.env.ES_API_VERSION || "7.4",
2742

2843
ELASTICCLOUD: {
2944
id: process.env.ELASTICCLOUD_ID,
@@ -35,14 +50,11 @@ module.exports = {
3550
DOCUMENTS: {
3651
skill: {
3752
index: process.env.SKILL_INDEX || 'skill',
38-
type: '_doc',
39-
enrichPolicyName: process.env.SKILL_ENRICH_POLICYNAME || 'skill-policy'
53+
type: '_doc'
4054
},
4155
taxonomy: {
4256
index: process.env.TAXONOMY_INDEX || 'taxonomy',
43-
type: '_doc',
44-
pipelineId: process.env.TAXONOMY_PIPELINE_ID || 'taxonomy-pipeline',
45-
enrichPolicyName: process.env.TAXONOMY_ENRICH_POLICYNAME || 'taxonomy-policy'
57+
type: '_doc'
4658
}
4759
},
4860
MAX_BATCH_SIZE: parseInt(process.env.MAX_BATCH_SIZE, 10) || 10000,

docker/sample.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ DB_PORT=5432
66

77
ES_HOST=http://host.docker.internal:9200
88
PORT=3001
9+
10+
AUTH0_CLIENT_ID=<auth0 client id>
11+
AUTH0_CLIENT_SECRET=<auth0 client secret>
12+
AUTH0_URL=<auth0 url>
13+
AUTH0_AUDIENCE=<auth0 audience>

docs/permissions.html

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ <h2 class="anchor-container">
9797
</div>
9898

9999
<div>
100-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
101-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
102-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
100+
<span class="badge badge-dark" title="Allowed Topcoder Role">create:skill</span>
101+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:skill</span>
103102
</div>
104103
</div>
105104
</div>
@@ -127,9 +126,8 @@ <h2 class="anchor-container">
127126
</div>
128127

129128
<div>
130-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
131-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
132-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
129+
<span class="badge badge-dark" title="Allowed Topcoder Role">update:skill</span>
130+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:skill</span>
133131
</div>
134132
</div>
135133
</div>
@@ -157,9 +155,8 @@ <h2 class="anchor-container">
157155
</div>
158156

159157
<div>
160-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
161-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
162-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
158+
<span class="badge badge-dark" title="Allowed Topcoder Role">delete:skill</span>
159+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:skill</span>
163160
</div>
164161
</div>
165162
</div>
@@ -194,9 +191,8 @@ <h2 class="anchor-container">
194191
</div>
195192

196193
<div>
197-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
198-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
199-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
194+
<span class="badge badge-dark" title="Allowed Topcoder Role">create:skill</span>
195+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:skill</span>
200196
</div>
201197
</div>
202198
</div>
@@ -224,9 +220,8 @@ <h2 class="anchor-container">
224220
</div>
225221

226222
<div>
227-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
228-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
229-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
223+
<span class="badge badge-dark" title="Allowed Topcoder Role">update:skill</span>
224+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:skill</span>
230225
</div>
231226
</div>
232227
</div>
@@ -254,16 +249,15 @@ <h2 class="anchor-container">
254249
</div>
255250

256251
<div>
257-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
258-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
259-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
252+
<span class="badge badge-dark" title="Allowed Topcoder Role">delete:skill</span>
253+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:skill</span>
260254
</div>
261255
</div>
262256
</div>
263257
<div class="row">
264258
<div class="col pt-5 pb-2">
265259
<h2 class="anchor-container">
266-
<a href="#section-taxonomy-metadata" name="section-taxonomy-metadata" class="anchor"></a>Taxonomy Metadata
260+
<a href="#section-taxonomy" name="section-taxonomy" class="anchor"></a>Taxonomy
267261
</h2>
268262
</div>
269263
</div>
@@ -291,9 +285,8 @@ <h2 class="anchor-container">
291285
</div>
292286

293287
<div>
294-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
295-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
296-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
288+
<span class="badge badge-dark" title="Allowed Topcoder Role">create:taxonomy</span>
289+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:taxonomy</span>
297290
</div>
298291
</div>
299292
</div>
@@ -321,9 +314,8 @@ <h2 class="anchor-container">
321314
</div>
322315

323316
<div>
324-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
325-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
326-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
317+
<span class="badge badge-dark" title="Allowed Topcoder Role">update:taxonomy</span>
318+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:taxonomy</span>
327319
</div>
328320
</div>
329321
</div>
@@ -351,16 +343,15 @@ <h2 class="anchor-container">
351343
</div>
352344

353345
<div>
354-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
355-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
356-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
346+
<span class="badge badge-dark" title="Allowed Topcoder Role">delete:taxonomy</span>
347+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:taxonomy</span>
357348
</div>
358349
</div>
359350
</div>
360351
<div class="row">
361352
<div class="col pt-5 pb-2">
362353
<h2 class="anchor-container">
363-
<a href="#section-taxonomy" name="section-taxonomy" class="anchor"></a>Taxonomy
354+
<a href="#section-taxonomy-metadata" name="section-taxonomy-metadata" class="anchor"></a>Taxonomy Metadata
364355
</h2>
365356
</div>
366357
</div>
@@ -388,9 +379,8 @@ <h2 class="anchor-container">
388379
</div>
389380

390381
<div>
391-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
392-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
393-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
382+
<span class="badge badge-dark" title="Allowed Topcoder Role">create:taxonomy</span>
383+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:taxonomy</span>
394384
</div>
395385
</div>
396386
</div>
@@ -418,9 +408,8 @@ <h2 class="anchor-container">
418408
</div>
419409

420410
<div>
421-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
422-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
423-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
411+
<span class="badge badge-dark" title="Allowed Topcoder Role">update:taxonomy</span>
412+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:taxonomy</span>
424413
</div>
425414
</div>
426415
</div>
@@ -448,9 +437,8 @@ <h2 class="anchor-container">
448437
</div>
449438

450439
<div>
451-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:connect_project</span>
452-
<span class="badge badge-dark" title="Allowed Topcoder Role">all:projects</span>
453-
<span class="badge badge-dark" title="Allowed Topcoder Role">write:projects</span>
440+
<span class="badge badge-dark" title="Allowed Topcoder Role">delete:taxonomy</span>
441+
<span class="badge badge-dark" title="Allowed Topcoder Role">all:taxonomy</span>
454442
</div>
455443
</div>
456444
</div>

0 commit comments

Comments
 (0)