diff --git a/.gitignore b/.gitignore index 31c7257..b299ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .tasks/ .agile/ +**/bin/ +**/obj/ diff --git a/Customer.Orders.Bff.slnx b/Customer.Orders.Bff.slnx new file mode 100644 index 0000000..d4b6450 --- /dev/null +++ b/Customer.Orders.Bff.slnx @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..7ebffcf --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,10 @@ + + + AgileWebs + AgileWebs + git + http://192.168.68.156:3000/AgileWebs/customer-orders-bff + http://192.168.68.156:3000/AgileWebs/customer-orders-bff + false + + diff --git a/src/Customer.Orders.Bff.Application/Adapters/DefaultCustomerOrdersServiceClient.cs b/src/Customer.Orders.Bff.Application/Adapters/DefaultCustomerOrdersServiceClient.cs new file mode 100644 index 0000000..beac07f --- /dev/null +++ b/src/Customer.Orders.Bff.Application/Adapters/DefaultCustomerOrdersServiceClient.cs @@ -0,0 +1,12 @@ +using Customer.Orders.Bff.Contracts.Requests; +using Customer.Orders.Bff.Contracts.Responses; + +namespace Customer.Orders.Bff.Application.Adapters; + +public sealed class DefaultCustomerOrdersServiceClient : ICustomerOrdersServiceClient +{ + public Task FetchAsync(GetCustomerOrderStatusRequest request, CancellationToken cancellationToken) + { + return Task.FromResult(new GetCustomerOrderStatusResponse(request.ContextId, "Default service-backed response.")); + } +} diff --git a/src/Customer.Orders.Bff.Application/Adapters/ICustomerOrdersServiceClient.cs b/src/Customer.Orders.Bff.Application/Adapters/ICustomerOrdersServiceClient.cs new file mode 100644 index 0000000..cf9477a --- /dev/null +++ b/src/Customer.Orders.Bff.Application/Adapters/ICustomerOrdersServiceClient.cs @@ -0,0 +1,9 @@ +using Customer.Orders.Bff.Contracts.Requests; +using Customer.Orders.Bff.Contracts.Responses; + +namespace Customer.Orders.Bff.Application.Adapters; + +public interface ICustomerOrdersServiceClient +{ + Task FetchAsync(GetCustomerOrderStatusRequest request, CancellationToken cancellationToken); +} diff --git a/src/Customer.Orders.Bff.Application/Customer.Orders.Bff.Application.csproj b/src/Customer.Orders.Bff.Application/Customer.Orders.Bff.Application.csproj new file mode 100644 index 0000000..a38b8a2 --- /dev/null +++ b/src/Customer.Orders.Bff.Application/Customer.Orders.Bff.Application.csproj @@ -0,0 +1,12 @@ + + + + net10.0 + enable + enable + + + + + + diff --git a/src/Customer.Orders.Bff.Application/Handlers/GetCustomerOrderStatusHandler.cs b/src/Customer.Orders.Bff.Application/Handlers/GetCustomerOrderStatusHandler.cs new file mode 100644 index 0000000..48de8b9 --- /dev/null +++ b/src/Customer.Orders.Bff.Application/Handlers/GetCustomerOrderStatusHandler.cs @@ -0,0 +1,13 @@ +using Customer.Orders.Bff.Application.Adapters; +using Customer.Orders.Bff.Contracts.Requests; +using Customer.Orders.Bff.Contracts.Responses; + +namespace Customer.Orders.Bff.Application.Handlers; + +public sealed class GetCustomerOrderStatusHandler(ICustomerOrdersServiceClient serviceClient) : IGetCustomerOrderStatusHandler +{ + public Task HandleAsync(GetCustomerOrderStatusRequest request, CancellationToken cancellationToken) + { + return serviceClient.FetchAsync(request, cancellationToken); + } +} diff --git a/src/Customer.Orders.Bff.Application/Handlers/IGetCustomerOrderStatusHandler.cs b/src/Customer.Orders.Bff.Application/Handlers/IGetCustomerOrderStatusHandler.cs new file mode 100644 index 0000000..348bb12 --- /dev/null +++ b/src/Customer.Orders.Bff.Application/Handlers/IGetCustomerOrderStatusHandler.cs @@ -0,0 +1,9 @@ +using Customer.Orders.Bff.Contracts.Requests; +using Customer.Orders.Bff.Contracts.Responses; + +namespace Customer.Orders.Bff.Application.Handlers; + +public interface IGetCustomerOrderStatusHandler +{ + Task HandleAsync(GetCustomerOrderStatusRequest request, CancellationToken cancellationToken); +} diff --git a/src/Customer.Orders.Bff.Contracts/Customer.Orders.Bff.Contracts.csproj b/src/Customer.Orders.Bff.Contracts/Customer.Orders.Bff.Contracts.csproj new file mode 100644 index 0000000..b760144 --- /dev/null +++ b/src/Customer.Orders.Bff.Contracts/Customer.Orders.Bff.Contracts.csproj @@ -0,0 +1,9 @@ + + + + net10.0 + enable + enable + + + diff --git a/src/Customer.Orders.Bff.Contracts/Requests/GetCustomerOrderStatusRequest.cs b/src/Customer.Orders.Bff.Contracts/Requests/GetCustomerOrderStatusRequest.cs new file mode 100644 index 0000000..0700596 --- /dev/null +++ b/src/Customer.Orders.Bff.Contracts/Requests/GetCustomerOrderStatusRequest.cs @@ -0,0 +1,3 @@ +namespace Customer.Orders.Bff.Contracts.Requests; + +public sealed record GetCustomerOrderStatusRequest(string ContextId); diff --git a/src/Customer.Orders.Bff.Contracts/Responses/GetCustomerOrderStatusResponse.cs b/src/Customer.Orders.Bff.Contracts/Responses/GetCustomerOrderStatusResponse.cs new file mode 100644 index 0000000..e01c065 --- /dev/null +++ b/src/Customer.Orders.Bff.Contracts/Responses/GetCustomerOrderStatusResponse.cs @@ -0,0 +1,3 @@ +namespace Customer.Orders.Bff.Contracts.Responses; + +public sealed record GetCustomerOrderStatusResponse(string ContextId, string Summary); diff --git a/src/Customer.Orders.Bff.Rest/Customer.Orders.Bff.Rest.csproj b/src/Customer.Orders.Bff.Rest/Customer.Orders.Bff.Rest.csproj new file mode 100644 index 0000000..45307d1 --- /dev/null +++ b/src/Customer.Orders.Bff.Rest/Customer.Orders.Bff.Rest.csproj @@ -0,0 +1,13 @@ + + + + net10.0 + enable + enable + + + + + + + diff --git a/src/Customer.Orders.Bff.Rest/Program.cs b/src/Customer.Orders.Bff.Rest/Program.cs new file mode 100644 index 0000000..be7e8fb --- /dev/null +++ b/src/Customer.Orders.Bff.Rest/Program.cs @@ -0,0 +1,17 @@ +using Customer.Orders.Bff.Application.Adapters; +using Customer.Orders.Bff.Application.Handlers; +using Customer.Orders.Bff.Contracts.Requests; + +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + +var app = builder.Build(); + +app.MapGet("/api/customer/orders/status", async (string contextId, IGetCustomerOrderStatusHandler handler, CancellationToken ct) => +{ + var request = new GetCustomerOrderStatusRequest(contextId); + return Results.Ok(await handler.HandleAsync(request, ct)); +}); + +app.Run(); diff --git a/src/Customer.Orders.Bff.Rest/Properties/launchSettings.json b/src/Customer.Orders.Bff.Rest/Properties/launchSettings.json new file mode 100644 index 0000000..c55f6a2 --- /dev/null +++ b/src/Customer.Orders.Bff.Rest/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:0", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:0;http://localhost:0", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Customer.Orders.Bff.Rest/appsettings.Development.json b/src/Customer.Orders.Bff.Rest/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/Customer.Orders.Bff.Rest/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/Customer.Orders.Bff.Rest/appsettings.json b/src/Customer.Orders.Bff.Rest/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/Customer.Orders.Bff.Rest/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}