Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add type safety to adapters auth #504

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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