GithubHelp home page GithubHelp logo

Should we remove $env? about confidence HOT 6 OPEN

hapipal avatar hapipal commented on June 16, 2024
Should we remove $env?

from confidence.

Comments (6)

Nargonath avatar Nargonath commented on June 16, 2024

I use $env a lot so as long as we don't lose the feature I'm all up for it. Especially if it simplifies the codebase. It doesn't seem to overcomplicate the API. Only downside I see is that $env was more explicit to where it gets its values from compared to $param if you're not too familiar with confidence API.

from confidence.

YoannMa avatar YoannMa commented on June 16, 2024

We use $env as well because it's more explicit, plus we use criteria for other things like sentry/tracing agent that need to be initialized before any other require() but are needed in a plugin for biding with server's events, requests, etc

It would not be a deal breaker thought, we could just do :

const store = new Confidence.Store({
    server: {
        host: 'localhost',
        port: {
            $param: 'env.PORT',
            $coerce: 'number',
            $default: 3000
        },
        debug: {
            $filter: 'env.NODE_ENV',
            $default: {
                log: ['error'],
                request: ['error']
            },
            production: {
                request: ['implementation']
            }
        }
    }
});

const config = store.get('/', { env : process.env, other: 'things' });

Bonus point for still being explicit enough too

from confidence.

Nargonath avatar Nargonath commented on June 16, 2024

@YoannMa Good idea I like it that way too, plus as you mentioned it's still explicit.

from confidence.

devinivy avatar devinivy commented on June 16, 2024

If we decide we want to go forward with this, I have a proposal here: #110

I thought that removing $env left a small gap, so in that proposal I introduced a way to bind criteria to the store, store.bind(). I think it has some nice upsides, but check out the proposal if you're interested and of course feel free to offer any feedback, concerns, questions. @augnin if you have the time, I am especially interested to hear what you're thinking on all of this.

from confidence.

devinivy avatar devinivy commented on June 16, 2024

Worth noting that there was some chatter in hapi hour about this, mostly concerns that removing $env would make things less explicit than it currently is, and that some folks like having this feature available to them. I would love to at least keep its feature set in parity with $param, and maintain it as just a special case of $param.

from confidence.

Nargonath avatar Nargonath commented on June 16, 2024

I agree. If we were to modify this feature, leveraging $param as @YoannMa mentioned above seems to be the best choice IMO.

from confidence.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.