MCPcopy
hub / github.com/mongodb/node-mongodb-native / getTLSOptions

Function getTLSOptions

test/tools/utils.ts:131–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

129}
130
131export 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
154export function getEnvironmentalOptions(): ReturnType<typeof getTLSOptions> &
155 Pick<MongoClientOptions, 'serverApi'> {

Callers 1

getEnvironmentalOptionsFunction · 0.85

Calls 1

filterMethod · 0.45

Tested by

no test coverage detected