celest-dev/celest

Allow the code to specify/check if Celest is running locally or in the cloud (and where in the cloud).

marcglasberg opened this issue ยท 2 comments

When you init the app:

celest.init(env: CelestEnvironment.local);
celest.init(env: CelestEnvironment.staging);
celest.init(env: CelestEnvironment.prod);

Where CelestEnvironment is autogenerated with the client as an enum.

Then, I can access it from BOTH the frontend and the backend code, like this: celest.env

This has a few uses:

  • I can show this info in the app UI, just like the "debug banner" Flutter shows.
  • I can simulate third-party services, when I'm running local.
  • I can use staging versions of third-party services, when I'm running staging.
  • I can run the real third-party services, when I'm running prod.
enum CelestEnvironment {
  local, staging, prod;

  bool get isLocal => this == CelestEnvironment.local;
  bool get isCloud => this == CelestEnvironment.staging || this == CelestEnvironment.prod;
}

๐Ÿ‘‰ Extra points if I can later run celest.init() again to plug another environment while the app is running.

dnys1 commented

Love this! We're going to prioritize this for the 0.2.0 release.

This has been fixed in 0.2.0 ๐Ÿš€