Skip to content

Commit d1d4ecd

Browse files
authored
Merge pull request #149 from CodeForBaltimore/revjtanton/HOTFIX-sequelize-ssl
Revjtanton/hotfix sequelize ssl
2 parents 36064d5 + a9e2383 commit d1d4ecd

File tree

8 files changed

+37
-15
lines changed

8 files changed

+37
-15
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bmore-responsive",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "An API-driven CRM (Civic Relationship Management) system.",
55
"main": "src/index.js",
66
"directories": {
@@ -58,12 +58,12 @@
5858
"pg": "7.18.2",
5959
"random-words": "1.1.1",
6060
"sequelize": "5.21.6",
61+
"snyk": "^1.316.1",
6162
"supertest": "4.0.2",
6263
"swagger-ui-express": "4.1.4",
6364
"tls": "0.0.1",
6465
"uuid4": "1.1.4",
65-
"validator": "12.2.0",
66-
"snyk": "^1.316.1"
66+
"validator": "12.2.0"
6767
},
6868
"devDependencies": {
6969
"@babel/compat-data": "7.8.6",

publiccode.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ publiccodeYmlVersion: "0.2"
33
name: Bmore-Responsive
44
url: "https://github.com/CodeForBaltimore/Bmore-Responsive.git"
55
landingUrl: "https://github.com/CodeForBaltimore/Bmore-Responsive"
6-
softwareVersion: "1.1.0"
6+
softwareVersion: "1.1.1"
77
releaseDate: "2020-04-06"
88
platforms:
99
- web

src/email/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const sendMail = async (to, subject, html, text) => {
3535
* @param {string} resetPasswordToken temporary token for the reset password link
3636
*/
3737
const sendForgotPassword = async (userEmail, resetPasswordToken) => {
38-
const emailResetLink = `https://healthcare-rollcall.netlify.com/reset/${resetPasswordToken}`;
38+
const emailResetLink = `https://healthcarerollcall.org/reset/${resetPasswordToken}`;
3939
await sendMail(
4040
userEmail,
4141
"Password Reset - Healthcare Roll Call",

src/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,14 @@ app.use((error, req, res, next) => {
7777
});
7878

7979
// Starting Express and connecting to PostgreSQL
80-
sequelize.sync().then(async () => {
81-
app.listen(process.env.PORT || 3000, () => {
82-
console.log(`Bmore Responsive is available at http://localhost:${process.env.PORT || 3000}`);
80+
try {
81+
sequelize.sync().then(() => {
82+
app.listen(process.env.PORT || 3000, () => {
83+
console.log(`Bmore Responsive is available at http://localhost:${process.env.PORT || 3000}`);
84+
});
8385
});
84-
});
86+
} catch (e) {
87+
console.error(e);
88+
}
8589

8690
export default app;

src/routes/entity.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ router.put('/', async (req, res) => {
9898
let message;
9999
try {
100100
if (validator.isUUID(req.body.id)) {
101-
let { id, name, address, phone, email, checkIn, contacts } = req.body;
101+
let { id, name, type, address, phone, email, checkIn, contacts } = req.body;
102102

103103
/** @todo validate emails */
104104
// Validating emails
@@ -111,6 +111,7 @@ router.put('/', async (req, res) => {
111111
});
112112

113113
entity.name = (name) ? name : entity.name;
114+
entity.type = (type) ? type : entity.type;
114115
entity.address = (address) ? address : entity.address;
115116
entity.phone = (phone) ? phone : entity.phone;
116117
entity.email = (email) ? email : entity.email;

src/utils/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import crypto from 'crypto';
44
import validator from 'validator';
5+
import fs from 'fs';
56
import { newEnforcer } from 'casbin';
67
import { SequelizeAdapter } from 'casbin-sequelize-adapter';
78

89
const casbinConf = `${__dirname}/casbin.conf`;
10+
const rdsCa = fs.readFileSync('./rds-combined-ca-bundle.pem');
911

1012
/**
1113
* Formats a timestamp to something readable by humans.
@@ -31,11 +33,26 @@ const formatTime = seconds => {
3133
* @returns {Object}
3234
*/
3335
const loadCasbin = async () => {
34-
const dbUrl = process.env.DATABASE_URL;
36+
let dialectOptions;
37+
if (process.env.NODE_ENV === 'production') {
38+
dialectOptions = {
39+
ssl: {
40+
rejectUnauthorized: true,
41+
ca: [rdsCa],
42+
checkServerIdentity: (host, cert) => {
43+
const error = tls.checkServerIdentity(host, cert);
44+
if (error && !cert.subject.CN.endsWith('.rds.amazonaws.com')) {
45+
return error;
46+
}
47+
}
48+
}
49+
};
50+
}
3551
const a = await SequelizeAdapter.newAdapter(
36-
dbUrl,
52+
dbUrl(),
3753
{
38-
dialect: 'postgres'
54+
dialect: 'postgres',
55+
dialectOptions: dialectOptions
3956
}
4057
);
4158

swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
} ],
77
"info" : {
88
"description" : "An emergency response and contact management API.",
9-
"version" : "1.1.0",
9+
"version" : "1.1.1",
1010
"title" : "Bmore Responsive",
1111
"contact" : {
1212
"email" : "[email protected]"

0 commit comments

Comments
 (0)