mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-11-04 01:15:14 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			676 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			676 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import knex from "knex";
 | 
						|
import {configGet, configHas} from "./lib/config.js";
 | 
						|
 | 
						|
const generateDbConfig = () => {
 | 
						|
	if (!configHas("database")) {
 | 
						|
		throw new Error(
 | 
						|
			"Database config does not exist! Please read the instructions: https://nginxproxymanager.com/setup/",
 | 
						|
		);
 | 
						|
	}
 | 
						|
 | 
						|
	const cfg = configGet("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,
 | 
						|
			...(cfg.ssl ? { ssl: cfg.ssl } : {})
 | 
						|
		},
 | 
						|
		migrations: {
 | 
						|
			tableName: "migrations",
 | 
						|
		},
 | 
						|
	};
 | 
						|
};
 | 
						|
 | 
						|
export default knex(generateDbConfig());
 |