Skip to content

Commit 8a89a98

Browse files
authored
Merge pull request #18 from topcoder-platform/v5
V5
2 parents 813292c + 9640f24 commit 8a89a98

37 files changed

+6948
-2214
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
node_modules/
2-
dist

.swagger-codegen-ignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

.swagger-codegen/VERSION

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

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: node index.js
1+
web: node index.js

README.md

Lines changed: 21 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
# TopCoder Notifications - Bus API Server
2-
------------------------------------------------------------
1+
# Topcoder Bus API Server
2+
3+
## Overview
4+
5+
A meta service, Topcoder Bus API server provides information about other services offered by Topcoder.
6+
7+
This server was generated initially by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. We then copied over changes that existed in the older version over to version 5
38

49
## Requirements
510

6-
- node.js 8.7.0 (the latest)
7-
- Heroku CLI: https://devcenter.heroku.com/articles/heroku-cli#download-and-install
11+
Nodejs: ~8
812

913
## Configuration
1014

11-
### Kafka Configurations
1215
The following Kafka configurations must be set in the environment variables:
16+
1317
- `KAFKA_URL` the Kafka url
1418
- `KAFKA_CLIENT_CERT` the SSL client cert, can be string or file path
1519
- `KAFKA_CLIENT_CERT_KEY` the SSL client cert key, can be string or file path
@@ -69,7 +73,7 @@ Jp8xItVz3sqz5aCg+EvcewSGZ18AC+9cbxrbI2I83jQDHw+DQmVUyR6rl5+r+S6O
6973
-----END RSA PRIVATE KEY-----"
7074
```
7175

72-
### Other Configurations
76+
## Other Configurations
7377

7478
The other configurations can be changed in `config/default.js` or by setting environment variables.
7579

@@ -84,123 +88,23 @@ The other configurations can be changed in `config/default.js` or by setting env
8488
- `TC_EMAIL_TOKEN` the email service authentication token (see tc-email README for details **link should be added later**)
8589
- `TC_EMAIL_CACHE_PERIOD` the period to cache template placeholders from email service (60 min default)
8690

87-
## Code Standard
88-
The code follows StandardJS:
89-
90-
```bash
91-
npm install
92-
npm run lint
93-
```
94-
95-
## Generate JWT Tokens:
96-
To generate JWT Tokens for allowed services, run:
97-
98-
```bash
99-
npm run generate-tokens
100-
```
101-
102-
## Local Deployment and Verification
103-
104-
- Start
105-
106-
```
107-
npm run start
108-
```
109-
110-
- Import `docs/tc-bus-api-server.postman_collection.json` and `docs/tc-bus-api-server.postman_environment.json` to Postman
111-
- Change `URL` environment variable in Postman according to your deployment. If you deploy locally, it should be `http://localhost:3000/api/v1` by default
112-
- Change `VALID_TOKEN` if you want to test with another JWT token
113-
- Change `VALID_MESSAGE_TYPE` if you want to test with another message type
114-
- Change `EMAIL` to a valid e-mail address
115-
- Execute calls to verify the endpoints
116-
117-
118-
### Verify the messsages end up in Kafka queue
119-
Check `bus-api-test/README.md` to run a consumer that consumes and prints all messages in Kafka queue.
120-
121-
## Heroku Deployment and Verification
122-
123-
- Login and create a new app
124-
```bash
125-
heroku login
126-
heroku create
127-
```
91+
## Deploying the server
12892

129-
- Set Kafka configurations (and other configurations if necessary)
130-
```bash
131-
heroku config:set KAFKA_URL=<your Kafka url> --app <your app name>
132-
heroku config:set KAFKA_CLIENT_CERT=<your Kafka client cert string or file> --app <your app name>
133-
heroku config:set KAFKA_CLIENT_CERT_KEY=<your Kafka client cert key string or file> --app <your app name>
134-
```
93+
To deploy the server locally, run:
13594

136-
Example (please change your app name):
13795
```bash
138-
heroku config:set KAFKA_URL="kafka+ssl://ec2-34-205-227-216.compute-1.amazonaws.com:9096,kafka+ssl://ec2-34-233-75-247.compute-1.amazonaws.com:9096,kafka+ssl://ec2-34-198-118-170.compute-1.amazonaws.com:9096,kafka+ssl://ec2-34-231-150-104.compute-1.amazonaws.com:9096,kafka+ssl://ec2-34-233-209-20.compute-1.amazonaws.com:9096,kafka+ssl://ec2-34-233-131-252.compute-1.amazonaws.com:9096,kafka+ssl://ec2-52-205-198-73.compute-1.amazonaws.com:9096,kafka+ssl://ec2-52-4-109-80.compute-1.amazonaws.com:9096" --app <your app name>
139-
140-
heroku config:set KAFKA_CLIENT_CERT="-----BEGIN CERTIFICATE-----
141-
MIIDQzCCAiugAwIBAgIBADANBgkqhkiG9w0BAQsFADAyMTAwLgYDVQQDDCdjYS1j
142-
YmJiNGVkZi1mNDFhLTRjNzMtYTg5OC01NDYyMjhkNmQyNDIwHhcNMTcwOTI3MDUw
143-
MTIyWhcNMjcwOTI3MDUwMTIyWjAZMRcwFQYDVQQDDA51ODFvcjFsdTl2dTB1bzCC
144-
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKjkcV/BXD13Q09bRKohN/sK
145-
iDMGFA2QZ57TGd7svX7iZQIk9HmXEPd5zCTHZ6nZBbcGDQ9P+zGlJIGZQuRVKLOn
146-
ZPilaeUHRGrvCWGJZ6lVPNqInC1STHTfFJhcUNMG6qaD2ayBAw16f13vD1wGEWCm
147-
/DRfvrjIp3JIetGdKctmdiGLYH7CQecRW88Czx9e3Vpl1nxGcNAPDDCj0nRwuPse
148-
fVrg5onPX355om+Ct/teSeSONhio4dFL3fwl47CXFCReZFYOrBoLexfHXHumJ/Kp
149-
TQW+k056hhoagykcpTf8uNjxNRalDPkw7ngt+1IzatbhOacea1/WUE1444eEak8C
150-
AwEAAaN9MHswHQYDVR0OBBYEFJJzd6OZVLthBkhVZEW42CR8NJbtMFoGA1UdIwRT
151-
MFGAFORcypfrQ0tfS5tyBdv89jfpZEMaoTakNDAyMTAwLgYDVQQDDCdjYS1jYmJi
152-
NGVkZi1mNDFhLTRjNzMtYTg5OC01NDYyMjhkNmQyNDKCAQAwDQYJKoZIhvcNAQEL
153-
BQADggEBALVAdOWXdnSqhucXHjpIf0lxlH6WhzhhlctLCreSf+/7y6pPVpWSVIEl
154-
seVxOE5tsO2OzdtGgN2t7rr6bHuakL5rk9rH06r1jYAVQBR+T6SSLFbSVzl4Q5TO
155-
b+T9/sHx5QtXSYgMh4FhZcBjrmDmWvpd42Y4MPfjLTqTP8RWHHib8E4/FYS9txk6
156-
WoxrKcgnm/RmOcFWrjNjgm6JJprO1BSnbc2i/Rs5rxG2tRTTmXp6d7QCRa0bdhKz
157-
yETgcStnaVvyh64zhls3xXBm06rvpu2wwo6QHcPeekvQwxQvb63oovD8b+pFJri+
158-
6MBSQE4TtQenlVx7Ksy9UdNmU21xCYU=
159-
-----END CERTIFICATE-----" --app <your app name>
160-
161-
heroku config:set KAFKA_CLIENT_CERT_KEY="-----BEGIN RSA PRIVATE KEY-----
162-
MIIEogIBAAKCAQEAqORxX8FcPXdDT1tEqiE3+wqIMwYUDZBnntMZ3uy9fuJlAiT0
163-
eZcQ93nMJMdnqdkFtwYND0/7MaUkgZlC5FUos6dk+KVp5QdEau8JYYlnqVU82oic
164-
LVJMdN8UmFxQ0wbqpoPZrIEDDXp/Xe8PXAYRYKb8NF++uMinckh60Z0py2Z2IY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cEplBq0wI0B3VLZUC
181-
szlRKhtyKW6JM1tMQHT7uQKBgEOP+Hirzh5kJOj/5gKvi2r9FLUVzGzOessDFnSR
182-
YbMjOfSSc+y21UAFQSKkR+f+KtOSqP/wSSB6jrnThtclwJHny7PGRc+9GxWHPBRu
183-
T/qQhRLsPokHBp/+8SZ8MYSe0vnvL6Xw3+XxC8SzpMytOri+lijlx8CEtBGUz/iM
184-
bZpxAoGAEnJFUEGCB1ta3RQpI5L4nH2Rex0Avv8rkXGK2T/t5z2h8Ujg4WW3J7DD
185-
Jp8xItVz3sqz5aCg+EvcewSGZ18AC+9cbxrbI2I83jQDHw+DQmVUyR6rl5+r+S6O
186-
69wdZ08Y/jYkltb5PbhPqs0Kfr86cUqBuKEptRtto6Wto3k/Za4=
187-
-----END RSA PRIVATE KEY-----" --app <your app name>
96+
npm install
97+
npm start
18898
```
18999

190-
- Push to Heroku
191-
```bash
192-
git init
193-
git add .
194-
git commit -m "init"
195-
heroku git:remote -a <your app name>
196-
git push heroku master
197-
```
100+
## Generate JWT Tokens:
198101

199-
- The app will be available at `https://<your app name>.herokuapps.com/api/v1`
102+
To generate JWT Tokens for allowed services, run:
200103

201-
- Verification is similar to local verification, but you need to change `URL` in Postman to the Heroku app url `https://<your app name>.herokuapps.com/api/v1`
104+
```bash
105+
npm run generate-tokens
106+
```
202107

203-
## Others
108+
To view the Swagger UI interface visit `http://localhost:3000/docs`
204109

205-
- Swagger definition: `docs/swagger.yaml`
206-
- Demo Heroku app: `https://morning-mesa-65797.herokuapp.com/api/v1`
110+
This project leverages the mega-awesome [swagger-tools](https://github.com/apigee-127/swagger-tools) middleware which does most all the work.

0 commit comments

Comments
 (0)