Skip to content

Commit

Permalink
updated modules and addressed a pg client issue
Browse files Browse the repository at this point in the history
- updated to the latest modules
- fixed an issue encountered with the pg module described here: brianc/node-postgres#2009 (comment)
  • Loading branch information
dprosper committed May 12, 2021
1 parent f30cae0 commit 9fc8139
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
22 changes: 11 additions & 11 deletions sampleapps/nodejs-graphql/package.json
@@ -1,6 +1,6 @@
{
"name": "nodejs-graphql",
"version": "0.1.0",
"version": "0.1.1",
"main": "./build/index.js",
"repository": "https://github.com/IBM-Cloud/vpc-tutorials.git",
"author": "IBM",
Expand All @@ -11,10 +11,10 @@
"start": "node build/index.js"
},
"dependencies": {
"@babel/runtime": "^7.12.13",
"@babel/runtime": "^7.14.0",
"axios": "^0.21.1",
"body-parser": "^1.19.0",
"chalk": "^4.1.0",
"chalk": "^4.1.1",
"compression": "^1.7.4",
"cookie-parser": "^1.4.5",
"cookie-session": "^1.4.0",
Expand All @@ -24,22 +24,22 @@
"express-session": "^1.17.1",
"fs-extra": "^9.1.0",
"graphql": "^15.5.0",
"ibm-cos-sdk": "^1.9.0",
"ibm-cos-sdk": "^1.10.0",
"moment": "^2.29.1",
"morgan": "^1.10.0",
"pg": "^8.5.1",
"pg": "^8.6.0",
"uuid": "^8.3.2",
"winston": "^3.3.3",
"winston-daily-rotate-file": "^4.5.0"
"winston-daily-rotate-file": "^4.5.5"
},
"devDependencies": {
"@babel/cli": "^7.12.13",
"@babel/core": "^7.12.13",
"@babel/plugin-transform-runtime": "^7.12.15",
"@babel/preset-env": "^7.12.13",
"@babel/cli": "^7.13.16",
"@babel/core": "^7.14.2",
"@babel/plugin-transform-runtime": "^7.14.2",
"@babel/preset-env": "^7.14.2",
"rimraf": "^3.0.2"
},
"prefixes": {
"cookiesPrefix": "vpc:"
}
}
}
19 changes: 16 additions & 3 deletions sampleapps/nodejs-graphql/src/createTables.js
Expand Up @@ -10,11 +10,24 @@ const credentials = pg_credentials[0].credentials;
(async function createTables() {
let postgresconn = credentials.connection.postgres;

// Connection String is failing starting in pg 8.5.x: https://github.com/brianc/node-postgres/issues/2009#issuecomment-753211352
// let database_config = {
// connectionString: postgresconn.composed[0],
// ssl: {
// ca: Buffer.from(postgresconn.certificate.certificate_base64, 'base64').toString()
// }
// };

let database_config = {
connectionString: postgresconn.composed[0],
user: postgresconn.authentication.username,
host: postgresconn.hosts[0].hostname,
database: postgresconn.database,
password: postgresconn.authentication.password,
port: postgresconn.hosts[0].port,
ssl: {
ca: Buffer.from(postgresconn.certificate.certificate_base64, 'base64').toString()
}
rejectUnauthorized: true,
ca: Buffer.from(postgresconn.certificate.certificate_base64, 'base64').toString(),
},
};

// Create a pool.
Expand Down
19 changes: 16 additions & 3 deletions sampleapps/nodejs-graphql/src/index.js
Expand Up @@ -73,11 +73,24 @@ app.use(
}

let postgresconn = pg_credentials[0].credentials.connection.postgres;
// Connection String is failing starting in pg 8.5.x: https://github.com/brianc/node-postgres/issues/2009#issuecomment-753211352
// let database_config = {
// connectionString: postgresconn.composed[0],
// ssl: {
// ca: Buffer.from(postgresconn.certificate.certificate_base64, 'base64').toString()
// }
// };

let database_config = {
connectionString: postgresconn.composed[0],
user: postgresconn.authentication.username,
host: postgresconn.hosts[0].hostname,
database: postgresconn.database,
password: postgresconn.authentication.password,
port: postgresconn.hosts[0].port,
ssl: {
ca: Buffer.from(postgresconn.certificate.certificate_base64, 'base64').toString()
}
rejectUnauthorized: true,
ca: Buffer.from(postgresconn.certificate.certificate_base64, 'base64').toString(),
},
};

// Create a pool.
Expand Down

0 comments on commit 9fc8139

Please sign in to comment.