Browse Source

feat: parsing number values in config parsing

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/473/head
Pranav C 3 years ago
parent
commit
ccdd47a47c
  1. 6
      packages/nocodb/src/__tests__/noco/NcConfigFactory.test.ts
  2. 5
      packages/nocodb/src/lib/utils/NcConfigFactory.ts

6
packages/nocodb/src/__tests__/noco/NcConfigFactory.test.ts

@ -34,12 +34,10 @@ describe('Config Factory Tests', () => {
expect(config.connection.password).to.be.eq('xgene')
expect(config.connection.database).to.be.eq('abcde')
expect(config.pool).to.be.a('object')
expect(config.pool.min).to.be.eq('1')
expect(config.pool.max).to.be.eq('2')
expect(config.pool.min).to.be.eq(1)
expect(config.pool.max).to.be.eq(2)
expect(config.ssl).to.be.a('object')
expect(config.ssl.rejectUnauthorized).to.be.eq(false)
done();
});
});

5
packages/nocodb/src/lib/utils/NcConfigFactory.ts

@ -313,12 +313,15 @@ export default class NcConfigFactory implements NcConfig {
}
}
url.searchParams.forEach((_value, key) => {
let value:any = _value;
let value: any = _value;
if (value === 'true') {
value = true;
} else if (value === 'false') {
value = false;
} else if (/^\d+$/.test(value)) {
value = +value;
}
// todo: implement config read from JSON file or JSON env val read
if (!['password', 'p', 'database', 'd', 'user', 'u', 'search_path'].includes(key)) {
key.split('.').reduce((obj, k, i, arr) => {
return obj[k] = i === arr.length - 1 ? value : (obj[k] || {})

Loading…
Cancel
Save