add support for PostgreSQL (and other databases)

* renamed the 'mysql' config.yaml key to 'database'
* added database.client which still defaults to 'mysql'
This commit is contained in:
secretspecter 2023-12-14 22:11:17 -07:00
parent 227244e2d0
commit 0b806cec92
2 changed files with 10 additions and 9 deletions

View file

@ -11,7 +11,8 @@ import { CaptchaConfig } from './configuration/captchaconfig';
const LOGGER = require('@calzoneman/jsli')('config'); const LOGGER = require('@calzoneman/jsli')('config');
var defaults = { var defaults = {
mysql: { database: {
client: "mysql",
server: "localhost", server: "localhost",
port: 3306, port: 3306,
database: "cytube3", database: "cytube3",

View file

@ -30,19 +30,19 @@ class Database {
constructor(knexConfig = null) { constructor(knexConfig = null) {
if (knexConfig === null) { if (knexConfig === null) {
knexConfig = { knexConfig = {
client: 'mysql', client: 'database',
connection: { connection: {
host: Config.get('mysql.server'), host: Config.get('database.server'),
port: Config.get('mysql.port'), port: Config.get('database.port'),
user: Config.get('mysql.user'), user: Config.get('database.user'),
password: Config.get('mysql.password'), password: Config.get('database.password'),
database: Config.get('mysql.database'), database: Config.get('database.database'),
multipleStatements: true, // Legacy thing multipleStatements: true, // Legacy thing
charset: 'utf8mb4' charset: 'utf8mb4'
}, },
pool: { pool: {
min: Config.get('mysql.pool-size'), min: Config.get('database.pool-size'),
max: Config.get('mysql.pool-size') max: Config.get('database.pool-size')
}, },
debug: !!process.env.KNEX_DEBUG debug: !!process.env.KNEX_DEBUG
}; };