fix: DATABASE_URL missing in env does not produce validation error (#4409)
* fix: DATABASE_URL missing in env does not produce validation error * lint
This commit is contained in:
@@ -7,27 +7,28 @@ const isProduction = env.ENVIRONMENT === "production";
|
|||||||
const isSSLDisabled = env.PGSSLMODE === "disable";
|
const isSSLDisabled = env.PGSSLMODE === "disable";
|
||||||
const poolMax = env.DATABASE_CONNECTION_POOL_MAX ?? 5;
|
const poolMax = env.DATABASE_CONNECTION_POOL_MAX ?? 5;
|
||||||
const poolMin = env.DATABASE_CONNECTION_POOL_MIN ?? 0;
|
const poolMin = env.DATABASE_CONNECTION_POOL_MIN ?? 0;
|
||||||
|
const url =
|
||||||
|
env.DATABASE_CONNECTION_POOL_URL ||
|
||||||
|
env.DATABASE_URL ||
|
||||||
|
"postgres://localhost:5432/outline";
|
||||||
|
|
||||||
export const sequelize = new Sequelize(
|
export const sequelize = new Sequelize(url, {
|
||||||
env.DATABASE_URL ?? env.DATABASE_CONNECTION_POOL_URL ?? "",
|
logging: (msg) => Logger.debug("database", msg),
|
||||||
{
|
typeValidation: true,
|
||||||
logging: (msg) => Logger.debug("database", msg),
|
dialectOptions: {
|
||||||
typeValidation: true,
|
ssl:
|
||||||
dialectOptions: {
|
isProduction && !isSSLDisabled
|
||||||
ssl:
|
? {
|
||||||
isProduction && !isSSLDisabled
|
// Ref.: https://github.com/brianc/node-postgres/issues/2009
|
||||||
? {
|
rejectUnauthorized: false,
|
||||||
// Ref.: https://github.com/brianc/node-postgres/issues/2009
|
}
|
||||||
rejectUnauthorized: false,
|
: false,
|
||||||
}
|
},
|
||||||
: false,
|
models: Object.values(models),
|
||||||
},
|
pool: {
|
||||||
models: Object.values(models),
|
max: poolMax,
|
||||||
pool: {
|
min: poolMin,
|
||||||
max: poolMax,
|
acquire: 30000,
|
||||||
min: poolMin,
|
idle: 10000,
|
||||||
acquire: 30000,
|
},
|
||||||
idle: 10000,
|
});
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ export class Environment {
|
|||||||
* set or your users will be unable to login.
|
* set or your users will be unable to login.
|
||||||
*/
|
*/
|
||||||
@IsByteLength(32, 64)
|
@IsByteLength(32, 64)
|
||||||
public SECRET_KEY = `${process.env.SECRET_KEY}`;
|
public SECRET_KEY = process.env.SECRET_KEY ?? "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The secret that should be passed to the cron utility endpoint to enable
|
* The secret that should be passed to the cron utility endpoint to enable
|
||||||
* triggering of scheduled tasks.
|
* triggering of scheduled tasks.
|
||||||
*/
|
*/
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
public UTILS_SECRET = `${process.env.UTILS_SECRET}`;
|
public UTILS_SECRET = process.env.UTILS_SECRET ?? "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url of the database.
|
* The url of the database.
|
||||||
@@ -69,7 +69,7 @@ export class Environment {
|
|||||||
allow_underscores: true,
|
allow_underscores: true,
|
||||||
protocols: ["postgres", "postgresql"],
|
protocols: ["postgres", "postgresql"],
|
||||||
})
|
})
|
||||||
public DATABASE_URL = `${process.env.DATABASE_URL}`;
|
public DATABASE_URL = process.env.DATABASE_URL ?? "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url of the database pool.
|
* The url of the database pool.
|
||||||
@@ -125,7 +125,7 @@ export class Environment {
|
|||||||
*/
|
*/
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsUrl({ require_tld: false })
|
@IsUrl({ require_tld: false })
|
||||||
public URL = `${process.env.URL}`;
|
public URL = process.env.URL || "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If using a Cloudfront/Cloudflare distribution or similar it can be set below.
|
* If using a Cloudfront/Cloudflare distribution or similar it can be set below.
|
||||||
@@ -157,7 +157,7 @@ export class Environment {
|
|||||||
/**
|
/**
|
||||||
* Optional extra debugging. Comma separated
|
* Optional extra debugging. Comma separated
|
||||||
*/
|
*/
|
||||||
public DEBUG = `${process.env.DEBUG}`;
|
public DEBUG = process.env.DEBUG || "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How many processes should be spawned. As a reasonable rule divide your
|
* How many processes should be spawned. As a reasonable rule divide your
|
||||||
|
|||||||
Reference in New Issue
Block a user