Skip to content

Commit

Permalink
WIP: remove connection string
Browse files Browse the repository at this point in the history
  • Loading branch information
Garma00 committed Jun 5, 2024
1 parent 1b649bf commit 8c118c6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
6 changes: 1 addition & 5 deletions Info/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ export function Info(): express.RequestHandler {
healthcheck.checkAzureStorageHealth(
c.NOTIFICATIONS_STORAGE_CONNECTION_STRING
),
c =>
checkAzureNotificationHub(
c.AZURE_NH_CONNECTION_STRING,
c.AZURE_NH_HUB_NAME
),
c => checkAzureNotificationHub(c.AZURE_NH_ENDPOINT, c.AZURE_NH_HUB_NAME),
...[0, 1, 2, 3].map(i => (c: t.TypeOf<typeof IConfig>) =>
checkAzureNotificationHub(
c.AZURE_NOTIFICATION_HUB_PARTITIONS[i].endpoint,
Expand Down
2 changes: 1 addition & 1 deletion utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const BaseConfig = t.intersection([

// Legacy Notification Hub configuration
t.interface({
AZURE_NH_CONNECTION_STRING: NonEmptyString,
AZURE_NH_ENDPOINT: NonEmptyString,
AZURE_NH_HUB_NAME: NonEmptyString
}),

Expand Down
4 changes: 2 additions & 2 deletions utils/healthcheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { buildNHService } from "./notificationhubServicePartition";
* @returns either true or an array of error messages
*/
export const checkAzureNotificationHub = (
AZURE_NH_CONNECTION_STRING: NonEmptyString,
AZURE_NH_ENDPOINT: NonEmptyString,
AZURE_NH_HUB_NAME: NonEmptyString
): healthcheck.HealthCheck<"AzureNotificationHub"> =>
pipe(
TE.tryCatch(
() =>
buildNHService({
AZURE_NH_CONNECTION_STRING,
AZURE_NH_ENDPOINT,
AZURE_NH_HUB_NAME
}).deleteInstallation("aFakeInstallation"),
healthcheck.toHealthProblems("AzureNotificationHub")
Expand Down
10 changes: 5 additions & 5 deletions utils/notificationhubServicePartition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { InstallationId } from "../generated/notifications/InstallationId";
import { IConfig } from "./config";

export const NotificationHubConfig = t.interface({
AZURE_NH_CONNECTION_STRING: NonEmptyString,
AZURE_NH_ENDPOINT: NonEmptyString,
AZURE_NH_HUB_NAME: NonEmptyString
});

Expand All @@ -24,7 +24,7 @@ export type NotificationHubConfig = t.TypeOf<typeof NotificationHubConfig>;
export const getNHLegacyConfig = (
envConfig: IConfig
): NotificationHubConfig => ({
AZURE_NH_CONNECTION_STRING: envConfig.AZURE_NH_CONNECTION_STRING,
AZURE_NH_ENDPOINT: envConfig.AZURE_NH_ENDPOINT,
AZURE_NH_HUB_NAME: envConfig.AZURE_NH_HUB_NAME
});

Expand Down Expand Up @@ -55,7 +55,7 @@ export const getNotificationHubPartitionConfig = (envConfig: IConfig) => (
Error(`Unable to find Notification Hub partition for ${sha}`)
),
E.map(partition => ({
AZURE_NH_CONNECTION_STRING: partition.connectionString,
AZURE_NH_ENDPOINT: partition.endpoint,
AZURE_NH_HUB_NAME: partition.name
})),
E.getOrElseW(e => {
Expand All @@ -65,6 +65,6 @@ export const getNotificationHubPartitionConfig = (envConfig: IConfig) => (

export const buildNHService = ({
AZURE_NH_HUB_NAME,
AZURE_NH_CONNECTION_STRING
AZURE_NH_ENDPOINT
}: NotificationHubConfig): NotificationHubsClient =>
new NotificationHubsClient(AZURE_NH_CONNECTION_STRING, AZURE_NH_HUB_NAME);
new NotificationHubsClient(AZURE_NH_ENDPOINT, AZURE_NH_HUB_NAME);
1 change: 0 additions & 1 deletion utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export type NotificationHubPartition = t.TypeOf<
typeof NotificationHubPartition
>;
export const NotificationHubPartition = t.interface({
connectionString: NonEmptyString,
endpoint: NonEmptyString,
name: NonEmptyString,
partitionRegex: RegExpFromString
Expand Down

0 comments on commit 8c118c6

Please sign in to comment.