VOOZH about

URL: https://www.nuget.org/packages/Clerk.Webhooks/

⇱ NuGet Gallery | Clerk.Webhooks 0.0.2




Clerk.Webhooks 0.0.2

dotnet add package Clerk.Webhooks --version 0.0.2
 
 
NuGet\Install-Package Clerk.Webhooks -Version 0.0.2
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Clerk.Webhooks" Version="0.0.2" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Clerk.Webhooks" Version="0.0.2" />
 
Directory.Packages.props
<PackageReference Include="Clerk.Webhooks" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Clerk.Webhooks --version 0.0.2
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Clerk.Webhooks, 0.0.2"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Clerk.Webhooks@0.0.2
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Clerk.Webhooks&version=0.0.2
 
Install as a Cake Addin
#tool nuget:?package=Clerk.Webhooks&version=0.0.2
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Clerk Extensions

A collection of multiple clerk packages for .NET.

Clerk is adding support for clerk.com to .NET.

Clerk.Webhooks is a simple extension for supporting webhooks from clerk.com.

Clerk

Installing Clerk

Clerk is available as a NuGet package and can be installed as

Install-Package Clerk

or via the .NET Core command line interface:

dotnet add package Clerk

Registering using Dependency Injection

Clerk.Webhooks

Installing Clerk.Webhooks

Clerk.Webhooks is available as a NuGet package and can be installed as

Install-Package Clerk.Webhooks

or via the .NET Core command line interface:

dotnet add package Clerk.Webhooks

Creating Webhook Events

Webhook events are simple data classes whose only purpose is to hold the data from the webhook. The data is automatically deserialized from the webhook request.

Events are custom defined in order to enable better flexibility in case of data changes from the event catalog at clerk.com.

For example, if you would like to have a webhook event for when a user is created, you can create a class like this:

public class UserCreated
{
 public string Id { get; set; }
 
 public string Username { get; set; }
 
 [JsonProperty("first_name")]
 public string FirstName { get; set; }
 
 [JsonProperty("last_name")
 public string LastName { get; set; }
}

Creating Webhook Handlers

using Clerk.Webhooks;

public class UserCreatedWebhookHandler : IWebhookHandler<UserCreated>
{
 public Task HandleAsync(Webhook<UserCreated> webhook, CancellationToken cancellationToken)
 {
 // Do something with the webhook event
 }
}

The webhook handlers works with dependency injection, so you can inject any service you need into the handler by its constructor.

Registering using Dependency Injection

using Clerk.Webhooks;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddClerkWebhooks(webhookBuilder => 
{
 // using predefined event names
 webhookBuilder.AddHandler<UserCreated, UserCreatedWebhookHandler>(@event => @event.User.Created);
 
 // or simply using string
 webhookBuilder.AddHandler<UserCreated, UserCreatedWebhookHandler>("user.created");
});

Adding Validation

using Clerk.Webhooks;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddClerkWebhooks(webhookBuilder => 
{
 webhookBuilder.AddHandler<UserCreated, UserCreatedWebhookHandler>(@event => @event.User.Created);
 
 // Adding signing credentials for webhook validation using svix under the hood
 webhookBuilder.AddSigningSecret("signing-secret");
});

Using the middleware

In order to enable request to the webhook endpoint, you need to add the middleware to the request pipeline.

By default, it uses the route prefix '/clerk', but you can change it to whatever you want.

Example using the default route prefix:

using Clerk.Webhooks;

app = builder.build();

app.UseClerkWebhooks();

Example using a custom route prefix:

using Clerk.Webhooks;

app = builder.build();

app.UseClerkWebhooks(options => 
{
 options.RoutePrefix = "/my-webhook-endpoint";
});
Product Versions Compatible and additional computed target framework versions.
.NET net7.0 net7.0 is compatible.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.2 1,639 9/22/2023
0.0.1 616 9/22/2023
0.0.0-alpha.1 178 9/22/2023