taijinlee / eulermarks

2 stars 2 forks source link

Pass server config to client side #10

Closed taijinlee closed 12 years ago

taijinlee commented 12 years ago

Two ways of approaching this that I can think of.

1) Have app/server.js generate a static config file in /web/js/ and the client would just pick it up as a statically served file.

2) Have an api exposed for getting the current config -- /api/config or something like that

I think I prefer 2, but I can be swayed that 1 is better if you can think of any reasons.

In terms of all the pieces necessary, I'm currently using node-config for config files. I think we might want to abstract the config more, into a small wrapper so that we can use makeHidden only in our wrapper. http://lorenwest.github.com/node-config/latest/Config.html

Example, drop this in app/server.js

config.makeHidden(config.githubOauth, 'secret');
console.log(JSON.stringify(config.githubOauth.secret));
console.log(JSON.stringify(config));
taijinlee commented 12 years ago

I realized that by exposing an API we don't need to do this makeHidden thing, just have to make force specification on which fields are exposed. Woot.