-
Notifications
You must be signed in to change notification settings - Fork 11
Allow Celest environment in the backend #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Good catch! Let me think about the best way to handle this. |
Thinking about this some more, I believe there will always need to be a split between the client functionality and the server functionality. Having both available in the same interface will introduce too many footguns. What would you think about a |
Yes, you are right. In final celest = Celest();
final celestBackend = CelestBackend(); Only problem is, since it's not possible to make |
This has been fixed in v1! Celest will now generate a For example, when using Celest Data, you'll have a generated global that looks like this in your backend now: /// The interface to your Celest backend.
///
/// Similar to the `celest` global in the frontend, this
/// provides access to the backend environment and services
/// configured for your project.
const CelestCloud celest = CelestCloud._();
/// The interface to your Celest backend.
///
/// Similar to the `Celest` class in the frontend, this class
/// provides access to the backend environment and services
/// configured for your project.
class CelestCloud {
const CelestCloud._();
/// The current environment of the Celest service.
///
/// This is determined by the `CELEST_ENVIRONMENT` variable
/// which is set for you by the deployment environment.
CelestEnvironment get currentEnvironment =>
(variables.currentEnvironment as CelestEnvironment);
/// The variables of the Celest service.
///
/// This class provides access to the values configured for the
/// [currentEnvironment].
CelestVariables get variables => const CelestVariables();
/// The data services for the Celest backend.
///
/// This class provides access to the databases that are configured
/// for the [currentEnvironment].
CelestData get data => const CelestData();
} |
Fixes: #151 Fixes: https://celest.sentry.io/issues/5499486302/events/276cbd980f4a4a96a42b755ac8ccce78/ Fixes: https://celest.sentry.io/issues/5499486389/events/02e585e782f148e1bdf90fd88d321760/ - Adds the notion of feature flags and performs code-generation on that basis. - Adds tests that confirm support of the `supabase` package. Remaining TODOs: This issue arose because `supabase` depends on `websocket_channel: ^2` while the latest version of the runtime requires `websocket_channel: ^3`. Had the breaking change been released as a breaking version (e.g. 0.5.0), that would have caught the error sooner, e.g. `pub add` would display a version conflict, but it would still prevent users from adding supabase to their backend. There are no great answers to this except dramatically limiting the number of dependencies that `celest` uses. To do this, though, we'll need to have separate packages for the backend definition components and the generated client. Further, we'll need to generate a separate Dart/Flutter package for the generated client so that there is no overlap between the backend dependencies and the frontend dependencies. This is a good initiative regardless, and will unblock other issues such as #47. This work will be scoped for 0.5.0.
In a cloud function, if I check
celest.currentEnvironment
it throws me an error:However, it's very useful to know, in the backend code, if it's running locally or not. For example, suppose an
admin
function that should only work locally (and staging) but not in production. This function can be used to set up the database to some initial state for testing purposes:Since the
celest
object is visible from the function code, I think it should have this information (and other information, like the cookies #40 maybe). But if you try to accesscelest.functions
from inside a function it should fail with an appropriate error (and notCelest has not been initialized.
anyway).The text was updated successfully, but these errors were encountered: