mirror of
https://github.com/fosrl/pangolin.git
synced 2025-12-14 12:08:11 +00:00
Make postgres connection string also a ENV var
This commit is contained in:
@@ -7,9 +7,22 @@ function createDb() {
|
|||||||
const config = readConfigFile();
|
const config = readConfigFile();
|
||||||
|
|
||||||
if (!config.postgres) {
|
if (!config.postgres) {
|
||||||
throw new Error(
|
// check the environment variables for postgres config
|
||||||
"Postgres configuration is missing in the configuration file."
|
if (process.env.POSTGRES_CONNECTION_STRING) {
|
||||||
);
|
config.postgres = {
|
||||||
|
connection_string: process.env.POSTGRES_CONNECTION_STRING
|
||||||
|
};
|
||||||
|
if (process.env.POSTGRES_REPLICA_CONNECTION_STRINGS) {
|
||||||
|
const replicas = process.env.POSTGRES_REPLICA_CONNECTION_STRINGS.split(",").map((conn) => ({
|
||||||
|
connection_string: conn.trim()
|
||||||
|
}));
|
||||||
|
config.postgres.replicas = replicas;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
"Postgres configuration is missing in the configuration file."
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const connectionString = config.postgres?.connection_string;
|
const connectionString = config.postgres?.connection_string;
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export const configSchema = z
|
|||||||
}),
|
}),
|
||||||
postgres: z
|
postgres: z
|
||||||
.object({
|
.object({
|
||||||
connection_string: z.string(),
|
connection_string: z.string().optional(),
|
||||||
replicas: z
|
replicas: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
|
|||||||
Reference in New Issue
Block a user