DEV Community

Discussion on: I am the author of Elm in Action. Ask Me Anything!

Collapse
 
saucewaffle profile image
SauceWaffle

Since Elm seems to expose everything to the user, do you have a preferred method of keeping sensitive information from being presented? i.e. hiding API Keys

Have accomplished this with having a simple Python API set up parallel to the Elm app to feed Elm objects, but this seems overly complicated.

Collapse
 
rtfeldman profile image
Richard Feldman

Yeah, for API keys I recommend creating something like Secrets.elm and adding that file to .gitignore. Locally, developers have to create that file as part of setting up their systems, and then you have your build process swap in a different file (containing different constants) for production builds.

This way you can easily access the secrets from any module, and if you forget to set them up locally, you'll get a compile error because the module won't be found!

I do this with the Frontend Masters workshop for GitHub API access tokens; you can check out the repo here github.com/rtfeldman/elm-workshop