AdamPuzio / panda

Node.js rapid development framework
4 stars 0 forks source link

Undefined config values being returned as empty object #11

Closed AdamPuzio closed 2 years ago

AdamPuzio commented 2 years ago

When accessing config values that haven't been defined, the Config class is returning an empty object ({}) instead of undefined.

const Panda = require('panda')
const Config = Panda.Config.cfg

// how it works
let testVar = Config.value_does_not_exist
// testVar = {}

// how it should work
let testVar = Config.value_does_not_exist
// testVar = undefined
AdamPuzio commented 2 years ago

Decided to use cache-base for configuration. Local references have been updated to reflect the change. Will be available in the 0.3.4 release.

Now, you can retrieve the config one of two ways:

// shortcut
const Config = Panda.getConfig()
// or
const Config = Panda.Config.getConfig()

from there you use get() function to retrieve values:

let appPath = Config.get('APP_PATH')