Compare commits

...

3 commits

Author SHA1 Message Date
secretspecter db6253cd04 Blocked by FIXME 2024-01-04 19:54:13 -07:00
secretspecter 4846b22cd1 fix format and use database.client 2023-12-14 23:06:26 -07:00
secretspecter 0b806cec92 add support for PostgreSQL (and other databases)
* renamed the 'mysql' config.yaml key to 'database'
* added database.client which still defaults to 'mysql'
2023-12-14 22:11:17 -07:00
5 changed files with 1513 additions and 6142 deletions

6
.editorconfig Normal file
View file

@ -0,0 +1,6 @@
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 4
indent_style = space

7625
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -26,8 +26,9 @@
"knex": "^2.4.0",
"lodash": "^4.17.21",
"morgan": "^1.10.0",
"mysql": "^2.18.1",
"nodemailer": "^6.6.1",
"pg": "^8.11.3",
"pg-native": "^3.0.1",
"prom-client": "^13.1.0",
"proxy-addr": "^2.0.6",
"pug": "^3.0.2",

View file

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

View file

@ -30,19 +30,19 @@ class Database {
constructor(knexConfig = null) {
if (knexConfig === null) {
knexConfig = {
client: 'mysql',
client: Config.get('database.client'),
connection: {
host: Config.get('mysql.server'),
port: Config.get('mysql.port'),
user: Config.get('mysql.user'),
password: Config.get('mysql.password'),
database: Config.get('mysql.database'),
host: Config.get('database.server'),
port: Config.get('database.port'),
user: Config.get('database.user'),
password: Config.get('database.password'),
database: Config.get('database.database'),
multipleStatements: true, // Legacy thing
charset: 'utf8mb4'
},
pool: {
min: Config.get('mysql.pool-size'),
max: Config.get('mysql.pool-size')
min: Config.get('database.pool-size'),
max: Config.get('database.pool-size')
},
debug: !!process.env.KNEX_DEBUG
};
@ -73,6 +73,8 @@ module.exports.init = function (newDB) {
} else {
db = new Database();
}
// FIXME Initial database connection failed: error: select 1 from dual
// relation "dual" does not exist
db.knex.raw('select 1 from dual')
.catch(error => {
LOGGER.error('Initial database connection failed: %s', error.stack);