nginx-proxy-manager/backend/db.js

28 lines
604 B
JavaScript
Raw Normal View History

const config = require('./lib/config');
if (!config.has('database')) {
throw new Error('Database config does not exist! Please read the instructions: https://nginxproxymanager.com/setup/');
}
2020-07-19 14:43:01 +00:00
function generateDbConfig() {
const cfg = config.get('database');
if (cfg.engine === 'knex-native') {
return cfg.knex;
}
return {
client: cfg.engine,
connection: {
host: cfg.host,
user: cfg.user,
password: cfg.password,
database: cfg.name,
port: cfg.port
},
migrations: {
tableName: 'migrations'
}
};
2020-07-19 14:43:01 +00:00
}
module.exports = require('knex')(generateDbConfig());