如何使用Nestjs配置处理每个模块的不同配置

发布于 2025-02-02 19:13:19 字数 377 浏览 3 评论 0原文

我想为每个模块具有不同的配置,例如指定的

这里能够实现这一目标,这是我面临的问题: https://github.com/nestjs/nestjs/config/config/issues/947

I want to have different config for each module like specified here

But I am not able to achieve this, here is the issue that I am facing:
https://github.com/nestjs/config/issues/947

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南汐寒笙箫 2025-02-09 19:13:19

我不完全理解您为什么需要这样的行为,也许有更多信息,我可以给您更详细的输入。但是,从您提供的信息来看,我建议将配置变量保留在全球范围内,并避免使用名称碰撞,这不仅是出于设计目的,而且还用于可读性。
如果您有很多配置变量,则可以始终将它们分为不同的JSON文件并将其从每个模块中加载,但以不同的方式命名它们。
让我知道这是否是您问题的可行解决方案。

I don't fully understand why you need such behaviour, and maybe with more information I could give you a more detailed input. However, from the information you provided, I would suggest to keep the configuration variables globally scoped and avoid name collisions, not only for design purposes but for readability also.
If you have a lot of configuration variables, you can always separate them into different JSON files and load them from each module, but naming them differently.
Let me know if this is a viable solution for your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文