Skip to content

Commit

Permalink
Add client (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwatson484 authored Nov 14, 2022
1 parent aaaede6 commit 68a7dd8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions app/messaging/admin-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { ServiceBusAdministrationClient } = require('@azure/service-bus')
const { DefaultAzureCredential } = require('@azure/identity')

class AdminClient {
constructor (config) {
this.connectionName = config.name || config.address
this.appInsights = config.appInsights
this.config = config
this.connect()
}

connect () {
if (this.config.useCredentialChain) {
const credentials = this.getCredentials()
this.sbClient = new ServiceBusAdministrationClient(this.config.host, credentials)
} else {
this.sbClient = new ServiceBusAdministrationClient(`Endpoint=sb://${this.config.host}/;SharedAccessKeyName=${this.config.username};SharedAccessKey=${this.config.password}`)
}
}

getCredentials () {
return new DefaultAzureCredential()
}

async getClient () {
return this.sbClient
}
}

module.exports = AdminClient
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-messaging",
"version": "2.5.2",
"version": "2.6.0",
"description": "Messaging npm module for FFC services",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 68a7dd8

Please sign in to comment.