()
| 58 | let poolPromise: Promise<mysql2.Pool>; |
| 59 | |
| 60 | const getPool = (): Promise<mysql2.Pool> => { |
| 61 | if (!poolPromise) { |
| 62 | poolPromise = new Promise<mysql2.Pool>((resolve, reject) => { |
| 63 | try { |
| 64 | const pool = mysql2.createPool(config.mysql); |
| 65 | log("info", "MySQL pool created successfully"); |
| 66 | resolve(pool); |
| 67 | } catch (error) { |
| 68 | log("error", "Error creating MySQL pool:", error); |
| 69 | reject(error); |
| 70 | } |
| 71 | }); |
| 72 | } |
| 73 | return poolPromise; |
| 74 | }; |
| 75 | |
| 76 | async function executeQuery<T>(sql: string, params: string[] = []): Promise<T> { |
| 77 | let connection; |
no test coverage detected