MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / getClient

Function getClient

apps/webapp/app/db.server.ts:80–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78);
79
80function getClient() {
81 const { DATABASE_URL } = process.env;
82 invariant(typeof DATABASE_URL === "string", "DATABASE_URL env var not set");
83
84 const databaseUrl = extendQueryParams(DATABASE_URL, {
85 connection_limit: env.DATABASE_CONNECTION_LIMIT.toString(),
86 pool_timeout: env.DATABASE_POOL_TIMEOUT.toString(),
87 });
88
89 console.log(`🔌 setting up prisma client to ${redactUrlSecrets(databaseUrl)}`);
90
91 const client = new PrismaClient({
92 datasources: {
93 db: {
94 url: databaseUrl.href,
95 },
96 },
97 log: [
98 {
99 emit: "stdout",
100 level: "error",
101 },
102 {
103 emit: "stdout",
104 level: "info",
105 },
106 {
107 emit: "stdout",
108 level: "warn",
109 },
110 // {
111 // emit: "stdout",
112 // level: "query",
113 // },
114 // {
115 // emit: "event",
116 // level: "query",
117 // },
118 ],
119 });
120
121 // client.$on("query", (e) => {
122 // console.log(`Query tooks ${e.duration}ms`, {
123 // query: e.query,
124 // params: e.params,
125 // duration: e.duration,
126 // });
127 // });
128
129 // connect eagerly
130 client.$connect();
131
132 console.log(`🔌 prisma client connected`);
133
134 return client;
135}
136
137function getReplicaClient() {

Callers

nothing calls this directly

Calls 4

extendQueryParamsFunction · 0.85
redactUrlSecretsFunction · 0.85
toStringMethod · 0.80
logMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…