Files
nginx-proxy-manager/backend/db.js
Jamie Curnow a12553fec7 Convert backend to ESM
- About 5 years overdue
- Remove eslint, use bomejs instead
2025-09-03 13:59:40 +10:00

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());