From ccdd47a47c062ebaa3c897eabdf8c2f8deecf3b1 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 19 Aug 2021 00:02:52 +0530 Subject: [PATCH] feat: parsing number values in config parsing Signed-off-by: Pranav C --- packages/nocodb/src/__tests__/noco/NcConfigFactory.test.ts | 6 ++---- packages/nocodb/src/lib/utils/NcConfigFactory.ts | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/__tests__/noco/NcConfigFactory.test.ts b/packages/nocodb/src/__tests__/noco/NcConfigFactory.test.ts index 6050800640..8ed25d6448 100644 --- a/packages/nocodb/src/__tests__/noco/NcConfigFactory.test.ts +++ b/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(); }); - - }); diff --git a/packages/nocodb/src/lib/utils/NcConfigFactory.ts b/packages/nocodb/src/lib/utils/NcConfigFactory.ts index 12197008d8..17da9e6378 100644 --- a/packages/nocodb/src/lib/utils/NcConfigFactory.ts +++ b/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] || {})