diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fe7b9d0..a7b40d33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Flake now exports NixOS module ### Changed +- support defining a postgres password in config or env + +### Fixed - nixpkgs updated to latest `nixos-23.05` - NodeJS updated to `18.16.1` 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; }; - }; + }; }; } ``` 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, },