mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-10-30 23:33:34 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			632 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			632 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,
 | |
| 		},
 | |
| 		migrations: {
 | |
| 			tableName: "migrations",
 | |
| 		},
 | |
| 	};
 | |
| };
 | |
| 
 | |
| export default knex(generateDbConfig());
 |