From 92bde8b0c47d04d9bfd6f35931055059cc808b87 Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Tue, 11 Jul 2023 22:17:45 -0400 Subject: [PATCH 1/3] feat: support postgres password --- src/app.ts | 1 + src/config.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/app.ts b/src/app.ts index 665bbc0a..ac0da772 100644 --- a/src/app.ts +++ b/src/app.ts @@ -55,6 +55,7 @@ const start = (options = {}): FastifyInstance => { user: config.dbSync.user, database: config.dbSync.database, max: config.dbSync.maxConnections, + password: config.dbSync.password, }); // addresses diff --git a/src/config.ts b/src/config.ts index acc2c4c3..de7c76b8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -28,6 +28,9 @@ export const loadConfig = () => { Number(process.env.BLOCKFROST_CONFIG_DBSYNC_PORT) ?? config.get('dbSync.port'); const databaseSyncDatabase = process.env.BLOCKFROST_CONFIG_DBSYNC_DATABASE ?? config.get('dbSync.database'); + const databaseSyncPassword = + process.env.BLOCKFROST_CONFIG_DBSYNC_PASSWORD ?? + (config.has('dbSync.password') ? config.get('dbSync.password') : undefined); const databaseSyncMaxConnections = process.env.BLOCKFROST_CONFIG_DBSYNC_MAX_CONN ? Number(process.env.BLOCKFROST_CONFIG_DBSYNC_MAX_CONN) : config.get('dbSync.maxConnections'); @@ -53,6 +56,7 @@ export const loadConfig = () => { host: databaseSyncHost, port: databaseSyncPort, user: databaseSyncUser, + password: databaseSyncPassword, database: databaseSyncDatabase, maxConnections: databaseSyncMaxConnections, }, From f4b5cde4a9d83a124464eed528a8b30c71ab0dca Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Tue, 11 Jul 2023 22:19:09 -0400 Subject: [PATCH 2/3] docs: add optional postgres password to README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9564ab0a..b08d30ff 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ If you are using an authenticated db connection that requires a password, you'd host: 'cdbsync-dev.mydomain.com', user: 'username', database: 'password', + // Optionally define a password + password: 'randomstringthatissolongandpowerfulthatnoonecanguess' }, // Cardano network - mainnet, testnet, preview, preprod network: 'mainnet', @@ -179,7 +181,7 @@ A minimal usage example is: database = config.services.cardano-db-sync.postgres.database; host = config.services.cardano-db-sync.postgres.socketdir; }; - }; + }; }; } ``` From ae9b22084e6a8000c1aef7b88a53be61e5ca08cf Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Thu, 17 Aug 2023 15:21:11 -0400 Subject: [PATCH 3/3] docs: support postgres password changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ea719e5..62b511dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- support defining a postgres password in config or env + ### Fixed - bump blockfrost-utils to 2.6.2