Closed amv closed 5 years ago
If something like with the log+load is implemented, having the option to dump the contents of a box in the free service in a format that can be ingested by a local version might be a useful addition too. Then one could initially just develop against the free service, but set up a local/offline demo when needed.
This would also act as kind of a backup system in case your service experiences problems at any point.
Getting CORS to work with a local version can be a major PITA in some situations though. Usually not a problem for local dev envs, but if you initially develop through a TLS secured remote host using the free service, getting the remotely hosted page to contact something on localhost without a valid TLS cert can cause a lot of gray hairs :(
Great idea @amv !
@amv currently there is no plan to provide an alternative db store for local envs.
Addressing at least some of the requests with https://github.com/vasanthv/jsonbox/pull/24
@harlev have addressed this as part of https://github.com/vasanthv/jsonbox/commit/ff0758e3a35c0fe4926652ae57822bfca2272ea1
A local version would remove a lot of demo effects in hackathons when the wifi is laggy, and would also be faster due to no network latencies.
The easy & dirty way would be to create a single container that runs both a mongo server and the node process, but this would make the container very heavy and problems hard to debug.
An alternative route would be to abstract the db layer and allow using something like sqlite3.
And yet another option would be to just provide an in-memory db option for local use. To make this a bit more usable, one might consider adding super simple to understand persistence by making it possible to enable a stdout output in the style of a log that can be piped back to a fresh server to restore the old state.
Example after providing a simple Dockerfile in the repo:
The log could look something like this, just outputting a line for each operation:
I personally would prefers the last one as it is by far the simplest to operate and allows storing different states of the db simply by copying the file, but understand if you don't want to add code for doing in-memory db alternative with custom query implementations.
Let me know if any pull requests would be welcome, especially for the last option :)