Skip to content
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

Dependency Injection in backend #46

Open
dnys1 opened this issue Feb 13, 2024 · 0 comments
Open

Dependency Injection in backend #46

dnys1 opened this issue Feb 13, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dnys1
Copy link
Member

dnys1 commented Feb 13, 2024

Related to #40. Based off a Discord thread.

It is common to have a set of service providers shared between functions on the backend (for example, Sentry). Currently, in order to use the same provider in multiple functions, users are required to initialize the provider at the start of each call, e.g.

// functions/my_api.dart

Future<void> _initializeSentry({ required String dsn }) async {
  // initialize sentry provider
}

Future<void> tracedFunction({
  // params...
  @Env.sentryDsn required String sentryDsn,
}) async {
  await _initializeSentry(dsn: dsn);
}

It would be nice if there was a way to consolidate this logic even more so functions can either move this logic to a middleware or have a pre-initialized service provider injected into the function like env variables are currently injected.

@dnys1 dnys1 added the enhancement New feature or request label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant