Skip to content

Commit

Permalink
Member traits
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasKranitsas committed Mar 13, 2020
1 parent dbbf36d commit 8a81f6e
Show file tree
Hide file tree
Showing 25 changed files with 2,926 additions and 180 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ The following parameters can be set in config files or in env variables:
- ES: config object for Elasticsearch
- ES.HOST: Elasticsearch host
- ES.API_VERSION: Elasticsearch API version
- ES.ES_INDEX: Elasticsearch index name
- ES.ES_TYPE: Elasticsearch index type
- ES.ES_INDEX: Elasticsearch index name for member
- ES.ES_TYPE: Elasticsearch index type for member
- ES.MEMBER_TRAIT_ES_INDEX: Elasticsearch index name for member trait
- ES.MEMBER_TRAIT_ES_TYPE: Elasticsearch index type for member trait
- FILE_UPLOAD_SIZE_LIMIT: the file upload size limit in bytes
- ID_FIELDS: member identifiable info fields, only admin, M2M, or member himself can get these fields
- PHOTO_URL_TEMPLATE: photo URL template, its <key> will be replaced with S3 object key
Expand Down Expand Up @@ -88,8 +90,8 @@ It starts Elasticsearch, DynamoDB and S3 compatible server.
3. Initialize/Clear database: `npm run init-db`
4. Create Elasticsearch index: `npm run init-es`, or to re-create index: `npm run init-es force`
5. Seed/Insert data to ES and DB: `npm run seed-data`
6. View DB table data: `npm run view-db-data <ModelName>`, ModelName can be `Member`
7. View ES data: `npm run view-es-data`
6. View DB table data: `npm run view-db-data <ModelName>`, ModelName can be `Member`, `MemberTrait`
7. View ES data: `npm run view-es-data <IndexName>`, IndexName can be `member`, `member_trait`

## Local Deployment

Expand Down Expand Up @@ -166,3 +168,10 @@ Refer to the verification document `Verification.md`

- all JWT tokens provided in Postman environment file and tests are created in `https://jwt.io` with secret `mysecret`

- you don't need to setup the (https://github.com/topcoder-platform/member-processor-es),
because there is seed-data script to setup data to test the members API,
the tests also have setup data properly

- the tests use mock S3 service to upload member photo, so you may use the provided mock AWS credential for tests,
but Postman tests require using real AWS S3, you need to follow README.md to create S3 bucket and provide your own AWS credential
so that the upload photo API works
6 changes: 3 additions & 3 deletions Verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
- clear the environment, run command `npm run init-db` and `npm run init-es force`
- create test data in ES and DB, run `npm run seed-data`
- import Postman collection and environment in the docs folder to Postman
- run the tests
- run the Postman tests

## DynamoDB Verification
Run command `npm run view-db-data <ModelName>` to view table data, ModelName can be `Member`
Run command `npm run view-db-data <ModelName>` to view table data, ModelName can be `Member`, `MemberTrait`

## S3 Verification

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

## ElasticSearch Verification

Run command `npm run view-es-data` to view data store in ES.
Run command `npm run view-es-data <IndexName>` to view data store in ES, IndexName can be `member`, `member_trait`

## Bus Event Verification

Expand Down
10 changes: 8 additions & 2 deletions app-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ const EVENT_MIME_TYPE = 'application/json'

const TOPICS = {
MemberUpdated: 'member.action.profile.update',
EmailChanged: 'member.action.email.profile.emailchange.verification'
EmailChanged: 'member.action.email.profile.emailchange.verification',
MemberTraitCreated: 'member.action.profile.trait.create',
MemberTraitUpdated: 'member.action.profile.trait.update',
MemberTraitDeleted: 'member.action.profile.trait.delete'
}

const ES_SEARCH_MAX_SIZE = 9999

module.exports = {
ADMIN_ROLES,
EVENT_ORIGINATOR,
EVENT_MIME_TYPE,
TOPICS
TOPICS,
ES_SEARCH_MAX_SIZE
}
6 changes: 5 additions & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ module.exports = {
// above AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are used if we use AWS ES
HOST: process.env.ES_HOST || 'localhost:9200',
API_VERSION: process.env.ES_API_VERSION || '6.8',
// member index
ES_INDEX: process.env.ES_INDEX || 'member',
ES_TYPE: process.env.ES_TYPE || '_doc' // ES 6.x accepts only 1 Type per index and it's mandatory to define it
// member type, ES 6.x accepts only 1 Type per index and it's mandatory to define it
ES_TYPE: process.env.ES_TYPE || '_doc',
MEMBER_TRAIT_ES_INDEX: process.env.MEMBER_TRAIT_ES_INDEX || 'member_trait',
MEMBER_TRAIT_ES_TYPE: process.env.MEMBER_TRAIT_ES_TYPE || '_doc'
},

// file upload max size in bytes
Expand Down
Loading

0 comments on commit 8a81f6e

Please sign in to comment.