(dbUrl: string)
| 26 | }); |
| 27 | |
| 28 | export const getPool = (dbUrl: string) => { |
| 29 | // WARNING: if you start getting errors that the certificate is expired or not |
| 30 | // valid, download the latest certificate from AWS and replace the one in the |
| 31 | // codebase! It expires in August 2024. TODO: automatically the latest version |
| 32 | // into the Docker image at build time. |
| 33 | // https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html#UsingWithRDS.SSL.RegionCertificates |
| 34 | const ca = dbUrl?.includes("us-west-2.rds.amazonaws.com") |
| 35 | ? readFileSync("./prisma/us-west-2-bundle.pem").toString() |
| 36 | : undefined; |
| 37 | |
| 38 | return new Pool({ |
| 39 | connectionString: dbUrl, |
| 40 | ssl: ca ? { rejectUnauthorized: false, ca } : undefined, |
| 41 | max: env.PG_MAX_POOL_SIZE, |
| 42 | }); |
| 43 | }; |
| 44 | |
| 45 | export const pgPool = getPool(env.DATABASE_URL); |
| 46 |
no outgoing calls
no test coverage detected