**Initialize React Vite project with basic setup**

Add initial project structure including React, Vite, TailwindCSS, and Syncfusion dependencies. Configure tooling with ESLint, TypeScript, and Tailwind plugins. Set up `.gitignore`, Syncfusion themes, and example components for demonstration purposes.
This commit is contained in:
2025-02-07 23:21:46 +01:00
parent be2599218d
commit 9b45752d1a
33 changed files with 6511 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
using Api.SignalR;
using Microsoft.AspNetCore.SignalR;
var builder = WebApplication.CreateBuilder(args);
@@ -8,6 +9,7 @@ builder.Services.AddEndpointsApiExplorer();
builder.Services.AddOpenApi();
builder.Services.AddSignalR();
builder.Services.AddHostedService<SignalRSendService>();
builder.Services.AddSingleton<IUserIdProvider, UserProvider>();
builder.Services.AddOpenApiDocument(config =>
{
config.Title = "NSwag Demo API";

View File

@@ -12,16 +12,16 @@ namespace Api.SignalR
while (!stoppingToken.IsCancellationRequested)
{
// For example, wait 10 seconds between messages.
await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken);
await Task.Delay(TimeSpan.FromSeconds(2), stoppingToken);
// Log or do any work here.
logger.LogInformation("Background service sending message at: {Time}", DateTime.Now);
// Send a message to all connected clients.
await hubContext.Clients.All.SendAsync(
await hubContext.Clients.User("user1234").SendAsync(
"ReceiveMessage", // This is the client method name.
"Background Service", // Example sender.
"Hello from the background task!", // The message.
$"Hello from the background task at {DateTime.Now:F}", // The message.
stoppingToken);
}
}

View File

@@ -0,0 +1,14 @@
using Microsoft.AspNetCore.SignalR;
namespace Api.SignalR
{
public class UserProvider : IUserIdProvider
{
public string GetUserId(HubConnectionContext connection)
{
// Extract the "userId" query parameter from the HTTP context.
var httpContext = connection.GetHttpContext();
return httpContext?.Request.Query["userId"].FirstOrDefault();
}
}
}