From ed7bef073f584b33509c5476c2474a51d962dd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez?= Date: Tue, 21 May 2019 20:35:18 +0000 Subject: [PATCH] Small changes after type definitions are added Once https-proxy-agent type definitions are added, these changes will be necessary to make this sample work. The PR that introduces the TypeScript definitions to https-proxy-agent is: https://github.com/TooTallNate/node-https-proxy-agent/pull/66 This commit is related to https://github.com/Azure/azure-sdk-for-js/issues/3064 --- .../samples/typescript/gettingStarted/useProxy.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sdk/servicebus/service-bus/samples/typescript/gettingStarted/useProxy.ts b/sdk/servicebus/service-bus/samples/typescript/gettingStarted/useProxy.ts index 743a07b01d35..ca32ce28428b 100644 --- a/sdk/servicebus/service-bus/samples/typescript/gettingStarted/useProxy.ts +++ b/sdk/servicebus/service-bus/samples/typescript/gettingStarted/useProxy.ts @@ -10,16 +10,21 @@ import { ServiceBusClient } from "@azure/service-bus"; import WebSocket from "ws"; import url from "url"; import httpsProxyAgent from "https-proxy-agent"; +import { HttpsProxyAgentOptions } from "https-proxy-agent"; // Define connection string for your Service Bus instance here const connectionString = ""; // Get relevant proxy url, username and password needed to create an instance of httpsProxyAgent -const urlParts = url.parse("http://localhost:3128"); -urlParts.auth = "username:password"; // Skip this if proxy server does not need authentication. +const { host = "", port = "" } = url.parse("http://localhost:3128"); +const options: HttpsProxyAgentOptions = { + host, + port: parseInt(port, 10), + auth: "username:password" // Skip this if proxy server does not need authentication. +} // Create an instance of the `HttpsProxyAgent` class with the proxy server information -const proxyAgent = new httpsProxyAgent(urlParts); +const proxyAgent = new httpsProxyAgent(options); async function main(): Promise { const sbClient = ServiceBusClient.createFromConnectionString(connectionString, {