I'm trying to build a DB utility class (app/utils/db.server.js) using prisma, following the pattern that we've all seen in the various tutorials. I understand that in Cloudflare Pages, prisma's client cannot access the DATABASE_URL env var the way it would in Node, so you have to pass it in (ie, new PrismaClient( { datasources: { db: { url: "prisma://blah" } })
It's not good practice to hard-code database urls as strings. So I want to use cloudflare env vars, but those are only accessible from the context which is passed to loaders/actions/etc. So there doesn't seem to be a way, other than threading it through from the loader. so every time I want to use the db it's got to be "db(context.cloudflare.env.DATABASE_URL).findMany(blah)" ?
Is this right? Is there some other way I should be accessing vars from modular/util/helper code?