()
| 4 | let instance = null; |
| 5 | |
| 6 | const generateDbConfig = () => { |
| 7 | if (!configHas("database")) { |
| 8 | throw new Error( |
| 9 | "Database config does not exist! Please read the instructions: https://nginxproxymanager.com/setup/", |
| 10 | ); |
| 11 | } |
| 12 | |
| 13 | const cfg = configGet("database"); |
| 14 | |
| 15 | if (cfg.engine === "knex-native") { |
| 16 | return cfg.knex; |
| 17 | } |
| 18 | |
| 19 | return { |
| 20 | client: cfg.engine, |
| 21 | connection: { |
| 22 | host: cfg.host, |
| 23 | user: cfg.user, |
| 24 | password: cfg.password, |
| 25 | database: cfg.name, |
| 26 | port: cfg.port, |
| 27 | ...(cfg.ssl ? { ssl: cfg.ssl } : {}) |
| 28 | }, |
| 29 | migrations: { |
| 30 | tableName: "migrations", |
| 31 | }, |
| 32 | }; |
| 33 | }; |
| 34 | |
| 35 | const getInstance = () => { |
| 36 | if (!instance) { |
no test coverage detected