【问题标题】:Configuration file best practices node.js配置文件最佳实践 node.js
【发布时间】:2017-04-27 16:48:29
【问题描述】:

我正在开发一个 node.js 项目,其中很多模块都需要配置文件。目前我需要每个模块中的配置文件,这是最好的方法吗?我曾考虑将配置设置为全局,但它看起来“脏”。 这是目前的文件(暂时不要介意结构,它仍在开发中)

{
  "root" :  "undefined",
  "jwtAuthentication": {
    "appSecret": "XXXXXXXXXXXXX",
    "expiration": "48h"
  },
  "authorization": {
    "guestActions": [ "signup" ]
  }
}

【问题讨论】:

  • 向我们展示配置文件。
  • @JoeLloyd 编辑了帖子

标签: javascript node.js optimization config


【解决方案1】:

这是我设置项目结构的方式:

  module1
   --controllers
   --services
   --middleware
   --config
  module2
   --controllers
   --services
   --middleware
   --config
  shared
   --config
   --services

在 shared/config 中,我设置了全局配置,并在 module{i} 配置中设置了特定于该模块的配置。

【讨论】:

    猜你喜欢
    • 2013-02-21
    • 1970-01-01
    • 2012-03-09
    • 2017-09-06
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 2016-06-05
    • 1970-01-01
    相关资源
    最近更新 更多