final config changes
This commit is contained in:
parent
718ace05b0
commit
19f05a2a69
7 changed files with 311 additions and 51 deletions
54
libs/config/src/postgres.ts
Normal file
54
libs/config/src/postgres.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* PostgreSQL configuration using envalid
|
||||
*/
|
||||
import { cleanEnv, str, port, bool, num } from 'envalid';
|
||||
|
||||
/**
|
||||
* PostgreSQL configuration with validation and defaults
|
||||
*/
|
||||
export const postgresConfig = cleanEnv(process.env, {
|
||||
// PostgreSQL Connection Settings
|
||||
POSTGRES_HOST: str({ default: 'localhost', desc: 'PostgreSQL host' }),
|
||||
POSTGRES_PORT: port({ default: 5432, desc: 'PostgreSQL port' }),
|
||||
POSTGRES_DATABASE: str({ default: 'stockbot', desc: 'PostgreSQL database name' }),
|
||||
POSTGRES_USERNAME: str({ default: 'stockbot', desc: 'PostgreSQL username' }),
|
||||
POSTGRES_PASSWORD: str({ default: '', desc: 'PostgreSQL password' }),
|
||||
|
||||
// Connection Pool Settings
|
||||
POSTGRES_POOL_MIN: num({ default: 2, desc: 'Minimum pool connections' }),
|
||||
POSTGRES_POOL_MAX: num({ default: 10, desc: 'Maximum pool connections' }),
|
||||
POSTGRES_POOL_IDLE_TIMEOUT: num({ default: 30000, desc: 'Pool idle timeout in ms' }),
|
||||
|
||||
// SSL Configuration
|
||||
POSTGRES_SSL: bool({ default: false, desc: 'Enable SSL for PostgreSQL connection' }),
|
||||
POSTGRES_SSL_REJECT_UNAUTHORIZED: bool({ default: true, desc: 'Reject unauthorized SSL certificates' }),
|
||||
|
||||
// Additional Settings
|
||||
POSTGRES_QUERY_TIMEOUT: num({ default: 30000, desc: 'Query timeout in ms' }),
|
||||
POSTGRES_CONNECTION_TIMEOUT: num({ default: 5000, desc: 'Connection timeout in ms' }),
|
||||
POSTGRES_STATEMENT_TIMEOUT: num({ default: 30000, desc: 'Statement timeout in ms' }),
|
||||
POSTGRES_LOCK_TIMEOUT: num({ default: 10000, desc: 'Lock timeout in ms' }),
|
||||
POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT: num({ default: 60000, desc: 'Idle in transaction timeout in ms' }),
|
||||
});
|
||||
|
||||
// Export typed configuration object
|
||||
export type PostgresConfig = typeof postgresConfig;
|
||||
|
||||
// Export individual config values for convenience
|
||||
export const {
|
||||
POSTGRES_HOST,
|
||||
POSTGRES_PORT,
|
||||
POSTGRES_DATABASE,
|
||||
POSTGRES_USERNAME,
|
||||
POSTGRES_PASSWORD,
|
||||
POSTGRES_POOL_MIN,
|
||||
POSTGRES_POOL_MAX,
|
||||
POSTGRES_POOL_IDLE_TIMEOUT,
|
||||
POSTGRES_SSL,
|
||||
POSTGRES_SSL_REJECT_UNAUTHORIZED,
|
||||
POSTGRES_QUERY_TIMEOUT,
|
||||
POSTGRES_CONNECTION_TIMEOUT,
|
||||
POSTGRES_STATEMENT_TIMEOUT,
|
||||
POSTGRES_LOCK_TIMEOUT,
|
||||
POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT,
|
||||
} = postgresConfig;
|
||||
Loading…
Add table
Add a link
Reference in a new issue