+1

Managing access to various environments through one app code base.

jakelisby 7 years ago updated by ajones 7 years ago 5
Our application currently loads content from RSS Feeds and JSON calls from Wordpress where content is created. They use specific URLs that are currently hardcoded into our app. This works great while we're only looking at our sandbox environment, but now we're ready to move our application to production and I'd like the ability for our app to be smart enough to choose which environment it should pull content from.

I don't know if anyone has tackled this yet, but wanted to reach out before we got too deep.
Jake,

Help me understand your use case here. Are you suggesting that the same class or list would need to pivot from one datasource to another based on certain criteria?
Well, essentially, I'm looking to create 2 sets of API credentials, links and the like. One will represent Sandbox, one Production. I'd like there to be a single preference we would need to change in the code that would point the app to the correct set of information.

The more I'm thinking through this, the more I'm considering using a SQL database that has a preference pointing to it. My problem is preferences are only available in one wire at a time, so there needs to be some passing which adds to the fun of course... :)
Actually Jake, a [preferences:] tag will persist from one wire to another so you could use that to pass a different datasource address based on an if statement or something.
Dang it, early morning brain fart. Of course it does, we're currently using that... For some reason I was out of it.

So I guess my request would be to add the API key capabilities for Parse. If we were able to do that, it would save us from having to manage a config file at all. Can we put that feature request in? Or perhaps a capability like Github has where you can include/declare any public API and it will be accessible in your app?
My first thought would be to talk you out of the addition of PARSE credentials on the API Setting page for this usage. Here is why, if you depend on a RW live-app-update to push new Parse keys, if a used declines an update from the app, they won't be pushed to your production level services. I would take any need for the user to respond out of this workflow.

What would be easy to set up and for the team to manage would be to create a little datasource in the app that points to an external json file with a single name:vale pair.


<datasource name="bestof" source="URL" query="/app/status" providertype="json"/>


and the json file be something like:


{
"app": {
"status": [
{
"level": "sandbox"
}
]
}


when the app loads, fire that datasource and return the result. depending on the result, set up a couple if statements that set a [var:statusURL] to the url you want and then in any place in the app that references that URL, replace it was your [var:statusURL].

Hope that helps.