fix(core.gbapp): Fixes #391 ignore case during params object access.

This commit is contained in:
Rodrigo Rodriguez 2024-01-10 15:43:07 -03:00
parent 99da0001d7
commit c844613c98
2 changed files with 22 additions and 16 deletions

View file

@ -9,16 +9,15 @@ import pjson from './package.json' assert { type: 'json' };
console.log(``); console.log(``);
console.log(``); console.log(``);
console.log(` █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® `); console.log(``);
console.log(`██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ `); console.log(``);
console.log(`██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ `); console.log(``);
console.log(`██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ `); console.log(`General Bots Open-core Server 3.1 is initializing...`);
console.log(` █████ █████ █ ███ █████ ██ ██ ██ ██ ██████ ████ █████ █ ███ 3.1`); console.log(`Visit: https://github.com/generalbots.`);
process.stdout.write(` botserver@${pjson.version}, botlib@${pjson.dependencies.botlib}, botbuilder@${pjson.dependencies.botbuilder}, node@${process.version.replace('v', '')}, ${process.platform} ${process.arch} `); console.log(``);
process.stdout.write(`Enviroment: botserver@${pjson.version}, botlib@${pjson.dependencies.botlib}, botbuilder@${pjson.dependencies.botbuilder}, node@${process.version.replace('v', '')}, ${process.platform} ${process.arch} `);
var now = () => { console.log(``);
return new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '') + ' UTC'; console.log(``);
};
var __dirname = process.env.PWD || process.cwd(); var __dirname = process.env.PWD || process.cwd();
try { try {
var run = () => { var run = () => {

View file

@ -60,6 +60,7 @@ import open from 'open';
import ngrok from 'ngrok'; import ngrok from 'ngrok';
import Path from 'path'; import Path from 'path';
import { file } from 'googleapis/build/src/apis/file/index.js'; import { file } from 'googleapis/build/src/apis/file/index.js';
import { GBUtil } from '../../../src/util.js';
/** /**
* GBCoreService contains main logic for handling storage services related * GBCoreService contains main logic for handling storage services related
@ -675,26 +676,32 @@ ENDPOINT_UPDATE=true
*/ */
public getParam<T>(instance: IGBInstance, name: string, defaultValue?: T): any { public getParam<T>(instance: IGBInstance, name: string, defaultValue?: T): any {
let value = null; let value = null;
let params;
name = name.trim();
if (instance.params) { if (instance.params) {
const params = typeof (instance.params) === 'object' ? instance.params: JSON.parse(instance.params); params = typeof (instance.params) === 'object' ? instance.params: JSON.parse(instance.params);
params = GBUtil.caseInsensitive(params);
value = params ? params[name] : defaultValue; value = params ? params[name] : defaultValue;
} }
if (typeof defaultValue === 'boolean') { if (value && typeof defaultValue === 'boolean') {
return new Boolean(value ? value.toString().toLowerCase() === 'true' : defaultValue).valueOf(); return new Boolean(value ? value.toString().toLowerCase() === 'true' : defaultValue).valueOf();
} }
if (typeof defaultValue === 'string') { if (value && typeof defaultValue === 'string') {
return value ? value : defaultValue; return value ? value : defaultValue;
} }
if (typeof defaultValue === 'number') { if (value && typeof defaultValue === 'number') {
return new Number(value ? value : defaultValue ? defaultValue : 0).valueOf(); return new Number(value ? value : defaultValue ? defaultValue : 0).valueOf();
} }
if (instance['dataValues'] && !value) { params = GBUtil.caseInsensitive(instance['dataValues']);
if (params && !value) {
value = instance['dataValues'][name]; value = instance['dataValues'][name];
if (value === null) { if (value === null) {
const minBoot = GBServer.globals.minBoot as any; const minBoot = GBServer.globals.minBoot as any;
value = minBoot.instance[name]; params = GBUtil.caseInsensitive(minBoot.instance);
value = params[name];
} }
} }
if (value === undefined) { if (value === undefined) {