-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from DEFRA/feature/add-sql-task
Feature/add sql task
- Loading branch information
Showing
23 changed files
with
900 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
sonar.javascript.exclusions=**/jest.config.js,**/jest.setup.js,**/__mocks__/**,**/node_modules/**,**/test/**,**/test-output/** | ||
sonar.javascript.exclusions=**/jest.config.js,**/jest.setup.js,**/__mocks__/**,**/node_modules/**,**/test/**,**/test-output/**,/src/examples/** | ||
sonar.javascript.lcov.reportPaths=test-output/lcov.info | ||
sonar.exclusions=/test/**,**/*.test.js,*snyk_report.html,*snyk_report.css | ||
sonar.exclusions=/test/**,**/*.test.js,*snyk_report.html,*snyk_report.css,/src/examples/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { PostgresDatabaseConnection } = require("./postgresDatabaseConnection") | ||
|
||
module.exports = { | ||
PostgresDatabaseConnection | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const DEFAULT_PORT = 5432 | ||
const { Sequelize } = require('sequelize') | ||
const debug = require('debug')('connection') | ||
|
||
/** | ||
* | ||
* @param {Object} options | ||
* @param {Object} options.connectionname | ||
* @param {Object} options.username | ||
* @param {Object} options.password | ||
* @param {Object} options.database | ||
* @param {Object} options.host | ||
* @param {Object} options.port | ||
* @returns Connection | ||
*/ | ||
async function PostgresDatabaseConnection(options){ | ||
const connectionname = options.connectionname | ||
const username = options.username | ||
const password = options.password | ||
const database = options.database | ||
const host = options.host | ||
const port = options.port || DEFAULT_PORT | ||
|
||
const sequelize = new Sequelize(database, username, password, { | ||
host: host, | ||
port: port, | ||
dialect: 'postgres', | ||
logging: false | ||
}) | ||
|
||
try{ | ||
await sequelize.authenticate() | ||
debug('sequelize.authenticate succeeded') | ||
return { | ||
name: connectionname, | ||
db: sequelize | ||
} | ||
} catch(e){ | ||
debug('sequelize.authenticate failed') | ||
debug(e) | ||
throw e | ||
} | ||
} | ||
|
||
module.exports = { | ||
PostgresDatabaseConnection | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.