getConfiguration() method question about settings

This method and in general setting the settings for this confused me a little.

I set the settings manually to reflect needed values. But I was wondering these 3 things.

  1. Why can’t i set this settings in the env file and if so how do I access them again.

  2. What is setting the undefined key object of {poolSize, wtimeout} = movies.s.db.serverConfi.s.options doing exactly? What is the purpose of this as I am not completely seeing it.

  3. If the object is directly set here then what is the purpose of the above statement as the variables are no longer being used?

    static async getConfiguration() {
         const roleInfo = await mflix.command({ connectionStatus: 1 })
         const authInfo = roleInfo.authInfo.authenticatedUserRoles[0]
         const { poolSize, wtimeout } = movies.s.db.serverConfig.s.options
         let response = {
           poolSize: 50,
           wtimeout: 2500,
         console.log('this stuff here 44444444 ', response)
         console.log('this stuff here rrrrrrr ', movies.s.db.serverConfig.s.options)
         return response

I believe, getConfiguration() method was designed for internal status checks (e.g. in tests), and is not supposed to be modified within this course. Basically, it just returns few settings, and does not change anything. Note, get- prefix is a very common convention to mark method as a “getter” (so, no mutations are expected).

So, I recommend you to read again that ticket description, as it points exactly at file names, where connection is initialized — you should add settings over there. See documentation example for that.

  1. You can, actually. And it’s a good place for that!
    Basically, you just add ANY_STRING=anything to your .env file and then read it from code as process.env.ANY_STRING.
    There’s a catch, though — it will be a string, so sometimes you would need to make a type conversion, for example here’s how you can get a true number from string: const myNumber = Number('123')
  1. Well, that’s just a ES6 syntax for destructuring objects, which basically means: “gimme only these [two] properties from that object”. Take a look at this explanation with examples and try to look for this term on youtube if that’s still not enough.

  2. And next construction is also a specific “syntax sugar” to set object properties in a shorter way. Take a look at this explanation.

Hope that helps. Ask more, if there’s anything still unclear)


Thanks for the examples… Again, object structure for the bite in the butt again. I appreciate it and will look at the articles.

1 Like