Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres Secure Connection Support #1117

Merged
merged 5 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
POSTGRES_HOST=127.0.0.1
POSTGRES_SSL=
HMAC_SECRET_ADMIN=xxxxxxx
NSQD_HTTP_PORT=4151
SHLVL=1
Expand Down
4 changes: 3 additions & 1 deletion src/_db/commands/up/pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export const handler = async (argv) => {
try {
const postgrator = (await import("postgrator")).default;
logger.child({ up: "pg", schemaPath: argv.schemaPath }).info("beginning handler");
const cs = `tcp://${argv.postgresUser}:${argv.postgresPassword}@${argv.postgresHost}:${argv.postgresPort}/${argv.postgresDatabase}`;
const cs = `tcp://${argv.postgresUser}:${argv.postgresPassword}@${argv.postgresHost}:${
argv.postgresPort
}/${argv.postgresDatabase}${argv.postgresSsl ? "?sslmode=require" : ""}`;
const client = new pg.Client(cs);
// Establish a database connection
await client.connect();
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
EXPORT_PAGE_SIZE_INTERNAL: process.env.EXPORT_PAGE_SIZE_INTERNAL || env.EXPORT_PAGE_SIZE_INTERNAL || 10000,
POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD || env.POSTGRES_PASSWORD,
POSTGRES_POOL_SIZE: process.env.POSTGRES_POOL_SIZE || env.POSTGRES_POOL_SIZE || 20,
POSTGRES_SSL: process.env.POSTGRES_SSL || env.POSTGRES_SSL,
HMAC_SECRET_VIEWER: process.env.HMAC_SECRET_VIEWER || env.HMAC_SECRET_VIEWER,
POSTGRES_PORT: process.env.POSTGRES_PORT || env.POSTGRES_PORT,
API_BASE_URL_PATH: process.env.API_BASE_URL_PATH || env.API_BASE_URL_PATH,
Expand Down
1 change: 1 addition & 0 deletions src/persistence/pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function getPgPool(): pg.Pool {
host: config.POSTGRES_HOST,
port: Number(config.POSTGRES_PORT),
max: Number(config.POSTGRES_POOL_SIZE) || 20,
ssl: config.POSTGRES_SSL || false,
idleTimeoutMillis: Number(config.PUBLISHER_CREATE_EVENT_TIMEOUT) || 2000, // how long a client is allowed to remain idle before being closed
});

Expand Down
Loading