From f1f8f6e012806ba013c0e2a5d2c6b2ae92864e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B0=D0=BB=D0=B8=D0=BC=D0=BE=D0=B2=20=D0=A0=D1=83?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BC?= Date: Mon, 30 Mar 2026 23:57:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=BF=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/Host/Host.csproj | 1 - backend/src/Host/Program.cs | 21 +++++++---- .../Modules/Admin/Knot.Modules.Admin.csproj | 3 +- .../Presentation/Endpoints/AdminEndpoints.cs | 5 ++- .../src/Modules/Auth/Knot.Modules.Auth.csproj | 3 +- .../Presentation/Endpoints/AuthEndpoints.cs | 5 ++- .../Knot.Modules.Conversations.csproj | 3 +- .../Presentation/Endpoints/ChatsEndpoints.cs | 29 ++++++++------- .../Endpoints/MessagesEndpoints.cs | 23 ++++++------ .../Federation/Knot.Modules.Federation.csproj | 5 +-- .../Endpoints/FederationEndpoints.cs | 5 ++- .../Modules/Klipy/Knot.Modules.Klipy.csproj | 5 +-- .../Presentation/Endpoints/KlipyEndpoints.cs | 5 ++- .../Profiles/Knot.Modules.Profiles.csproj | 3 +- .../Endpoints/ProfilesEndpoints.cs | 5 ++- .../Relations/Knot.Modules.Relations.csproj | 1 - .../Endpoints/ContactsEndpoints.cs | 5 ++- .../Settings/Knot.Modules.Settings.csproj | 5 +-- .../Endpoints/SettingsEndpoints.cs | 5 ++- .../Storage/Knot.Modules.Storage.csproj | 1 - .../Presentation/Endpoints/FilesEndpoints.cs | 35 +++++++++---------- .../Stories/Knot.Modules.Stories.csproj | 1 - .../Endpoints/StoriesEndpoints.cs | 34 ++---------------- .../Knot.Modules.TelegramImport.csproj | 1 - .../Endpoints/TelegramImportEndpoints.cs | 11 +++--- .../Modules/WebRtc/Knot.Modules.WebRtc.csproj | 1 - .../Presentation/Endpoints/WebRtcEndpoints.cs | 9 +++-- 27 files changed, 88 insertions(+), 142 deletions(-) diff --git a/backend/src/Host/Host.csproj b/backend/src/Host/Host.csproj index 39bc759..746b68c 100644 --- a/backend/src/Host/Host.csproj +++ b/backend/src/Host/Host.csproj @@ -8,7 +8,6 @@ - diff --git a/backend/src/Host/Program.cs b/backend/src/Host/Program.cs index 2b571fb..e835ddc 100644 --- a/backend/src/Host/Program.cs +++ b/backend/src/Host/Program.cs @@ -1,5 +1,4 @@ using Knot.Modules.Messaging; -using Carter; using Knot.Shared.Infrastructure; using Knot.Modules.Auth; using Knot.Modules.Profiles; @@ -19,7 +18,6 @@ using System.Text; using System.IdentityModel.Tokens.Jwt; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Extensions.FileProviders; using Microsoft.AspNetCore.SignalR; using System.Security.Claims; @@ -77,9 +75,6 @@ builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies( typeof(Knot.Modules.Klipy.DependencyInjection).Assembly )); -// Carter для вызова Minimal APIs (Endpoints) -builder.Services.AddCarter(); - // Настройка CORS builder.Services.AddCors(options => { @@ -216,8 +211,20 @@ if (app.Environment.IsDevelopment()) app.UseAuthentication(); app.UseAuthorization(); -// Добавляем контроллеры и Carter (Minimal APIs) -app.MapCarter(); +// Регистрация эндпоинтов +app.MapAuthEndpoints(); +app.MapStoriesEndpoints(); +app.MapContactsEndpoints(); +app.MapSettingsEndpoints(); +app.MapProfilesEndpoints(); +app.MapFederationEndpoints(); +app.MapKlipyEndpoints(); +app.MapChatsEndpoints(); +app.MapMessagesEndpoints(); +app.MapAdminEndpoints(); +app.MapFilesEndpoints(); +app.MapWebRtcEndpoints(); +app.MapTelegramImportEndpoints(); // Добавляем SignalR хабы app.MapHub("/hubs/chat"); diff --git a/backend/src/Modules/Admin/Knot.Modules.Admin.csproj b/backend/src/Modules/Admin/Knot.Modules.Admin.csproj index 97466f0..f428a51 100644 --- a/backend/src/Modules/Admin/Knot.Modules.Admin.csproj +++ b/backend/src/Modules/Admin/Knot.Modules.Admin.csproj @@ -1,4 +1,4 @@ - + net10.0 enable @@ -18,7 +18,6 @@ - diff --git a/backend/src/Modules/Admin/Presentation/Endpoints/AdminEndpoints.cs b/backend/src/Modules/Admin/Presentation/Endpoints/AdminEndpoints.cs index 38a1d3d..5f5c37f 100644 --- a/backend/src/Modules/Admin/Presentation/Endpoints/AdminEndpoints.cs +++ b/backend/src/Modules/Admin/Presentation/Endpoints/AdminEndpoints.cs @@ -1,4 +1,3 @@ -using Carter; using Knot.Contracts.Settings.Application.Abstractions; using Knot.Contracts.Settings.Application.DTOs; using Knot.Modules.Admin.Application.Admin.Commands; @@ -15,9 +14,9 @@ namespace Knot.Host.Presentation.Endpoints; public record KlipyTestDto(string ApiKey, string AppName); public record ResetPasswordRequest(string NewPassword); -public sealed class AdminEndpoints : ICarterModule +public static class AdminEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapAdminEndpoints(this WebApplication app) { var group = app.MapGroup("api/admin"); // Middleware handles auth diff --git a/backend/src/Modules/Auth/Knot.Modules.Auth.csproj b/backend/src/Modules/Auth/Knot.Modules.Auth.csproj index 84d1bd5..bdd0400 100644 --- a/backend/src/Modules/Auth/Knot.Modules.Auth.csproj +++ b/backend/src/Modules/Auth/Knot.Modules.Auth.csproj @@ -1,4 +1,4 @@ - + net10.0 @@ -15,7 +15,6 @@ - diff --git a/backend/src/Modules/Auth/Presentation/Endpoints/AuthEndpoints.cs b/backend/src/Modules/Auth/Presentation/Endpoints/AuthEndpoints.cs index b0a0114..18d349c 100644 --- a/backend/src/Modules/Auth/Presentation/Endpoints/AuthEndpoints.cs +++ b/backend/src/Modules/Auth/Presentation/Endpoints/AuthEndpoints.cs @@ -1,4 +1,3 @@ -using Carter; using Knot.Shared.Kernel; using Knot.Modules.Auth.Application.Users.Login; using Knot.Modules.Auth.Application.Users.Register; @@ -11,9 +10,9 @@ using Microsoft.AspNetCore.Mvc; namespace Knot.Modules.Auth.Presentation.Endpoints; -public sealed class AuthEndpoints : ICarterModule +public static class AuthEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapAuthEndpoints(this WebApplication app) { var group = app.MapGroup("api/auth"); diff --git a/backend/src/Modules/Conversations/Knot.Modules.Conversations.csproj b/backend/src/Modules/Conversations/Knot.Modules.Conversations.csproj index 198253d..d41b490 100644 --- a/backend/src/Modules/Conversations/Knot.Modules.Conversations.csproj +++ b/backend/src/Modules/Conversations/Knot.Modules.Conversations.csproj @@ -1,4 +1,4 @@ - + net10.0 enable @@ -16,7 +16,6 @@ - diff --git a/backend/src/Modules/Conversations/Presentation/Endpoints/ChatsEndpoints.cs b/backend/src/Modules/Conversations/Presentation/Endpoints/ChatsEndpoints.cs index 0665923..6de2a98 100644 --- a/backend/src/Modules/Conversations/Presentation/Endpoints/ChatsEndpoints.cs +++ b/backend/src/Modules/Conversations/Presentation/Endpoints/ChatsEndpoints.cs @@ -1,28 +1,27 @@ -using Carter; -using Knot.Shared.Kernel; -using Knot.Modules.Conversations.Application.DTOs; -using Knot.Modules.Conversations.Application.Chats.GetChats; -using Knot.Modules.Conversations.Application.Chats.GetChatById; -using Knot.Modules.Conversations.Application.Chats.Create; -using Knot.Modules.Conversations.Application.Chats.GetOrCreateFavorites; -using Knot.Modules.Conversations.Application.Chats.Update; -using Knot.Modules.Conversations.Application.Chats.LeaveOrDelete; -using Knot.Modules.Conversations.Application.Chats.Clear; -using Knot.Modules.Conversations.Application.Chats.TogglePin; -using Knot.Modules.Conversations.Application.Chats.Members; using Knot.Modules.Conversations.Application.Chats.Avatar; +using Knot.Modules.Conversations.Application.Chats.Clear; +using Knot.Modules.Conversations.Application.Chats.Create; +using Knot.Modules.Conversations.Application.Chats.GetChatById; +using Knot.Modules.Conversations.Application.Chats.GetChats; +using Knot.Modules.Conversations.Application.Chats.GetOrCreateFavorites; +using Knot.Modules.Conversations.Application.Chats.LeaveOrDelete; +using Knot.Modules.Conversations.Application.Chats.Members; +using Knot.Modules.Conversations.Application.Chats.TogglePin; +using Knot.Modules.Conversations.Application.Chats.Update; +using Knot.Modules.Conversations.Application.DTOs; using Knot.Modules.Conversations.Domain; +using Knot.Shared.Kernel; using MediatR; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; namespace Knot.Modules.Conversations.Presentation.Endpoints; -public sealed class ChatsEndpoints : ICarterModule +public static class ChatsEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapChatsEndpoints(this WebApplication app) { var group = app.MapGroup("api/chats").RequireAuthorization(); diff --git a/backend/src/Modules/Conversations/Presentation/Endpoints/MessagesEndpoints.cs b/backend/src/Modules/Conversations/Presentation/Endpoints/MessagesEndpoints.cs index 9d3bf53..54dd276 100644 --- a/backend/src/Modules/Conversations/Presentation/Endpoints/MessagesEndpoints.cs +++ b/backend/src/Modules/Conversations/Presentation/Endpoints/MessagesEndpoints.cs @@ -1,22 +1,21 @@ -using Carter; -using Knot.Shared.Kernel; using Knot.Modules.Conversations.Application.DTOs; using Knot.Modules.Conversations.Application.Messages.GetMessages; -using Knot.Modules.Conversations.Application.Messages.SearchMessages; -using Knot.Modules.Conversations.Application.Messages.UploadFile; using Knot.Modules.Conversations.Application.Messages.GetSharedMedia; +using Knot.Modules.Conversations.Application.Messages.SearchMessages; using Knot.Modules.Conversations.Application.Messages.Send; +using Knot.Modules.Conversations.Application.Messages.UploadFile; +using Knot.Shared.Kernel; using MediatR; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; namespace Knot.Modules.Conversations.Presentation.Endpoints; -public sealed class MessagesEndpoints : ICarterModule +public static class MessagesEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapMessagesEndpoints(this WebApplication app) { var group = app.MapGroup("api/messages").RequireAuthorization(); @@ -41,7 +40,7 @@ public sealed class MessagesEndpoints : ICarterModule using var stream = file.OpenReadStream(); var result = await sender.Send(new UploadFileCommand(file.FileName, file.ContentType, file.Length, stream), ct); - + if (result.IsFailure) { if (result.Error.Code == "File.TooLarge") return Results.StatusCode(413); @@ -58,13 +57,13 @@ public sealed class MessagesEndpoints : ICarterModule group.MapPost("chat/{chatId:guid}", async (Guid chatId, [FromBody] SendMessageRequest request, ISender sender, IUserContext userContext, CancellationToken ct) => { - var attachments = request.Attachments?.Select(a => + var attachments = request.Attachments?.Select(a => new AttachmentRequest(a.Type, a.Url, a.FileName, a.FileSize)).ToList(); var command = new SendMessageCommand( - chatId, - userContext.UserId, - request.Content, + chatId, + userContext.UserId, + request.Content, request.Type, attachments, request.ReplyToId, diff --git a/backend/src/Modules/Federation/Knot.Modules.Federation.csproj b/backend/src/Modules/Federation/Knot.Modules.Federation.csproj index 3302ede..dcb36a9 100644 --- a/backend/src/Modules/Federation/Knot.Modules.Federation.csproj +++ b/backend/src/Modules/Federation/Knot.Modules.Federation.csproj @@ -1,4 +1,4 @@ - + net10.0 enable @@ -13,7 +13,4 @@ - - - diff --git a/backend/src/Modules/Federation/Presentation/Endpoints/FederationEndpoints.cs b/backend/src/Modules/Federation/Presentation/Endpoints/FederationEndpoints.cs index bc3849c..c2be4ea 100644 --- a/backend/src/Modules/Federation/Presentation/Endpoints/FederationEndpoints.cs +++ b/backend/src/Modules/Federation/Presentation/Endpoints/FederationEndpoints.cs @@ -1,4 +1,3 @@ -using Carter; using MediatR; using Knot.Shared.Kernel.Constants; using Microsoft.AspNetCore.Builder; @@ -17,9 +16,9 @@ namespace Host.Endpoints; /// /// Эндпоинты федерации для межсерверного взаимодействия. /// -public sealed class FederationEndpoints : ICarterModule +public static class FederationEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapFederationEndpoints(this WebApplication app) { var group = app.MapGroup(Routes.ApiFederation); diff --git a/backend/src/Modules/Klipy/Knot.Modules.Klipy.csproj b/backend/src/Modules/Klipy/Knot.Modules.Klipy.csproj index c585e72..a01475c 100644 --- a/backend/src/Modules/Klipy/Knot.Modules.Klipy.csproj +++ b/backend/src/Modules/Klipy/Knot.Modules.Klipy.csproj @@ -1,4 +1,4 @@ - + net10.0 enable @@ -9,7 +9,4 @@ - - - diff --git a/backend/src/Modules/Klipy/Presentation/Endpoints/KlipyEndpoints.cs b/backend/src/Modules/Klipy/Presentation/Endpoints/KlipyEndpoints.cs index 462c094..93fed50 100644 --- a/backend/src/Modules/Klipy/Presentation/Endpoints/KlipyEndpoints.cs +++ b/backend/src/Modules/Klipy/Presentation/Endpoints/KlipyEndpoints.cs @@ -1,4 +1,3 @@ -using Carter; using MediatR; using Knot.Shared.Kernel.Constants; using Microsoft.AspNetCore.Builder; @@ -13,9 +12,9 @@ namespace Host.Endpoints; /// /// Регистрация эндпоинтов для сервиса Klipy. /// -public sealed class KlipyEndpoints : ICarterModule +public static class KlipyEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapKlipyEndpoints(this WebApplication app) { var group = app.MapGroup(Routes.ApiKlipy).RequireAuthorization(); diff --git a/backend/src/Modules/Profiles/Knot.Modules.Profiles.csproj b/backend/src/Modules/Profiles/Knot.Modules.Profiles.csproj index ee9ec12..99be9c4 100644 --- a/backend/src/Modules/Profiles/Knot.Modules.Profiles.csproj +++ b/backend/src/Modules/Profiles/Knot.Modules.Profiles.csproj @@ -1,4 +1,4 @@ - + net10.0 @@ -13,7 +13,6 @@ - diff --git a/backend/src/Modules/Profiles/Presentation/Endpoints/ProfilesEndpoints.cs b/backend/src/Modules/Profiles/Presentation/Endpoints/ProfilesEndpoints.cs index bb06d79..86483f7 100644 --- a/backend/src/Modules/Profiles/Presentation/Endpoints/ProfilesEndpoints.cs +++ b/backend/src/Modules/Profiles/Presentation/Endpoints/ProfilesEndpoints.cs @@ -1,4 +1,3 @@ -using Carter; using Knot.Shared.Kernel; using Knot.Modules.Profiles.Application.Profiles.Avatar; using Knot.Modules.Profiles.Application.Profiles.GetProfile; @@ -13,9 +12,9 @@ using Microsoft.AspNetCore.Mvc; namespace Knot.Modules.Profiles.Presentation.Endpoints; -public sealed class ProfilesEndpoints : ICarterModule +public static class ProfilesEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapProfilesEndpoints(this WebApplication app) { var group = app.MapGroup("api/profiles").RequireAuthorization(); diff --git a/backend/src/Modules/Relations/Knot.Modules.Relations.csproj b/backend/src/Modules/Relations/Knot.Modules.Relations.csproj index 4bbafee..f985fdc 100644 --- a/backend/src/Modules/Relations/Knot.Modules.Relations.csproj +++ b/backend/src/Modules/Relations/Knot.Modules.Relations.csproj @@ -13,7 +13,6 @@ - diff --git a/backend/src/Modules/Relations/Presentation/Endpoints/ContactsEndpoints.cs b/backend/src/Modules/Relations/Presentation/Endpoints/ContactsEndpoints.cs index 61cf836..83748b7 100644 --- a/backend/src/Modules/Relations/Presentation/Endpoints/ContactsEndpoints.cs +++ b/backend/src/Modules/Relations/Presentation/Endpoints/ContactsEndpoints.cs @@ -1,4 +1,3 @@ -using Carter; using Knot.Contracts.Relations.Domain; using Knot.Modules.Relations.Application.Contacts; using Knot.Shared.Infrastructure; @@ -12,9 +11,9 @@ using Microsoft.EntityFrameworkCore; namespace Knot.Modules.Relations.Presentation.Endpoints; -public sealed class ContactsEndpoints : ICarterModule +public static class ContactsEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapContactsEndpoints(this WebApplication app) { var group = app.MapGroup("api/contacts").RequireAuthorization(); diff --git a/backend/src/Modules/Settings/Knot.Modules.Settings.csproj b/backend/src/Modules/Settings/Knot.Modules.Settings.csproj index c585e72..a01475c 100644 --- a/backend/src/Modules/Settings/Knot.Modules.Settings.csproj +++ b/backend/src/Modules/Settings/Knot.Modules.Settings.csproj @@ -1,4 +1,4 @@ - + net10.0 enable @@ -9,7 +9,4 @@ - - - diff --git a/backend/src/Modules/Settings/Presentation/Endpoints/SettingsEndpoints.cs b/backend/src/Modules/Settings/Presentation/Endpoints/SettingsEndpoints.cs index 961865b..e8fd7f3 100644 --- a/backend/src/Modules/Settings/Presentation/Endpoints/SettingsEndpoints.cs +++ b/backend/src/Modules/Settings/Presentation/Endpoints/SettingsEndpoints.cs @@ -1,4 +1,3 @@ -using Carter; using Knot.Modules.Settings.Application.Settings.Queries; using Knot.Shared.Kernel; using MediatR; @@ -8,9 +7,9 @@ using Microsoft.AspNetCore.Routing; namespace Knot.Modules.Settings.Presentation.Endpoints; -public sealed class SettingsEndpoints : ICarterModule +public static class SettingsEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapSettingsEndpoints(this WebApplication app) { app.MapGet("api/config", async (ISender sender, CancellationToken ct) => { diff --git a/backend/src/Modules/Storage/Knot.Modules.Storage.csproj b/backend/src/Modules/Storage/Knot.Modules.Storage.csproj index bd98b1f..a89cc86 100644 --- a/backend/src/Modules/Storage/Knot.Modules.Storage.csproj +++ b/backend/src/Modules/Storage/Knot.Modules.Storage.csproj @@ -15,7 +15,6 @@ - diff --git a/backend/src/Modules/Storage/Presentation/Endpoints/FilesEndpoints.cs b/backend/src/Modules/Storage/Presentation/Endpoints/FilesEndpoints.cs index 6b76787..db44cf0 100644 --- a/backend/src/Modules/Storage/Presentation/Endpoints/FilesEndpoints.cs +++ b/backend/src/Modules/Storage/Presentation/Endpoints/FilesEndpoints.cs @@ -1,21 +1,19 @@ -using Carter; -using Microsoft.Extensions.Caching.Memory; +using System.Security.Cryptography; +using System.Text; +using Knot.Contracts.Settings.Application.Abstractions; +using Knot.Contracts.Settings.Application.DTOs; using Knot.Shared.Kernel.Storage; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Mvc; - -using Knot.Contracts.Settings.Application.Abstractions; -using Knot.Contracts.Settings.Application.DTOs; -using System.Text; -using System.Security.Cryptography; +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Caching.Memory; namespace Knot.Host.Presentation.Endpoints; -public sealed class FilesEndpoints : ICarterModule +public static class FilesEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapFilesEndpoints(this WebApplication app) { var group = app.MapGroup("api/files"); @@ -31,12 +29,12 @@ public sealed class FilesEndpoints : ICarterModule using var ms = new MemoryStream(); if (result.Stream.CanSeek) result.Stream.Position = 0; await result.Stream.CopyToAsync(ms, ct); - + cachedData = (ms.ToArray(), result.ContentType, result.FileName); - + var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromMinutes(30)); - + cache.Set(cacheKey, cachedData, cacheEntryOptions); result.Stream.Dispose(); } @@ -47,7 +45,7 @@ public sealed class FilesEndpoints : ICarterModule { return Results.File(outStream, cachedData.ContentType, fileDownloadName: cachedData.FileName, enableRangeProcessing: true); } - + return Results.File(outStream, cachedData.ContentType, enableRangeProcessing: true); } catch (Exception ex) @@ -64,12 +62,13 @@ public sealed class FilesEndpoints : ICarterModule // Формируем подписанный запрос к удаленному серверу var targetUrl = $"{domain.TrimEnd('/')}/api/federation/v1/proxy/{id}"; - + var request = new HttpRequestMessage(HttpMethod.Get, targetUrl); request.Headers.Add("X-Knot-Domain", settings.System.DomainUrl); - + // Генерируем подпись запроса своим приватным ключом - using(var rsa = RSA.Create()) { + using (var rsa = RSA.Create()) + { rsa.ImportPkcs8PrivateKey(Convert.FromBase64String(settings.Federation.PrivateKey!), out _); var dataToSign = Encoding.UTF8.GetBytes(id + settings.System.DomainUrl); var signature = Convert.ToBase64String(rsa.SignData(dataToSign, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1)); @@ -81,7 +80,7 @@ public sealed class FilesEndpoints : ICarterModule var remoteStream = await response.Content.ReadAsStreamAsync(ct); var contentType = response.Content.Headers.ContentType?.ToString() ?? "application/octet-stream"; - + return Results.Stream(remoteStream, contentType, enableRangeProcessing: true); }); } diff --git a/backend/src/Modules/Stories/Knot.Modules.Stories.csproj b/backend/src/Modules/Stories/Knot.Modules.Stories.csproj index 2851337..2778c4e 100644 --- a/backend/src/Modules/Stories/Knot.Modules.Stories.csproj +++ b/backend/src/Modules/Stories/Knot.Modules.Stories.csproj @@ -15,7 +15,6 @@ - diff --git a/backend/src/Modules/Stories/Presentation/Endpoints/StoriesEndpoints.cs b/backend/src/Modules/Stories/Presentation/Endpoints/StoriesEndpoints.cs index fab195f..3e2744c 100644 --- a/backend/src/Modules/Stories/Presentation/Endpoints/StoriesEndpoints.cs +++ b/backend/src/Modules/Stories/Presentation/Endpoints/StoriesEndpoints.cs @@ -1,16 +1,10 @@ -using Carter; using Knot.Modules.Stories.Application.DTOs; -using Knot.Modules.Stories.Application.Stories.Commands.AddStoryReaction; -using Knot.Modules.Stories.Application.Stories.Commands.AddStoryReply; using Knot.Modules.Stories.Application.Stories.Commands.CreateStory; using Knot.Modules.Stories.Application.Stories.Commands.DeleteStory; -using Knot.Modules.Stories.Application.Stories.Commands.RemoveStoryReaction; using Knot.Modules.Stories.Application.Stories.Commands.ViewStory; using Knot.Modules.Stories.Application.Stories.Queries.GetStories; -using Knot.Modules.Stories.Application.Stories.Queries.GetStoryReplies; using Knot.Modules.Stories.Application.Stories.Queries.GetStoryViewers; using Knot.Modules.Stories.Application.Stories.Queries.GetUserStories; -using Knot.Modules.Stories.Domain; using Knot.Shared.Kernel; using Knot.Shared.Kernel.Storage; using MediatR; @@ -21,9 +15,9 @@ using Microsoft.AspNetCore.Routing; namespace Knot.Modules.Stories.Presentation.Endpoints; -public sealed class StoriesEndpoints : ICarterModule +public static class StoriesEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapStoriesEndpoints(this WebApplication app) { var group = app.MapGroup("api/stories").RequireAuthorization(); @@ -76,30 +70,6 @@ public sealed class StoriesEndpoints : ICarterModule if (result.IsFailure) return result.Error.Code == "Unauthorized" ? Results.Forbid() : Results.NotFound(); return Results.Ok(result.Value); }); - - group.MapPost("{id:guid}/reaction", async (Guid id, [FromBody] AddStoryReactionRequest request, ISender sender, IUserContext userContext, CancellationToken ct) => - { - var result = await sender.Send(new AddStoryReactionCommand(userContext.UserId, id, request.Emoji), ct); - return result.IsSuccess ? Results.Ok(new { message = "Reaction added" }) : Results.NotFound(); - }); - - group.MapDelete("{id:guid}/reaction", async (Guid id, [FromBody] RemoveStoryReactionRequest request, ISender sender, IUserContext userContext, CancellationToken ct) => - { - var result = await sender.Send(new RemoveStoryReactionCommand(userContext.UserId, id, request.Emoji), ct); - return result.IsSuccess ? Results.Ok(new { message = "Reaction removed" }) : Results.NotFound(); - }); - - group.MapPost("{id:guid}/reply", async (Guid id, [FromBody] AddStoryReplyRequest request, ISender sender, IUserContext userContext, CancellationToken ct) => - { - var result = await sender.Send(new AddStoryReplyCommand(userContext.UserId, id, request.Content), ct); - return result.IsSuccess ? Results.Ok(new { message = "Reply added" }) : Results.NotFound(); - }); - - group.MapGet("{id:guid}/replies", async (Guid id, ISender sender, IUserContext userContext, CancellationToken ct) => - { - var result = await sender.Send(new GetStoryRepliesQuery(userContext.UserId, id), ct); - return result.IsSuccess ? Results.Ok(result.Value) : Results.NotFound(); - }); } } diff --git a/backend/src/Modules/TelegramImport/Knot.Modules.TelegramImport.csproj b/backend/src/Modules/TelegramImport/Knot.Modules.TelegramImport.csproj index 5ee3c84..ef65c7c 100644 --- a/backend/src/Modules/TelegramImport/Knot.Modules.TelegramImport.csproj +++ b/backend/src/Modules/TelegramImport/Knot.Modules.TelegramImport.csproj @@ -9,7 +9,6 @@ - diff --git a/backend/src/Modules/TelegramImport/Presentation/Endpoints/TelegramImportEndpoints.cs b/backend/src/Modules/TelegramImport/Presentation/Endpoints/TelegramImportEndpoints.cs index f135a3d..fc47191 100644 --- a/backend/src/Modules/TelegramImport/Presentation/Endpoints/TelegramImportEndpoints.cs +++ b/backend/src/Modules/TelegramImport/Presentation/Endpoints/TelegramImportEndpoints.cs @@ -1,18 +1,17 @@ -using Carter; -using Knot.Shared.Kernel; -using Knot.Modules.TelegramImport.Application.TelegramImport.DTOs; using Knot.Modules.TelegramImport.Application.TelegramImport; +using Knot.Modules.TelegramImport.Application.TelegramImport.DTOs; +using Knot.Shared.Kernel; using MediatR; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; namespace Knot.Modules.TelegramImport.Presentation.Endpoints; -public sealed class TelegramImportEndpoints : ICarterModule +public static class TelegramImportEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapTelegramImportEndpoints(this WebApplication app) { var group = app.MapGroup("api/import/telegram").RequireAuthorization(); diff --git a/backend/src/Modules/WebRtc/Knot.Modules.WebRtc.csproj b/backend/src/Modules/WebRtc/Knot.Modules.WebRtc.csproj index bff30b3..37dc67c 100644 --- a/backend/src/Modules/WebRtc/Knot.Modules.WebRtc.csproj +++ b/backend/src/Modules/WebRtc/Knot.Modules.WebRtc.csproj @@ -10,7 +10,6 @@ - diff --git a/backend/src/Modules/WebRtc/Presentation/Endpoints/WebRtcEndpoints.cs b/backend/src/Modules/WebRtc/Presentation/Endpoints/WebRtcEndpoints.cs index c0763c6..a8cfe3e 100644 --- a/backend/src/Modules/WebRtc/Presentation/Endpoints/WebRtcEndpoints.cs +++ b/backend/src/Modules/WebRtc/Presentation/Endpoints/WebRtcEndpoints.cs @@ -1,7 +1,6 @@ -using Carter; -using MediatR; -using Knot.Shared.Kernel; using Knot.Modules.WebRtc.Application.WebRtc.Queries; +using Knot.Shared.Kernel; +using MediatR; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; @@ -11,9 +10,9 @@ namespace Knot.Modules.WebRtc.Presentation.Endpoints; /// /// Endpoints for WebRTC signaling and ICE configuration /// -public sealed class WebRtcEndpoints : ICarterModule +public static class WebRtcEndpoints { - public void AddRoutes(IEndpointRouteBuilder app) + public static void MapWebRtcEndpoints(this WebApplication app) { var group = app.MapGroup("api/webrtc") .RequireAuthorization();