config parser parses user name and passoword for database
This commit is contained in:
parent
d417b9cf3d
commit
0b987b3261
@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"build": "rm -rf ./build/dist && webpack --config=./webpack.config.js",
|
||||
"lint": "tslint --project ./tsconfig.json --config ./tslint.json",
|
||||
"postinstall": "mkdir node_modules/@graphile && cp -R ./vendor/postgraphile-supporter/ ./node_modules/@graphile/plugin-supporter/",
|
||||
"postinstall": "rm -rf node_modules/@graphile && mkdir node_modules/@graphile && cp -R ./vendor/postgraphile-supporter/ ./node_modules/@graphile/plugin-supporter/",
|
||||
"start": "npm run build && node ./build/dist/vulcanize-postgraphile-server.js",
|
||||
"test": "rm -rf ./build/spec && tsc --build ./tsconfig.test.json && jasmine --config=./spec/support/jasmine.json",
|
||||
"test:ci": "npm run lint && npm run test"
|
||||
|
@ -16,7 +16,9 @@ describe('parseConfig', () => {
|
||||
database: {
|
||||
hostname: 'example.com',
|
||||
name: 'example_database',
|
||||
port: '1234'
|
||||
port: '1234',
|
||||
user: 'user',
|
||||
password: 'password'
|
||||
}
|
||||
};
|
||||
|
||||
@ -31,7 +33,7 @@ describe('parseConfig', () => {
|
||||
const databaseConfig = parseConfig(
|
||||
readCallback, tomlParseCallback, configPath);
|
||||
|
||||
expect(databaseConfig.host).toEqual('postgres://example.com:1234');
|
||||
expect(databaseConfig.host).toEqual('postgres://user:password@example.com:1234');
|
||||
});
|
||||
|
||||
it('provides the database name', () => {
|
||||
|
@ -24,6 +24,8 @@ export function parseConfig(
|
||||
const host = parsedToml['database']['hostname'];
|
||||
const port = parsedToml['database']['port'];
|
||||
const database = parsedToml['database']['name'];
|
||||
const user = parsedToml['database']['user'] || '';
|
||||
const password = parsedToml['database']['password'] || '';
|
||||
|
||||
if (!host || host.length < 1) {
|
||||
throw new Error(MISSING_HOST_MESSAGE);
|
||||
@ -33,5 +35,5 @@ export function parseConfig(
|
||||
throw new Error(MISSING_DATABASE_MESSAGE);
|
||||
}
|
||||
|
||||
return { host: `postgres://${host}:${port}`, database };
|
||||
return { host: `postgres://${user}:${password}@${host}:${port}`, database };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user