Hello, all. I’m attempting to initialize `PrismaC...
# orm-help
m
Hello, all. I’m attempting to initialize
PrismaClient
in a new Nest.js application. All of my secrets are managed in AWS Secrets Manager, because I’d like to avoid having any sort of secret/.env files in my source code. I am able to instantiate an instance of
PrismaClient
programmatically, but the resulting client instance cannot be bound to my Prisma service in Nest.js. I’d like to bind that client to
this.client
in my
PrismaService
constructor, but, as you well know, constructors are synchronous and their declaration cannot be prefaced with
async
to make them asynchronous either. My thinking is that, if I instantiate a single instance of
PrismaClient
within my
PrismaService
, I should then be able to import
PrismaService
into my domain-specific service modules (e.g.,
cars.service.ts
,
bicycles.service.ts
, etc.) then reference those services with my resolvers (e.g.,
cars.resolvers.ts
). What I don’t want to do--though what would probably work--is instantiate an instance of
PrismaClient
when- and wherever I need to interact with a datasource. I’m aware that there are a few prescribed patterns for connecting to Prisma, but they all seem to involve environment variables or config files, whereas I’d like my own implementation to involve only the secrets I keep within AWS Secrets Manager and an instance of
PrismaClient
that I instantiate within a
PrismaService
. Hopefully all of that makes sense. -_-; Edit: I guess another thought that comes to mind is somehow accessing the environment variables stored within AWS Secrets Manager and . . . I don’t know . . . writing prescribing them to a container or something of the like whenever it is instantiated, though this sort of thing is admittedly beyond my depth and presumes that I am utilizing something like Docker.