Skip to content

Commit

Permalink
Merge pull request #117 from Liqwid-Labs/feat/postgres-password
Browse files Browse the repository at this point in the history
feat: support postgres password
  • Loading branch information
1000101 authored Aug 17, 2023
2 parents df48c29 + ae9b220 commit 3321506
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
};
};
};
};
}
```
Expand Down
1 change: 1 addition & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const loadConfig = () => {
Number(process.env.BLOCKFROST_CONFIG_DBSYNC_PORT) ?? config.get<number>('dbSync.port');
const databaseSyncDatabase =
process.env.BLOCKFROST_CONFIG_DBSYNC_DATABASE ?? config.get<string>('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<number>('dbSync.maxConnections');
Expand All @@ -53,6 +56,7 @@ export const loadConfig = () => {
host: databaseSyncHost,
port: databaseSyncPort,
user: databaseSyncUser,
password: databaseSyncPassword,
database: databaseSyncDatabase,
maxConnections: databaseSyncMaxConnections,
},
Expand Down

0 comments on commit 3321506

Please sign in to comment.