hoodiehq-archive / hoodie-plugin-appconfig

⛔ deprecated
Apache License 2.0
1 stars 1 forks source link

Access from hoodie-client? #8

Open girvo opened 8 years ago

girvo commented 8 years ago

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 in hoodieAdmin?

gr2m commented 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

girvo commented 8 years ago

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 :)

gr2m commented 8 years ago

Thanks for the input @girvo, that is very useful! We’ll get back to the discussion on how to share config soon :)