Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get root/whole config #350

Open
1 of 4 tasks
Javarome opened this issue Nov 26, 2020 · 2 comments
Open
1 of 4 tasks

Cannot get root/whole config #350

Javarome opened this issue Nov 26, 2020 · 2 comments

Comments

@Javarome
Copy link

Issue type:

  • question
  • bug report
  • feature request
  • documentation issue

nestjs-config version
0.5.0

@nestjs/common+core or other package versions

  • @nestjs/common: 7.5.5
  • @nestjs/core: 7.5.5

Excepted behavior

serviceConfig.get() returns root/whole config object.

Actual behavior or outcome (for issue)

A parameter is mandatory to get a specific field of the config.

Replication/Example

I defined my config as a complex object with fields being sub-objects, etc.
and need to provide that object to another party (a database, some service, the frontend, whatever).

Today:

config = serviceConfig.get()

is not allowed.

and I'm constrained to break encapsulation by doing:

config = serviceConfig['internalConfig']
@bashleigh
Copy link
Collaborator

Hmmmm, this is not something that exists in the latest version, 1.4.7 or the next version ^2.0.0.
Could you provide an example of how you're structuring your config object please? nestjs-config started out as a 'laravel-like' config folder/file structure. So database config goes into a database.ts file and to get that config you use config.get('database') which would return the export object/class from database.ts.

Version ^2.0.0 currently only uses export default to add config to the config service. I have been thinking about enabling all exports which sounds similar to your request? But not completely.

Let me know how you're expecting to use the package and I'll see if it's possible to tweek.How comes you're using version 0.5.0 though?

@pvogel1967
Copy link

pvogel1967 commented Jan 30, 2021

It's a pretty standard pattern for an app to log out its config when it bootstraps itself. I don't know Jerome's use case, but mine is pretty simple, in our configureApp() method:

const configService = app.get(ConfigService)
ROOT_LOGGER.info(configService.get(), 'Initial Container Configuration');

Alternatively, if you had a method in ConfigService that returned the available configuration namespaces as an array, I could then do the dump by walking the namespaces returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants