Skip to content

Commit

Permalink
support postgres CA
Browse files Browse the repository at this point in the history
  • Loading branch information
neongreen committed Aug 15, 2024
1 parent aa391aa commit 9e9733c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ PGDATABASE=db_dev
PGHOST=localhost
PGPORT=3999

# For docker compose
# For docker compose and pgboss
POSTGRES_PASSWORD=password
POSTGRES_USER=user
POSTGRES_DB=db_dev
POSTGRES_HOST=localhost
POSTGRES_PORT=3999

# For prisma and pg-boss
# For prisma
DATABASE_URL="postgresql://user:password@localhost:3999/db_dev"

# Next-auth
Expand Down
12 changes: 10 additions & 2 deletions lib/job-queue.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import PgBoss from 'pg-boss'
import { beeminderSyncCard, BeeminderSyncCardPayload } from './jobs/beeminder-sync-card'
import { error } from 'console'

type Job = {
tag: 'beeminder-sync-card'
payload: BeeminderSyncCardPayload
}

const boss = new PgBoss(process.env.DATABASE_URL!)
const boss = new PgBoss({
user: process.env.POSTGRES_USER,
host: process.env.POSTGRES_HOST,
port: parseInt(process.env.POSTGRES_PORT!),
database: process.env.POSTGRES_DB,
password: process.env.POSTGRES_PASSWORD,
...('POSTGRES_CA_CERT' in process.env
? { ssl: { rejectUnauthorized: true, ca: process.env.POSTGRES_CA_CERT } }
: {}),
})

export async function addJob<T extends Job['tag']>(
tag: T,
Expand Down

0 comments on commit 9e9733c

Please sign in to comment.