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

Function get

src/utils.ts:1196–1222  ·  view source on GitHub ↗
(
  url: URL | string,
  options: http.RequestOptions = {}
)

Source from the content-addressed store, hash-verified

1194 * @internal
1195 */
1196export function get(
1197 url: URL | string,
1198 options: http.RequestOptions = {}
1199): Promise<{ body: string; status: number | undefined }> {
1200 return new Promise((resolve, reject) => {
1201 /* eslint-disable prefer-const */
1202 let timeoutId: NodeJS.Timeout;
1203 const request = http
1204 .get(url, options, response => {
1205 response.setEncoding('utf8');
1206 let body = '';
1207 response.on('data', chunk => (body += chunk));
1208 response.on('end', () => {
1209 clearTimeout(timeoutId);
1210 resolve({ status: response.statusCode, body });
1211 });
1212 })
1213 .on('error', error => {
1214 clearTimeout(timeoutId);
1215 reject(error);
1216 })
1217 .end();
1218 timeoutId = setTimeout(() => {
1219 request.destroy(new MongoNetworkTimeoutError(`request timed out after 10 seconds`));
1220 }, 10000);
1221 });
1222}
1223
1224/** @internal */
1225export const DOCUMENT_DB_CHECK = /(\.docdb\.amazonaws\.com$)|(\.docdb-elastic\.amazonaws\.com$)/;

Callers 4

getGcpTokenDataFunction · 0.90
getAzureTokenDataFunction · 0.90
fetchAzureKMSTokenFunction · 0.90
isMockServerSetupFunction · 0.50

Calls 5

onMethod · 0.80
resolveFunction · 0.50
endMethod · 0.45
getMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected