Skip to content

Commit a456cd0

Browse files
Add endpoint to fetch user's challenges
2 parents bd9fb3f + bcf68c7 commit a456cd0

27 files changed

+1006
-878
lines changed

.eslintrc.yaml

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

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The following parameters can be set in config files or in env variables:
3636
- ES.API_VERSION: Elasticsearch API version
3737
- ES.ES_INDEX: Elasticsearch index name
3838
- ES.ES_TYPE: Elasticsearch index type
39+
- ES.ES_REFRESH: Elasticsearch refresh method. Default to string `true`(i.e. refresh immediately)
3940
- FILE_UPLOAD_SIZE_LIMIT: the file upload size limit in bytes
4041
- RESOURCES_API_URL: TC resources API base URL
4142
- GROUPS_API_URL: TC groups API base URL
@@ -65,13 +66,15 @@ The following test parameters can be set in config file or in env variables:
6566
- M2M_FULL_ACCESS_TOKEN: M2M full access token
6667
- M2M_READ_ACCESS_TOKEN: M2M read access token
6768
- M2M_UPDATE_ACCESS_TOKEN: M2M update (including 'delete') access token
68-
69-
## Local Elasticsearch and DynamoDB setup
70-
In the `local` folder, run `docker-compose up`
69+
- S3_ENDPOINT: endpoint of AWS S3 API, for unit and e2e test only; default to `localhost:9000`
7170

7271
## AWS S3 Setup
7372
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.
7473

74+
## Local services setup
75+
In the `local` folder, run `docker-compose up`
76+
It starts Elasticsearch, DynamoDB and S3 compatible server.
77+
7578
## Mock api
7679
For postman verification, please use the mock api under mock-api folder. It provides mock endpoint to fetch challenge resources and groups.
7780
You need to ensure DynamoDB configuration in `mock-api/config/default.js` is consistent with `config/default.js`
@@ -109,13 +112,16 @@ Go to `mock-api` folder and run command `npm run start` to start the mock-api li
109112

110113
## Running tests
111114

112-
Before running tests, AWS S3 bucket should be created, DynamoDB tables should be created, ES index should be initialized, mock API should be started and various config parameters are properly set.
113-
Important notes: You need to ensure DynamoDB configuration in `mock-api/config/default.js` is consistent with `config/default.js`
115+
### Prepare
116+
- Start Local services.
117+
- Start Mock API.
118+
- Create DynamoDB tables.
119+
- Initialize ES index.
120+
- Various config parameters should be properly set.
114121

115122
Seeding db data is not needed.
116123

117124
### Running unit tests
118-
119125
To run unit tests alone
120126

121127
```bash
@@ -129,7 +135,6 @@ npm run test:cov
129135
```
130136

131137
### Running integration tests
132-
133138
To run integration tests alone
134139

135140
```bash

Verification.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Run command `npm run view-data <ModelName>` to view table data, ModelName can be
1313

1414
Login to AWS Console, S3 service, view the bucket content.
1515

16+
## ElasticSearch Verification
17+
18+
Run command `npm run view-es-data` to view data store in ES.
1619

1720
## Bus Event Verification
1821

config/default.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ module.exports = {
3333
ES: {
3434
// above AWS_REGION is used if we use AWS ES
3535
HOST: process.env.ES_HOST || 'localhost:9200',
36-
API_VERSION: process.env.ES_API_VERSION || '6.7',
36+
API_VERSION: process.env.ES_API_VERSION || '6.8',
3737
ES_INDEX: process.env.ES_INDEX || 'challenge',
38-
ES_TYPE: process.env.ES_TYPE || '_doc' // ES 6.x accepts only 1 Type per index and it's mandatory to define it
38+
ES_TYPE: process.env.ES_TYPE || '_doc', // ES 6.x accepts only 1 Type per index and it's mandatory to define it
39+
ES_REFRESH: process.env.ES_REFRESH || 'true'
3940
},
4041

4142
// in bytes

config/test.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

local/docker-compose.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ services:
66
- "7777:7777"
77
command: "-inMemory -port 7777"
88
esearch:
9-
image: "docker.elastic.co/elasticsearch/elasticsearch:6.3.1"
9+
image: "docker.elastic.co/elasticsearch/elasticsearch:6.8.0"
1010
ports:
1111
- "9200:9200"
12+
environment:
13+
- "discovery.type=single-node"
14+
minio1:
15+
image: minio/minio
16+
ports:
17+
- "9000:9000"
18+
environment:
19+
MINIO_ACCESS_KEY: "FAKE_ACCESS_KEY"
20+
MINIO_SECRET_KEY: "FAKE_SECRET_ACCESS_KEY"
21+
command: "server /data"

0 commit comments

Comments
 (0)