-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
6 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,15 @@ | ||
# Codefactors.DataFabric | ||
## Data synchronisation layer for C# and TypeScript | ||
# StandardWebhooks | ||
|
||
Codefactors.DataFabric is a library that provides a simple and efficient way to subscribe to data changes in a database. It is designed to be used in a microservices architecture where services need to be notified of changes in a database. | ||
## Implementation of Standard Webhooks for .NET Core | ||
|
||
## SignalR Transport | ||
```csharp | ||
using Microsoft.AspNetCore.SignalR; | ||
using Codefactors.DataFabric.Subscriptions; | ||
using Codefactors.DataFabric.Transport; | ||
using Codefactors.DataFabric.Transport.SignalR; | ||
|
||
namespace Codefactors.DataFabric.WebApi.Transport; | ||
|
||
public class SignalRHelper(Uri hubPath) : ITransportHelper | ||
{ | ||
private readonly Uri _hubPath = hubPath; | ||
|
||
public void Initialise(IServiceCollection services) | ||
{ | ||
services.AddSingleton<IUserIdProvider, SignalRUserIdProvider>(); | ||
|
||
services.AddSignalR(); | ||
|
||
services.AddSingleton<IDataFabricTransport, SignalRTransport>(); | ||
services.AddSingleton<ISubscriptionFactory, SignalRSubscriptionFactory>(); | ||
} | ||
|
||
public void InitialiseMiddleware(object app) | ||
{ | ||
if (app is WebApplication application) | ||
{ | ||
application.UseMiddleware<SignalRAuthenticationMiddleware>(_hubPath.ToString()); | ||
} | ||
else | ||
{ | ||
throw new ArgumentException("Unable to initialise transport middleware; invalid application type"); | ||
} | ||
} | ||
## Subhead | ||
```csharp | ||
|
||
public void Start(object app) | ||
{ | ||
if (app is WebApplication application) | ||
{ | ||
application.MapHub<NotificationHub>(_hubPath.ToString()) | ||
.RequireAuthorization(); | ||
} | ||
else | ||
{ | ||
throw new ArgumentException("Unable to start transport; invalid application type"); | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Acknowledgements | ||
|
||
``` | ||
|
||
### License | ||
This project is licensed under the MIT License. |