Guard against missing ca certificate during builds
This commit is contained in:
+8
-4
@@ -4,12 +4,16 @@ import pg from 'pg';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import { PrismaClient } from '$lib/generated/prisma/client';
|
||||
|
||||
const ca_cert = process.env.DO_CA_CERTIFICATE ?? '';
|
||||
|
||||
const pool = new pg.Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
ssl: {
|
||||
rejectUnauthorized: true,
|
||||
ca: fs.readFileSync('/etc/ssl/certs/do-ca-certificate.crt').toString()
|
||||
}
|
||||
ssl: ca_cert
|
||||
? {
|
||||
rejectUnauthorized: true,
|
||||
ca: fs.readFileSync(ca_cert).toString()
|
||||
}
|
||||
: undefined
|
||||
});
|
||||
|
||||
const adapter = new PrismaPg(pool);
|
||||
|
||||
Reference in New Issue
Block a user