db.js 604 B

123456789101112131415161718192021222324252627
  1. const config = require('./lib/config');
  2. if (!config.has('database')) {
  3. throw new Error('Database config does not exist! Please read the instructions: https://nginxproxymanager.com/setup/');
  4. }
  5. function generateDbConfig() {
  6. const cfg = config.get('database');
  7. if (cfg.engine === 'knex-native') {
  8. return cfg.knex;
  9. }
  10. return {
  11. client: cfg.engine,
  12. connection: {
  13. host: cfg.host,
  14. user: cfg.user,
  15. password: cfg.password,
  16. database: cfg.name,
  17. port: cfg.port
  18. },
  19. migrations: {
  20. tableName: 'migrations'
  21. }
  22. };
  23. }
  24. module.exports = require('knex')(generateDbConfig());