Database/environment injection when creating Better Auth instance on the server
New user here 🙂 It's pretty common to use dependency injection to instantiate database connection. But according to the docs we must use better-auth like this: 
Make sure to export the auth instance with the variable name auth or as a default export.This means we can't create the auth instance inside a function, it musy be at top-level. But we need to pass the database while creating the Better Auth instance, and we use a function to create it for dependency injection purposes. Anything we can do here? We were surprised that we couldn't find anything about this on Github.
1 Reply
You can create one inside a function, but if you rely on the cli to do migration or schema generation, it wouldn't work. That said, you can call the CLI commands programtically by import 
getMigrations from "better-auth/db"