Skip to content

Commit

Permalink
SchemaRegistry: Remove binding agent to global
Browse files Browse the repository at this point in the history
  • Loading branch information
seriouslag committed Apr 13, 2021
1 parent d2354ec commit d78272f
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Agent } from 'http'
import forge, { Authorization, Client, configs } from 'mappersmith'
import forge, { Authorization, Client, Options } from 'mappersmith'
import RetryMiddleware, { RetryMiddlewareOptions } from 'mappersmith/middleware/retry/v2'
import BasicAuthMiddleware from 'mappersmith/middleware/basic-auth'

Expand Down Expand Up @@ -48,18 +48,8 @@ export default ({
retry = {},
agent,
}: SchemaRegistryAPIClientArgs): SchemaRegistryAPIClient => {
// TODO: figure out how to only bind agent to host URL
// if an agent was provided, bind the agent to the mappersmith configs
if (agent) {
configs.gatewayConfigs.HTTP = {
configure() {
return {
agent,
}
},
}
}
return forge({
// FIXME: ResourcesType typings is not exposed by mappersmith
const manifest: Options<any> = {
clientId: clientId || DEFAULT_API_CLIENT_ID,
ignoreGlobalMiddleware: true,
host,
Expand Down Expand Up @@ -114,5 +104,13 @@ export default ({
},
},
},
})
}
// if an agent was provided, bind the agent to the mappersmith configs
if (agent) {
// gatewayConfigs is not listed as a type on manifest object in mappersmith
;(manifest as any).gatewayConfigs = {
configure: () => agent,
}
}
return forge(manifest)
}

0 comments on commit d78272f

Please sign in to comment.