Node.js: How to setup different variables for prod and staging

后端 未结 5 1097
说谎
说谎 2021-02-04 12:05

I\'m using Express and I need to use different credentials for each server (staging and production).

I could setup the variables in the server.coffee file but then I\'d

5条回答
  •  甜味超标
    2021-02-04 12:54

    I have an app which uses three different methods of declaring config variables (uris, api keys, credentials, etc.) depending upon the environment (production = environment variables; staging = command line args; local = config files.) I wrote a little "config" module to handle merging all of these options into one object that I can use in my app and uploaded it as a gist: https://gist.github.com/1616583

    It might not be the best implementation, but it's been working pretty well so far :).

提交回复
热议问题