Skip to content

Commit 7475dde

Browse files
asadath1395sharathkumaranbu
authored andcommitted
Fix issue #17, #31, #33 (#35)
Fixes and Improvements
1 parent 92848b5 commit 7475dde

14 files changed

+701
-4225
lines changed

README.md

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,14 @@ The following parameters can be set in config files or in env variables:
4040
- follow (https://neo4j.com/download-thanks-desktop/?edition=desktop&flavour=winstall64&release=1.1.13&offline=true) to add graph database
4141
- configure graph database connection details in config file
4242

43-
4443
## Local Deployment
4544

4645
- Install dependencies `npm install`
4746
- Run lint `npm run lint`
4847
- Run lint fix `npm run lint:fix`
49-
- Clear and init db `npm run init-db`
50-
- Add db indices `npm run create-index`
51-
- Insert test data `npm run test-data`
5248
- Start app `npm start`
53-
- App is running at `http://localhost:3000`
54-
49+
- App will be running at `http://localhost:3000`
50+
- Application can be run in development mode using the command `npm run dev`
5551

5652
## Heroku deployment
5753
- git init
@@ -63,33 +59,12 @@ The following parameters can be set in config files or in env variables:
6359
- to set some environment variables in heroku, run command like:
6460
`heroku config:set LOG_LEVEL=info`
6561
- git push heroku master // push code to Heroku
66-
- to initialize db, run `heroku run npm run init-db`
67-
- to create db indices, run `heroku run npm run create-index`
68-
- to insert test data, run `heroku run npm run test-data`
69-
70-
71-
I deployed the code to:
72-
https://thawing-savannah-55254.herokuapp.com
73-
74-
7562

7663
## Graph Database Structure
7764

78-
The graph database consists of 3 node types: SecurityGroup, Group and User, and one relation type: GroupContains.
65+
The graph database consists of 3 node types: Group and User, and one relation type: GroupContains.
7966
The GroupContains relation links from a group to a child group or user.
8067

81-
### SecurityGroup node
82-
83-
The security group node contains these fields:
84-
85-
- id: the group UUID corresponding to the security group
86-
- name: the security group name, should be unique (usually the same as the group)
87-
- createdAt: the created at date string
88-
- createdBy: the created by user id
89-
- updatedAt: the updated at date string
90-
- updatedBy: the updated by user id
91-
92-
9368
### Group node
9469

9570
The group node contains these fields:
@@ -113,18 +88,11 @@ The user node contains these fields:
11388
- id: the user UUID
11489
- handle: the user handle, should be unique
11590

116-
11791
### GroupContains relation
11892

11993
The GroupContains relation contains these fields:
12094

12195
- id: the relationship UUID
12296
- type: the relationship type, 'group' or 'user'
12397
- createdAt: the created at date string
124-
- createdBy: the created by user id
125-
126-
## Notes
127-
128-
In the app-constants.js Topics field, the used topics are using a test topic,
129-
the suggested ones are commented out, because these topics are not created in TC dev Kafka yet.
130-
98+
- createdBy: the created by user id

app-constants.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ const EVENT_ORIGINATOR = 'topcoder-groups-api'
1515

1616
const EVENT_MIME_TYPE = 'application/json'
1717

18-
// using a testing topc, should be changed to use real topics in comments when they are created
19-
const Topics = {
20-
GroupCreated: 'test.new.bus.events', // 'user.action.group.created',
21-
GroupUpdated: 'test.new.bus.events', // 'user.action.group.updated',
22-
GroupDeleted: 'test.new.bus.events', // 'user.action.group.deleted',
23-
GroupMemberCreated: 'test.new.bus.events', // 'user.action.group.member.created',
24-
GroupMemberDeleted: 'test.new.bus.events' // 'user.action.group.member.deleted'
18+
const GroupStatus = {
19+
Active: 'active',
20+
InActive: 'inactive'
2521
}
2622

2723
module.exports = {
2824
UserRoles,
2925
MembershipTypes,
3026
EVENT_ORIGINATOR,
3127
EVENT_MIME_TYPE,
32-
Topics
28+
GroupStatus
3329
}

app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const cors = require('cors')
1212
const logger = require('./src/common/logger')
1313
const HttpStatus = require('http-status-codes')
1414
const morgan = require('morgan')
15+
const swaggerUi = require('swagger-ui-express')
16+
const YAML = require('yamljs')
1517

18+
const swaggerDocument = YAML.load('./docs/swagger.yml')
1619
// setup express app
1720
const app = express()
1821

@@ -24,6 +27,11 @@ app.set('port', config.PORT)
2427
// Request logger
2528
app.use(morgan('common', { skip: (req, res) => res.statusCode < 400 }))
2629

30+
// Serve Swagger Docs after setting host and base path
31+
swaggerDocument.host = config.HOST
32+
swaggerDocument.basePath = config.API_PREFIX
33+
app.use('/groups/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
34+
2735
// Register routes
2836
require('./app-routes')(app)
2937

config/default.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
VALID_ISSUERS: process.env.VALID_ISSUERS
1515
? process.env.VALID_ISSUERS.replace(/\\"/g, '')
1616
: '["https://api.topcoder-dev.com", "https://api.topcoder.com","https://topcoder-dev.auth0.com/"]',
17+
HOST: process.env.HOST || 'localhost:3000',
1718

1819
// Auth0 config params
1920
AUTH0_URL: process.env.AUTH0_URL || 'https://topcoder-dev.auth0.com/oauth/token',
@@ -31,11 +32,11 @@ module.exports = {
3132
HEALTH_CHECK_TIMEOUT: process.env.HEALTH_CHECK_TIMEOUT || 3000,
3233

3334
// Kafka Topics
34-
KAFKA_GROUP_CREATE_TOPIC: process.env.KAFKA_GROUP_CREATE_TOPIC,
35-
KAFKA_GROUP_UPDATE_TOPIC: process.env.KAFKA_GROUP_UPDATE_TOPIC,
36-
KAFKA_GROUP_DELETE_TOPIC: process.env.KAFKA_GROUP_DELETE_TOPIC,
37-
KAFKA_GROUP_MEMBER_ADD_TOPIC: process.env.KAFKA_GROUP_MEMBER_ADD_TOPIC,
38-
KAFKA_GROUP_MEMBER_DELETE_TOPIC: process.env.KAFKA_GROUP_MEMBER_DELETE_TOPIC,
35+
KAFKA_GROUP_CREATE_TOPIC: process.env.KAFKA_GROUP_CREATE_TOPIC || 'groups.notification.create',
36+
KAFKA_GROUP_UPDATE_TOPIC: process.env.KAFKA_GROUP_UPDATE_TOPIC || 'groups.notification.update',
37+
KAFKA_GROUP_DELETE_TOPIC: process.env.KAFKA_GROUP_DELETE_TOPIC || 'groups.notification.delete',
38+
KAFKA_GROUP_MEMBER_ADD_TOPIC: process.env.KAFKA_GROUP_MEMBER_ADD_TOPIC || 'groups.notification.member.add',
39+
KAFKA_GROUP_MEMBER_DELETE_TOPIC: process.env.KAFKA_GROUP_MEMBER_DELETE_TOPIC || 'groups.notification.member.delete',
3940

4041
USER_ROLES: {
4142
Admin: 'Administrator',

0 commit comments

Comments
 (0)