Skip to content

Commit 9afbc89

Browse files
committed
fix: tidy up ssl stuff some more
1 parent 9d7c9c5 commit 9afbc89

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/lib/PostgresMetaTriggers.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,12 @@ export default class PostgresMetaTriggers {
167167
const enabledMode = enabled_mode.toUpperCase()
168168
const { name: currentName, schema: schema, table: table } = triggerRecord!
169169
const qualifiedTableName = `${ident(schema)}.${ident(table)}`
170-
const updateNameSql = newName && newName !== currentName
171-
? `ALTER TRIGGER ${ident(currentName)} ON ${qualifiedTableName} RENAME TO ${ident(newName)};`
172-
: ''
170+
const updateNameSql =
171+
newName && newName !== currentName
172+
? `ALTER TRIGGER ${ident(currentName)} ON ${qualifiedTableName} RENAME TO ${ident(
173+
newName
174+
)};`
175+
: ''
173176

174177
if (['ORIGIN', 'REPLICA', 'ALWAYS', 'DISABLED'].includes(enabledMode)) {
175178
if (enabledMode === 'DISABLED') {

src/lib/db.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ import { PostgresMetaResult } from './types'
33

44
types.setTypeParser(20, parseInt)
55

6-
export const init: (
7-
config: PoolConfig
8-
) => {
6+
export const init: (config: PoolConfig) => {
97
query: (sql: string) => Promise<PostgresMetaResult<any>>
108
end: () => Promise<void>
119
} = (config) => {
12-
// XXX: Race condition could happen here: one async task may be doing
10+
// NOTE: Race condition could happen here: one async task may be doing
1311
// `pool.end()` which invalidates the pool and subsequently all existing
1412
// handles to `query`. Normally you might only deal with one DB so you don't
1513
// need to call `pool.end()`, but since the server needs this, we make a
1614
// compromise: if we run `query` after `pool.end()` is called (i.e. pool is
17-
// `null`), we temporarily create a pool and close is right after.
15+
// `null`), we temporarily create a pool and close it right after.
1816
let pool: Pool | null = new Pool(config)
1917
return {
2018
async query(sql) {

src/server/constants.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ const PG_META_DB_USER = process.env.PG_META_DB_USER || 'postgres'
77
const PG_META_DB_PORT = Number(process.env.PG_META_DB_PORT) || 5432
88
const PG_META_DB_PASSWORD = process.env.PG_META_DB_PASSWORD || 'postgres'
99

10-
export const PG_CONNECTION = `postgres://${PG_META_DB_USER}:${PG_META_DB_PASSWORD}@${PG_META_DB_HOST}:${PG_META_DB_PORT}/${PG_META_DB_NAME}`
10+
export const PG_CONNECTION = `postgres://${PG_META_DB_USER}:${PG_META_DB_PASSWORD}@${PG_META_DB_HOST}:${PG_META_DB_PORT}/${PG_META_DB_NAME}?sslmode=disable`
1111

1212
export const PG_META_EXPORT_DOCS = process.env.PG_META_EXPORT_DOCS === 'true' || false
1313

14-
export const DEFAULT_POOL_CONFIG =
15-
process.env.NODE_ENV === 'development'
16-
? { max: 1, ssl: false }
17-
: { max: 1, ssl: { rejectUnauthorized: false } }
14+
export const DEFAULT_POOL_CONFIG = { max: 1 }

0 commit comments

Comments
 (0)