Skip to content

Commit

Permalink
feat: add type safety to adapters auth (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhudaDad414 authored Aug 14, 2023
1 parent 366c31a commit b84101b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/adapters/http/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HttpClientAdapter extends Adapter {
async send(message: GleeMessage): Promise<void> {
const headers = {}
const config: HttpAdapterConfig = await this.resolveProtocolConfig('http')
const auth: HttpAuthConfig = await this.getAuthConfig(config.client.auth)
const auth: HttpAuthConfig = await this.getAuthConfig(config?.client?.auth)
headers['Authentication'] = auth?.token
const serverUrl = this.serverUrlExpanded
for (const channelName of this.channelNames) {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/kafka/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class KafkaAdapter extends Adapter {
const kafkaOptions: KafkaAdapterConfig = await this.resolveProtocolConfig(
'kafka'
)
const auth: KafkaAuthConfig = await this.getAuthConfig(kafkaOptions.auth)
const auth: KafkaAuthConfig = await this.getAuthConfig(kafkaOptions?.auth)
const securityRequirements = (this.AsyncAPIServer.security() || []).map(
(sec) => {
const secName = Object.keys(sec.json())[0]
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/mqtt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class MqttAdapter extends Adapter {
const mqttOptions: MqttAdapterConfig = await this.resolveProtocolConfig(
'mqtt'
)
const auth: MqttAuthConfig = await this.getAuthConfig(mqttOptions.auth)
const auth: MqttAuthConfig = await this.getAuthConfig(mqttOptions?.auth)
const subscribedChannels = this.getSubscribedChannels()
const mqttServerBinding = this.AsyncAPIServer.binding('mqtt')
const mqtt5ServerBinding = this.AsyncAPIServer.binding('mqtt5')
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ws/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WsClientAdapter extends Adapter {
const headers = {}
const wsOptions: WebsocketAdapterConfig =
await this.resolveProtocolConfig('ws')
const auth: WsAuthConfig = await this.getAuthConfig(wsOptions.client.auth)
const auth: WsAuthConfig = await this.getAuthConfig(wsOptions?.client?.auth)
headers['Authentication'] = `bearer ${auth?.token}`

const url = new URL(this.AsyncAPIServer.url() + channel)
Expand Down

0 comments on commit b84101b

Please sign in to comment.