Open girvo opened 8 years ago
Hey @girvo, that’s no silly question at all :)
We are currently thinking about how to best share config between server & client in the new Hoodie. We have the new Hoodie client which accepts options, and that could be pretty much anything.
For example, we could add a config.hoodie
field to the package.json, which could either be an object with the settings, or a path string to where the config can be found. But we are not yet sure at this point how to make clear what options get passed to the client, and what options are sensitive and for backend only.
Does that all make sense to you? If not I could add code examples. Would love to hear your thoughts on this
That makes perfect sense to me, I recently built a "universal" Javascript app for Expedia that had the exact same "context" issue for config. We tackled it by making the shared config explicit; by default every config option had a defined context, be it server or client, and sharing between them was a separate object. While that goes against the "universal" ethos and somewhat against Hoodie's "treat it like there is no backend" aim (which I think is brilliant), but when dealing with secrets and other important config options, we couldn't see a nice way to solve it.
Environment variables are also extremely useful, and easy to expose via envify
with browserify
when compiling the hoodie.js
client-side file; whether this is an optimal solution for you is up for debate however, as its yet another tool that non-developers will need to care about if it breaks :)
Thanks for the input @girvo, that is very useful! We’ll get back to the discussion on how to share config soon :)
This may seem like a silly question, but is it possible to access
appName
from the client-side, ie. in the actual app, not just inhoodieAdmin
?