How to use the italia-ts-commons/lib/url.UrlFromString.decode function in italia-ts-commons

To help you get started, we’ve selected a few italia-ts-commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teamdigitale / io-functions / lib / webhook_queue_handler.ts View on Github external
const startWebhookCallTime = process.hrtime();

  const sendResult = await sendToWebhook(
    webhookNotification.url,
    message,
    content,
    senderMetadata
  );

  const webhookCallDurationMs = diffInMilliseconds(startWebhookCallTime);

  const eventName = "notification.webhook.delivery";

  // hide backend secret token in logs
  const hostName = UrlFromString.decode(webhookNotification.url).fold(
    _ => "invalid url",
    url => url.hostname || "invalid hostname"
  );

  const eventContent = {
    data: hostName,
    dependencyTypeName: "HTTP",
    duration: webhookCallDurationMs,
    name: eventName
  };

  if (isLeft(sendResult)) {
    const error = sendResult.value;
    // track the event of failed delivery
    lAppInsightsClient.trackDependency({
      ...eventContent,