Skip to content

Commit

Permalink
Merge pull request #6 from SafalPandey/log-fix
Browse files Browse the repository at this point in the history
Remove password attribute from connections object before logging
  • Loading branch information
kabirbaidhya authored Aug 9, 2019
2 parents 28b714d + 0c85551 commit a18084a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { log } from './logger';
import * as fs from './util/fs';
import Connection from './domain/Connection';
import Configuration from './domain/Configuration';
import ConnectionConfig from './domain/ConnectionConfig';
import { DEFAULT_CONFIG, CONFIG_FILENAME, CONNECTIONS_FILENAME } from './constants';

/**
Expand Down Expand Up @@ -41,18 +42,16 @@ export async function resolveConnections(): Promise<Connection[]> {
log('Resolving file: %s', filename);

const loaded = await fs.read(filename);
const { connections } = JSON.parse(loaded);

log('Connections parsed: %o', connections);
const { connections } = JSON.parse(loaded) as ConnectionConfig;

// TODO: Validate the connections received from file.

const result = connections.map((connection: Connection) => ({
const result = connections.map(connection => ({
...connection,
id: connection.id || `${connection.host}/${connection.database}`
}));

log('Resolved connections: %O', connections);
log('Resolved connections: %O', result.map(({ id, host, database }) => ({ id, host, database })));

return result;
}
10 changes: 10 additions & 0 deletions src/domain/ConnectionConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Connection from './Connection'

/**
* Interface for sync-db connection file (connections.sync-db.json).
*/
interface ConnectionConfig {
connections: Connection[];
}

export default ConnectionConfig;

0 comments on commit a18084a

Please sign in to comment.