(connection: Connection)
| 5 | const systemDatabases = ["master", "tempdb", "model", "msdb"]; |
| 6 | |
| 7 | const getMSSQLConnection = async (connection: Connection): Promise<ConnectionPool> => { |
| 8 | const connectionOptions: any = { |
| 9 | server: connection.host, |
| 10 | port: parseInt(connection.port), |
| 11 | user: connection.username, |
| 12 | password: connection.password, |
| 13 | database: connection.database, |
| 14 | options: { |
| 15 | encrypt: connection.encrypt === true, |
| 16 | }, |
| 17 | }; |
| 18 | if (connection.ssl) { |
| 19 | connectionOptions.ssl = { |
| 20 | ca: connection.ssl?.ca, |
| 21 | cert: connection.ssl?.cert, |
| 22 | key: connection.ssl?.key, |
| 23 | }; |
| 24 | } |
| 25 | const pool = await new ConnectionPool(connectionOptions).connect(); |
| 26 | return pool; |
| 27 | }; |
| 28 | |
| 29 | const testConnection = async (connection: Connection): Promise<boolean> => { |
| 30 | const pool = await getMSSQLConnection(connection); |
no outgoing calls
no test coverage detected