Skip to content

Commit 6811fc3

Browse files
committed
local development support
1 parent 2f57df8 commit 6811fc3

File tree

2 files changed

+75
-26
lines changed

2 files changed

+75
-26
lines changed

README.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,9 @@ Run `npm run sync:es` from the root of project to execute the script.
4242
4343
**NOTE**: In production these dependencies / services are hosted & managed outside tc-projects-service.
4444

45-
#### Kafka
46-
Kafka must be installed and configured prior starting the application.
47-
Following topics must be created:
48-
```
49-
notifications.connect.project.updated
50-
notifications.connect.project.files.updated
51-
notifications.connect.project.team.updated
52-
notifications.connect.project.plan.updated
53-
notifications.connect.project.topic.created
54-
notifications.connect.project.topic.updated
55-
notifications.connect.project.post.created
56-
notifications.connect.project.post.edited
57-
```
45+
### Import sample metadata
5846

59-
New Kafka related configuration options has been introduced:
60-
```
61-
"kafkaConfig": {
62-
"hosts": List of Kafka brokers. Default: localhost: 9092
63-
"clientCert": SSL certificate
64-
"clientCertKey": Certificate key
65-
}
66-
```
67-
Environment variables:
68-
- `KAFKA_HOSTS` - same as "hosts"
69-
- `KAFKA_CLIENT_CERT` - same as "clientCert"
70-
- `KAFKA_CLIENT_CERT_KEY` - same as "clientCertKey"
47+
To create sample metadata entries (duplicate what is currently in development environment) run `node migrations/seedMetadata.js`
7148

7249
### Test
7350

@@ -103,4 +80,4 @@ You may replace 172.17.0.1 with your docker0 IP.
10380
You can paste **swagger.yaml** to [swagger editor](http://editor.swagger.io/) or import **postman.json** and **postman_environment.json** to verify endpoints.
10481

10582
#### Deploying without docker
106-
If you don't want to use docker to deploy to localhost. You can simply run `npm run start` from root of project. This should start the server on default port `3000`.
83+
If you don't want to use docker to deploy to localhost. You can simply run `npm run start:dev` from root of project. This should start the server on default port `8001`.

migrations/seedMetadata.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* eslint-disable */
2+
const _ = require('lodash')
3+
const axios = require('axios');
4+
const Promise = require('bluebird');
5+
6+
7+
var url = 'https://api.topcoder-dev.com/v4/projects/metadata';
8+
var targetUrl = 'http://localhost:8001/v4/';
9+
var destUrl = targetUrl + 'projects/';
10+
var destTimelines = targetUrl;
11+
12+
axios.get(url)
13+
.then(async function (response) {
14+
let data = response.data;
15+
16+
var headers = {
17+
'Content-Type': 'application/json',
18+
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiYWRtaW5pc3RyYXRvciJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoidGVzdDEiLCJleHAiOjI1NjMwNzY2ODksInVzZXJJZCI6IjQwMDUxMzMzIiwiaWF0IjoxNDYzMDc2MDg5LCJlbWFpbCI6InRlc3RAdG9wY29kZXIuY29tIiwianRpIjoiYjMzYjc3Y2QtYjUyZS00MGZlLTgzN2UtYmViOGUwYWU2YTRhIn0.wKWUe0-SaiFVN-VR_-GwgFlvWaDkSbc8H55ktb9LAVw'
19+
}
20+
21+
22+
let promises = _(data.result.content.projectTypes).map(pt=>{
23+
return axios.post(destUrl+'metadata/projectTypes',{param:pt}, {headers:headers})
24+
});
25+
try{
26+
await Promise.all(promises);
27+
}catch(ex){
28+
//ignore the error
29+
}
30+
31+
promises = _(data.result.content.projectTemplates).map(pt=>{
32+
return axios.post(destUrl+'metadata/projectTemplates',{param:pt}, {headers:headers})
33+
});
34+
try{
35+
await Promise.all(promises);
36+
}catch(ex){
37+
//ignore the error
38+
}
39+
40+
promises = _(data.result.content.productCategories).map(pt=>{
41+
return axios.post(destUrl+'metadata/productCategories',{param:pt}, {headers:headers})
42+
});
43+
try{
44+
await Promise.all(promises);
45+
}catch(ex){
46+
//ignore the error
47+
}
48+
49+
promises = _(data.result.content.productTemplates).map(pt=>{
50+
return axios.post(destUrl+'metadata/productTemplates',{param:pt}, {headers:headers})
51+
});
52+
try{
53+
await Promise.all(promises);
54+
}catch(ex){
55+
//ignore the error
56+
}
57+
58+
await Promise.each(data.result.content.milestoneTemplates,pt=>{
59+
return new Promise((resolve,reject)=>{
60+
axios.post(destTimelines+'timelines/metadata/milestoneTemplates',{param:pt}, {headers:headers})
61+
.then(r=>resolve())
62+
.catch(e=>resolve()); //ignore the error
63+
})
64+
});
65+
66+
67+
68+
// handle success
69+
console.log('Done');
70+
}).catch(err=>{
71+
console.log(err);
72+
});

0 commit comments

Comments
 (0)