For the local development version of my Phoenix app, I would like to import some secret key data from a gitignore/
directory into config.exs
. However, there are two things that I am not sure of:
The data that I want to import is just string data - API key, secret key - do I need to define a module, or is there a simpler way to export string data?
What is the appropriate import statement to use in
config.exs
, given the following file structure:MyApp/ | - config/ | | | - config.exs | - gitignore/ | - api_key.exs - api_secret.exs
I'm familiar with how to accomplish this in Node, but I'm not sure about how to handle this in Phoenix.
To illustrate what I'd like to achieve, an example from one of my Node apps would look like:
index.js
const APISecret = process.env.API_SECRET || require('./gitignore/api_secret.js')
const APIKey = process.env.API_KEY || require('./gitignore/api_key.js')
where the required files look like
module.exports = 'RANDOM_KEY_HERE'
How should the data-to-be-ignored be formatted, and what is the appropriate way to access that data in config.exs
?