Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 7b7aad5

Browse files
author
James Cori
committed
Merge branch 'develop'
2 parents a501d39 + 8e5b024 commit 7b7aad5

File tree

14 files changed

+178
-64
lines changed

14 files changed

+178
-64
lines changed

app.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @version 1.0
99
*/
1010
'use strict';
11+
const config = require('config');
12+
const _ = require('lodash');
1113
const express = require('express');
1214
const cookieParser = require('cookie-parser');
1315
const bodyParser = require('body-parser');
@@ -72,4 +74,37 @@ process.on('unhandledRejection', (err) => {
7274
logger.logFullError(err, 'system');
7375
});
7476

77+
// dump the configuration to logger
78+
const ignoreConfigLog = ['cert', 'key', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET'];
79+
/**
80+
* Print configs to logger
81+
* @param {Object} params the config params
82+
* @param {Number} level the level of param object
83+
*/
84+
function dumpConfigs(params, level) {
85+
Object.keys(params).forEach((key) => {
86+
if (_.includes(ignoreConfigLog, key)) {
87+
return;
88+
}
89+
const item = params[key];
90+
let str = '';
91+
let n = 0;
92+
while (n < level) { // eslint-disable-line no-restricted-syntax
93+
n++;
94+
str += ' ';
95+
}
96+
if (item && _.isObject(item)) {
97+
str += `${key}=`;
98+
logger.debug(str);
99+
dumpConfigs(item, level + 1);
100+
} else {
101+
str += `${key}=${item}`;
102+
logger.debug(str);
103+
}
104+
});
105+
}
106+
logger.debug('--- List of Configurations ---');
107+
dumpConfigs(config, 0);
108+
logger.debug('--- End of List of Configurations ---');
109+
75110
module.exports = app;

config/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const fs = require('fs');
1515

1616
module.exports = {
1717
PORT: process.env.PORT || 3000, // eslint-disable-line no-magic-numbers
18-
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
18+
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',
1919
TOPIC: process.env.TOPIC || 'tc-x-events',
2020
KAFKA_OPTIONS: {
2121
connectionString: process.env.KAFKA_URL || 'localhost:9092',

models/CommentCreatedEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CommentCreatedEvent.schema = Joi.object().keys({
2121
id: Joi.number().required(),
2222
body: Joi.string().allow(''),
2323
user: Joi.object().keys({
24-
id: Joi.number().required()
24+
id: Joi.alternatives().try(Joi.string(), Joi.number()).required()
2525
}).required()
2626
}),
2727
repository: repositorySchema.required()

models/IssueClosedEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const IssueClosedEvent = {
1818
issue: issueSchema.required(),
1919
repository: repositorySchema.required(),
2020
assignee: Joi.object().keys({
21-
id: Joi.number().allow(null)
21+
id: Joi.alternatives().try(Joi.string(), Joi.number()).allow(null)
2222
}).required()
2323
})
2424
};

models/Project.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ const schema = new Schema({
3030
}
3131
},
3232
repoUrl: {type: String, required: true},
33+
repoId: {type: String, required: false},
3334
rocketChatWebhook: {type: String, required: false},
3435
rocketChatChannelName: {type: String, required: false},
3536
archived: {type: String, required: true},
3637
owner: {type: String, required: true},
37-
secretWebhookKey: {type: String, required: true}
38+
secretWebhookKey: {type: String, required: true},
39+
createCopilotPayments: {type: String, required: false},
40+
isConnect: {type: Boolean, required: false, default: true}
3841
});
3942

4043
module.exports = schema;

models/UserAssignedEvent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ UserAssignedEvent.schema = Joi.object().keys({
1919
issue: issueSchema.required(),
2020
repository: repositorySchema.required(),
2121
assignee: Joi.object().keys({
22-
id: Joi.number().required()
22+
id: Joi.alternatives().try(Joi.string(), Joi.number()).required()
2323
}).required()
2424
});
2525

models/common.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Joi = require('joi');
1616

1717
// the repository schema
1818
const repositorySchema = Joi.object().keys({
19-
id: Joi.number().required(),
19+
id: Joi.alternatives().try(Joi.string(), Joi.number()).required(),
2020
name: Joi.string().required(),
2121
full_name: Joi.string().required()
2222
});
@@ -28,10 +28,10 @@ const issueSchema = Joi.object().keys({
2828
body: Joi.string().allow(''),
2929
labels: Joi.array().items(Joi.string()),
3030
assignees: Joi.array().items(Joi.object().keys({
31-
id: Joi.number().required()
31+
id: Joi.alternatives().try(Joi.string(), Joi.number()).required()
3232
})),
3333
owner: Joi.object().keys({
34-
id: Joi.number().required()
34+
id: Joi.alternatives().try(Joi.string(), Joi.number()).required()
3535
}).required()
3636
});
3737

@@ -43,10 +43,10 @@ const pullRequestSchema = Joi.object().keys({
4343
body: Joi.string().allow(''),
4444
title: Joi.string().required(),
4545
user: Joi.object().keys({
46-
id: Joi.number().required()
46+
id: Joi.alternatives().try(Joi.string(), Joi.number()).required()
4747
}),
4848
assignees: Joi.array().items({
49-
id: Joi.number().required()
49+
id: Joi.alternatives().try(Joi.string(), Joi.number()).required()
5050
})
5151
});
5252

models/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ dynamoose.setDefaults({
2828
update: false
2929
});
3030

31+
if (process.env.CREATE_DB) {
32+
dynamoose.setDefaults({
33+
create: true,
34+
update: true
35+
});
36+
}
37+
3138
const IssueCreatedEvent = require('./IssueCreatedEvent');
3239
const IssueUpdatedEvent = require('./IssueUpdatedEvent');
3340
const IssueClosedEvent = require('./IssueClosedEvent');

package-lock.json

Lines changed: 31 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"private": true,
55
"scripts": {
66
"start": "node ./bin/www",
7-
"lint": "eslint . --ignore-pattern 'public/*' --ext .js --fix || true"
7+
"lint": "eslint . --ignore-pattern 'public/*' --ext .js --fix || true",
8+
"create-tables": "CREATE_DB=true node scripts/create-update-tables.js"
89
},
910
"engines": {
1011
"node": "~8.6.0"

0 commit comments

Comments
 (0)