Skip to content

Commit b0cfe04

Browse files
author
sachin-maheshwari
authored
Merge pull request #10 from topcoder-platform/dev
v5 and other miner changes
2 parents a9e84fd + 7c771c2 commit b0cfe04

File tree

8 files changed

+22
-12
lines changed

8 files changed

+22
-12
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# and runs it against the specified Topcoder backend (development or
33
# production) when container is executed.
44

5-
FROM node:8.2.1
6-
LABEL app="tc email" version="1.0"
5+
FROM node:6.10
6+
LABEL app="tc email" version="1.1"
77

88
WORKDIR /opt/app
99
COPY . .
1010
RUN npm install
11-
RUN npm install dotenv --save
11+
#RUN npm install dotenv --save
1212
RUN npm run lint
1313
CMD ["npm", "start"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
## Dependencies
5-
- nodejs https://nodejs.org/en/ (v8+)
5+
- nodejs https://nodejs.org/en/ (v6+)
66
- Heroku Toolbelt https://toolbelt.heroku.com
77
- git
88
- PostgreSQL 9.5

config/default.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ module.exports = {
4040

4141
//in every 2 minutes will retry for failed status
4242
EMAIL_RETRY_SCHEDULE: process.env.EMAIL_RETRY_SCHEDULE || '0 */2 * * * *',
43+
44+
API_CONTEXT_PATH: process.env.API_CONTEXT_PATH || '/v5/email',
45+
4346
};

deploy.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ EMAIL_PAUSE_TIME=$(eval "echo \$${ENV}_EMAIL_PAUSE_TIME")
6666
EMAIL_RETRY_SCHEDULE=$(eval "echo \"\$${ENV}_EMAIL_RETRY_SCHEDULE\"")
6767
DISABLE_LOGGING=$(eval "echo \$${ENV}_DISABLE_LOGGING")
6868

69+
API_CONTEXT_PATH=$(eval "echo \$${ENV}_API_CONTEXT_PATH")
70+
6971
configure_aws_cli() {
7072
aws --version
7173
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
@@ -188,6 +190,10 @@ make_task_def(){
188190
{
189191
"name": "DISABLE_LOGGING",
190192
"value": "%s"
193+
},
194+
{
195+
"name": "API_CONTEXT_PATH",
196+
"value": "%s"
191197
}
192198
],
193199
"portMappings": [
@@ -209,7 +215,7 @@ make_task_def(){
209215
]
210216
}'
211217

212-
task_def=$(printf "$task_template" $family $AWS_ACCOUNT_ID $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV $AUTH_DOMAIN $AUTH_SECRET $DATABASE_URL $EMAIL_FROM "$JWKS_URI" "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID $KAFKA_URL $LOG_LEVEL $PORT $SENDGRID_API_KEY "$TEMPLATE_MAP" "$VALID_ISSUERS" $EMAIL_MAX_ERRORS $EMAIL_PAUSE_TIME "$EMAIL_RETRY_SCHEDULE" "$DISABLE_LOGGING" $PORT $PORT $AWS_ECS_CLUSTER $AWS_REGION $ENV)
218+
task_def=$(printf "$task_template" $family $AWS_ACCOUNT_ID $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV $AUTH_DOMAIN $AUTH_SECRET $DATABASE_URL $EMAIL_FROM "$JWKS_URI" "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID $KAFKA_URL $LOG_LEVEL $PORT $SENDGRID_API_KEY "$TEMPLATE_MAP" "$VALID_ISSUERS" $EMAIL_MAX_ERRORS $EMAIL_PAUSE_TIME "$EMAIL_RETRY_SCHEDULE" "$DISABLE_LOGGING" "$API_CONTEXT_PATH" $PORT $PORT $AWS_ECS_CLUSTER $AWS_REGION $ENV)
213219

214220
}
215221

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"pg": "^7.3.0",
3939
"sequelize": "^4.21.0",
4040
"superagent": "^3.8.0",
41-
"tc-core-library-js": "gondzo/tc-core-library-js.git#dev",
41+
"tc-core-library-js": "appirio-tech/tc-core-library-js.git#v2.2",
4242
"winston": "^2.4.0"
4343
},
4444
"engines": {

src/app.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ function configureKafkaConsumer(handlers) {
5151
return null;
5252
}
5353
let emailModel = {};
54-
const messageJSON = JSON.parse(message);
54+
const busPayload = JSON.parse(message);
55+
const messageJSON = busPayload.payload;
5556
const handlerAsync = Promise.promisify(handler);
5657
// use handler to create notification instances for each recipient
5758
return models.Email.create(
@@ -189,7 +190,7 @@ function start(handlers) {
189190
req.signature = `${def.controller}#${def.method}`;
190191
next();
191192
});
192-
if (url !== '/email/health') {
193+
if (url !== '/health') {
193194
actions.push(jwtAuth());
194195
actions.push((req, res, next) => {
195196
if (!req.authUser) {
@@ -204,7 +205,7 @@ function start(handlers) {
204205
});
205206
});
206207

207-
app.use('/', apiRouter);
208+
app.use(config.API_CONTEXT_PATH, apiRouter);
208209

209210
app.use((req, res) => {
210211
res.status(404).json({ error: 'route not found' });

src/models/Email.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
module.exports = (sequelize, DataTypes) => sequelize.define('Email', {
1414
id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
1515
topicName: { type: DataTypes.STRING, allowNull: true, field: 'topic_name' },
16-
data: { type: DataTypes.STRING, allowNull: false },
16+
data: { type: DataTypes.TEXT, allowNull: false },
1717
recipients: { type: DataTypes.STRING, allowNull: false },
1818
status: { type: DataTypes.STRING, allowNull: false },
1919
}, {});

src/routes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict';
22

33
module.exports = {
4-
'/email/templates/eventType/:name': {
4+
'/templates/:name': {
55
get: {
66
controller: 'TemplateController',
77
method: 'eventTypes',
88
},
99
},
10-
'/email/health': {
10+
'/health': {
1111
get: {
1212
controller: 'HealthController',
1313
method: 'health',

0 commit comments

Comments
 (0)