mirror of
https://github.com/outline/outline.git
synced 2026-01-07 11:40:08 -06:00
* chore: Centralize env parsing, defaults, deprecation * wip * test * test * tsc * docs, more validation * fix: Allow empty REDIS_URL (defaults to localhost) * test * fix: SLACK_MESSAGE_ACTIONS not bool * fix: Add SMTP port validation
34 lines
945 B
TypeScript
34 lines
945 B
TypeScript
import { Sequelize } from "sequelize-typescript";
|
|
import env from "@server/env";
|
|
import Logger from "../logging/logger";
|
|
import * as models from "../models";
|
|
|
|
const isProduction = env.ENVIRONMENT === "production";
|
|
const isSSLDisabled = env.PGSSLMODE === "disable";
|
|
const poolMax = env.DATABASE_CONNECTION_POOL_MAX ?? 5;
|
|
const poolMin = env.DATABASE_CONNECTION_POOL_MIN ?? 0;
|
|
|
|
export const sequelize = new Sequelize(
|
|
env.DATABASE_URL ?? env.DATABASE_CONNECTION_POOL_URL ?? "",
|
|
{
|
|
logging: (msg) => Logger.debug("database", msg),
|
|
typeValidation: true,
|
|
dialectOptions: {
|
|
ssl:
|
|
isProduction && !isSSLDisabled
|
|
? {
|
|
// Ref.: https://github.com/brianc/node-postgres/issues/2009
|
|
rejectUnauthorized: false,
|
|
}
|
|
: false,
|
|
},
|
|
models: Object.values(models),
|
|
pool: {
|
|
max: poolMax,
|
|
min: poolMin,
|
|
acquire: 30000,
|
|
idle: 10000,
|
|
},
|
|
}
|
|
);
|