File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 1
- import dotenv from "dotenv" ;
2
1
import { drizzle } from "drizzle-orm/postgres-js" ;
3
2
import postgres from "postgres" ;
4
- dotenv . config ( ) ;
3
+ import { EnvConfig , envConfigSchema , envSchemaAjv } from "../envConfigSchema" ;
4
+ import envSchema from "env-schema" ;
5
5
6
- const DATABASE_URL = `postgres://${ process . env . API_POSTGRES_USER } :${ process . env . API_POSTGRES_PASSWORD } @${ process . env . API_POSTGRES_HOST } :${ process . env . API_POSTGRES_PORT } /${ process . env . API_POSTGRES_DATABASE } ` ;
6
+ const envConfig = envSchema < EnvConfig > ( {
7
+ ajv : envSchemaAjv ,
8
+ dotenv : true ,
9
+ schema : envConfigSchema ,
10
+ } ) ;
11
+
12
+ const DATABASE_URL = `postgres://${ envConfig . API_POSTGRES_USER } :${ envConfig . API_POSTGRES_PASSWORD } @${ envConfig . API_POSTGRES_HOST } :${ envConfig . API_POSTGRES_PORT } /${ envConfig . API_POSTGRES_DATABASE } ` ;
13
+ console . log ( 'DATABASE_URL' , DATABASE_URL ) ;
7
14
8
15
let client : postgres . Sql ;
9
16
12
19
prepare : false ,
13
20
max : 10 ,
14
21
idle_timeout : 30 ,
15
- ssl : process . env . API_POSTGRES_SSL_MODE === " true" ? "allow" : undefined ,
16
- ...( process . env . NODE_ENV === "development" && {
22
+ ssl : envConfig . API_POSTGRES_SSL_MODE === true ? "allow" : undefined ,
23
+ ...( envConfig . NODE_ENV === "development" && {
17
24
debug : ( connection , query , params ) => {
18
25
console . log ( "Running SQL Query:" , query ) ;
19
26
console . log ( "Query Parameters:" , params ) ;
You can’t perform that action at this time.
0 commit comments