To set up environment specific configs to be used with everyauth with Node.js, we return the config according to the NODE_ENV
environment variable.
For instance, we write
module.exports = () => {
switch (process.env.NODE_ENV) {
case "development":
return {
//...
};
case "production":
return {
//...
};
default:
return {
//...
};
}
};
in the config.js file to return the config according to the NODE_ENV
environment variable value.
Then we write
const Config = require("./config");
const conf = Config();
to require the config.js file and then call the imported Config
function to return the config for the environment in app.js.
And then we run
NODE_ENV=production node app.js
to set the NODE_ENV
environment variable value and run app.js.