question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] load config files from multiple sources

See original GitHub issue

Dear all,

thank you very much for this nice package. I am quite new to TypeScript - therefore, this might be a stupid question. Anyway, I am going for this 😆

Consider the following scenario (folder structure):

src
   app
      modules
         cat
            config
               cat-config.ts
               customconfig.ts
               whatever.ts
         dog
            config
               dog-config.ts
         snake
            config
               snake-config.ts
   config
      app.ts
      database.ts
      filesystem.ts

Basically, i would like to load all config files which are scattered around my application. Basic config files, like the app.ts or database.ts are stored in the src/app/config folder, whereas “domain specific” config files are located within their own module folder (e.g., the cat module has its configuration stored in src/app/modules/cat/config/cat-config.ts

Upon start of the application, i would like to get and merge all config files together, so i can use config.get('cat-config.deeply.nested.value'); to access specific values.

How can i manage to solve this?

All the best

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:27 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
bashleighcommented, Jan 28, 2019

@eugenchio There is now a ‘modifyConfigName’ options that you can pass in.

 @Module({
  imports: [
    ConfigModule.load(path.resolve(__dirname, '*-config.ts'), {
        modifyConfigName: name => name.replace('-config', ''),
    }),
  ],
})

I’ve noticed this isn’t actually in the readme 👎 so I’ll add an issue for that now

1reaction
bashleighcommented, Jan 28, 2019

I’ve opened #57 for the merge/immutable. I’ve also opened a PR for modifyConfigName method to be added to the readme https://github.com/nestjs-community/nestjs-config/tree/feature/modify-name-readme#multi-modular-config-usage

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Question] load config files from multiple sources · Issue #42
Upon start of the application, i would like to get and merge all config files together, so i can use config.get('cat-config.deeply.nested.value ...
Read more >
Multiple config files: Which one do the process read from?
I have a solution with multiple projects. In each project I've added a .config file with settings that affect the local settings. When...
Read more >
Where to place configuration files sources
What we've come up with is the following. We only place one config file under version control. It contains the settings of the...
Read more >
What order are config files loaded under linux when there are ...
What order are config files loaded under linux when there are multiple sources? ... I understand the main principle that local configuration files...
Read more >
Is there a way for one SSH config file to include another one?
From 7.3p1 and up, there is the Include keyword, which allows you to include configuration files. Include. Include the specified configuration file(s).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found