@@ -1198,64 +1198,6 @@ export function get(
11981198 } ) ;
11991199}
12001200
1201- export async function request ( uri : string ) : Promise < Record < string , any > > ;
1202- export async function request (
1203- uri : string ,
1204- options ?: { json ?: true } & RequestOptions
1205- ) : Promise < Record < string , any > > ;
1206- export async function request (
1207- uri : string ,
1208- options ?: { json : false } & RequestOptions
1209- ) : Promise < string > ;
1210- export async function request (
1211- uri : string ,
1212- options : RequestOptions = { }
1213- ) : Promise < string | Record < string , any > > {
1214- return await new Promise < string | Record < string , any > > ( ( resolve , reject ) => {
1215- const requestOptions = {
1216- method : 'GET' ,
1217- timeout : 10000 ,
1218- json : true ,
1219- url : new URL ( uri ) ,
1220- ...options
1221- } ;
1222-
1223- const req = http . request ( requestOptions , res => {
1224- res . setEncoding ( 'utf8' ) ;
1225-
1226- let data = '' ;
1227- res . on ( 'data' , d => {
1228- data += d ;
1229- } ) ;
1230-
1231- res . once ( 'end' , ( ) => {
1232- if ( options . json === false ) {
1233- resolve ( data ) ;
1234- return ;
1235- }
1236-
1237- try {
1238- const parsed = JSON . parse ( data ) ;
1239- resolve ( parsed ) ;
1240- } catch {
1241- // TODO(NODE-3483)
1242- reject ( new MongoRuntimeError ( `Invalid JSON response: "${ data } "` ) ) ;
1243- }
1244- } ) ;
1245- } ) ;
1246-
1247- req . once ( 'timeout' , ( ) =>
1248- req . destroy (
1249- new MongoNetworkTimeoutError (
1250- `Network request to ${ uri } timed out after ${ options . timeout } ms`
1251- )
1252- )
1253- ) ;
1254- req . once ( 'error' , error => reject ( error ) ) ;
1255- req . end ( ) ;
1256- } ) ;
1257- }
1258-
12591201/** @internal */
12601202export const DOCUMENT_DB_CHECK = / ( \. d o c d b \. a m a z o n a w s \. c o m $ ) | ( \. d o c d b - e l a s t i c \. a m a z o n a w s \. c o m $ ) / ;
12611203/** @internal */
0 commit comments