generated from alphane/template
This commit is contained in:
@@ -39,6 +39,7 @@ export const DB_PASSWORD = process.env.DB_PASSWORD || ""
|
|||||||
export const DB_DATABASE = process.env.DB_DATABASE || ""
|
export const DB_DATABASE = process.env.DB_DATABASE || ""
|
||||||
export const DB_PORT = parseInt(process.env.DB_PORT || "1433")
|
export const DB_PORT = parseInt(process.env.DB_PORT || "1433")
|
||||||
export const DB_TRUST_SERVER_CERTIFICATE = process.env.DB_TRUST_SERVER_CERTIFICATE === "true"
|
export const DB_TRUST_SERVER_CERTIFICATE = process.env.DB_TRUST_SERVER_CERTIFICATE === "true"
|
||||||
|
export const DB_SSL = process.env.DB_SSL === "true"
|
||||||
|
|
||||||
export const REDIS_CONNECTION_URL = process.env.REDIS_CONNECTION_URL || ""
|
export const REDIS_CONNECTION_URL = process.env.REDIS_CONNECTION_URL || ""
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import {
|
|||||||
DB_HOST,
|
DB_HOST,
|
||||||
DB_PASSWORD,
|
DB_PASSWORD,
|
||||||
DB_PORT,
|
DB_PORT,
|
||||||
|
DB_SSL,
|
||||||
DB_USERNAME,
|
DB_USERNAME,
|
||||||
NODE_ENV,
|
|
||||||
SEQUELIZE_LOGGING,
|
SEQUELIZE_LOGGING,
|
||||||
} from "@/config"
|
} from "@/config"
|
||||||
import compactSql from "@/utils/compact-sql"
|
import compactSql from "@/utils/compact-sql"
|
||||||
@@ -31,7 +31,7 @@ export const SEQUELIZE_CONFIG: Options<PostgresDialect> = {
|
|||||||
password: DB_PASSWORD,
|
password: DB_PASSWORD,
|
||||||
host: DB_HOST,
|
host: DB_HOST,
|
||||||
port: DB_PORT,
|
port: DB_PORT,
|
||||||
ssl: NODE_ENV !== "production" ? false : { rejectUnauthorized: false },
|
ssl: DB_SSL ? { rejectUnauthorized: false } : false,
|
||||||
schema: "public", // default - explicit for clarity
|
schema: "public", // default - explicit for clarity
|
||||||
logging: SEQUELIZE_LOGGING ? sqlLogger : false,
|
logging: SEQUELIZE_LOGGING ? sqlLogger : false,
|
||||||
pool: {
|
pool: {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import path from "path"
|
|||||||
import knex, { Knex } from "knex"
|
import knex, { Knex } from "knex"
|
||||||
import { isEmpty, isNil, merge } from "lodash"
|
import { isEmpty, isNil, merge } from "lodash"
|
||||||
|
|
||||||
import { DB_DATABASE, DB_HOST, DB_PASSWORD, DB_PORT, DB_USERNAME, NODE_ENV } from "@/config"
|
import { DB_DATABASE, DB_HOST, DB_PASSWORD, DB_PORT, DB_SSL, DB_USERNAME, NODE_ENV } from "@/config"
|
||||||
|
|
||||||
if (isEmpty(DB_DATABASE)) throw new Error("database name is unset.")
|
if (isEmpty(DB_DATABASE)) throw new Error("database name is unset.")
|
||||||
if (isEmpty(DB_USERNAME)) throw new Error("database username is unset.")
|
if (isEmpty(DB_USERNAME)) throw new Error("database username is unset.")
|
||||||
@@ -21,17 +21,7 @@ export function buildKnexConfig(options?: Knex.Config): Knex.Config {
|
|||||||
password: DB_PASSWORD,
|
password: DB_PASSWORD,
|
||||||
database: DB_DATABASE,
|
database: DB_DATABASE,
|
||||||
port: DB_PORT,
|
port: DB_PORT,
|
||||||
ssl:
|
ssl: DB_SSL ? { rejectUnauthorized: false } : false,
|
||||||
NODE_ENV !== "production"
|
|
||||||
? false
|
|
||||||
: {
|
|
||||||
require: true, // Enforce SSL
|
|
||||||
rejectUnauthorized: false, // Disable certificate verification (common for Azure)
|
|
||||||
},
|
|
||||||
/* options: {
|
|
||||||
encrypt: true,
|
|
||||||
trustServerCertificate: DB_TRUST_SERVER_CERTIFICATE,
|
|
||||||
}, */
|
|
||||||
},
|
},
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: path.resolve(__dirname, "./migrations"),
|
directory: path.resolve(__dirname, "./migrations"),
|
||||||
|
|||||||
Reference in New Issue
Block a user