()
| 129 | } |
| 130 | |
| 131 | export function getTLSOptions(): Pick< |
| 132 | MongoClientOptions, |
| 133 | 'tls' | 'tlsCertificateKeyFile' | 'tlsCAFile' |
| 134 | > { |
| 135 | if (!isTLSEnabled) return {}; |
| 136 | |
| 137 | const requiredTLSEnv = ['TLS_KEY_FILE', 'TLS_CA_FILE']; |
| 138 | const missingVariables = requiredTLSEnv.filter(key => process.env[key] == null); |
| 139 | |
| 140 | if (missingVariables.length) |
| 141 | throw new Error( |
| 142 | `TLS requires the following additional environment variables: ${missingVariables.join(',')}` |
| 143 | ); |
| 144 | |
| 145 | const { TLS_KEY_FILE: tlsCertificateKeyFile, TLS_CA_FILE: tlsCAFile } = process.env; |
| 146 | |
| 147 | return { |
| 148 | tlsCertificateKeyFile, |
| 149 | tlsCAFile, |
| 150 | tls: true |
| 151 | }; |
| 152 | } |
| 153 | |
| 154 | export function getEnvironmentalOptions(): ReturnType<typeof getTLSOptions> & |
| 155 | Pick<MongoClientOptions, 'serverApi'> { |
no test coverage detected