Code Monkey home page Code Monkey logo

eshop's Issues

Reconsider when EF schema migrations are applied

From @bricelam

Today, database schema migrations are applied as certain components start up. This is problematic when multiple components (or multiple instances of the same component) use the same database.

Currently, for example, Ordering.BackgroundTasks immediately begins querying the OrderingDB database. This continually fails while waiting for Ordering.API to create and migrate the database schema to the latest version.

Data seeding (#10) should also be done at the same time.

Domain events should be published utill there are no more left

Current implementation of eShop.Ordering.Infrastructure.MediatorExtension.DispatchDomainEventsAsync
will check tracked entities and publish all domain event those entices hold once, which triggers domain event handlers to handle published events.
However, in real world applications, domain event handlers might also cause new domain events generated, and in current implementation new created domain events will be ignored.

I wrote this implementation that will keep publishing created domain events from tracked entires recursively, utill there are no more left. Please consider.

static class MediatorExtension
{
    public static async Task DispatchDomainEventsAsync(this IMediator mediator, OrderingContext ctx)
    {
        bool remains = true;
        while(remains) {
            var publishedCount = await DispatchDomainEventsRecursivelyAsync(mediator, ctx);
            remains = publishedCount > 0;
        }
    }

    private static async Task<int> DispatchDomainEventsRecursivelyAsync(this IMediator mediator, OrderingContext ctx)
    {
        var domainEntities = ctx.ChangeTracker
            .Entries<Entity>()
            .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any());

        var domainEvents = domainEntities
            .SelectMany(x => x.Entity.DomainEvents)
            .ToList();
        int count = domainEvents.Count;

        domainEntities.ToList()
            .ForEach(entity => entity.Entity.ClearDomainEvents());
        
        foreach (var domainEvent in domainEvents)
            await mediator.Publish(domainEvent);
        
        return count;
    }
}

Would be happy to create the PR.

[WebToolsE2E][Aspire] The black area behind the shopping bag is too small, resulting in poor readability of the number of shopping bags.

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.9 P1 from build [34303.117.d17.9]
  3. Install latest 8.0 SDK: 8.0.100
  4. Apply NuGet Feeds
  5. Install Docker Desktop

REPRO STEPS

  1. In the VS, clone the eShop repository and open eShop.Web.slnf
  2. F5 / Ctrl-F5
  3. Click Endpoint for 'webapp'
  4. Log in to cart and add any item to cart
  5. Change the quantity to '8888' then click Update

ACTUAL

The black area is too small, resulting in poor readability of the number of shopping bags.
image

EXPECTED

image

Remove DDD boilerplate

From @bricelam:

It is the professional opinion of the EF team that the DDD patterns employed in the Ordering.API and related projects are of no value (and possibly even result in negative value) and can safely be removed for the sake of maintainability.

This includes, but is not limited to:

[WebToolsE2E][Aspire] When typing ‘Ctrl-C' to stop debugging eshop.web, I get some errors:“Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0] could not remove process's standard output file.”

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.9 P1 from build [34309.102.d17.9]
  3. Install latest 8.0 SDK: 8.0.100
  4. Apply NuGet Feeds
  5. Install Docker Desktop

REPRO STEPS

  1. In the VS, clone the eShop repository and open eShop.Web.slnf
  2. F5 / Ctrl-F5
  3. Enter "Ctrl-C" to stop debugging in the debug console

ACTUAL
fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
could not remove process's standard output file {"Controller": "usvc-dev.developer.microsoft.com/executable-reconciler", "Executable": {"name":"identity-api"}, "Reconciliation": 72, "State": "Running", "ExecutionID": "61", "path": "C:\Users\xxx\AppData\Local\Temp\identity-api_out_80dce640-5654-4d08-abc6-435287cc0eed", "error": "remove C:\Users\xxx\AppData\Local\Temp\identity-api_out_80dce640-5654-4d08-abc6-435287cc0eed: The process cannot access the file because it is being used by another process."}
image

EXPECTED
There are no errors in Debug Console.

[WebToolsE2E][Aspire] After running eshop.web solution, some error logs appear in structured logs: "An error occurred using the connection to database 'postgres' on server."

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.9 P1 from build [34303.117.d17.9]
  3. Install latest 8.0 SDK: 8.0.100
  4. Apply NuGet Feeds
  5. Install Docker Desktop

REPRO STEPS

  1. In the VS, clone the eShop repository and open eShop.Web.slnf
  2. F5 / Ctrl-F5
  3. There are some error logs 'an error occured using the connection to database 'postgres' on server' in Structured Logs

ACTUAL

Fatal error establishing database connection
An error occurred using the connection to database 'postgres' on server 'tcp://localhost:56882'.
image

EXPECTED

There are no errors in Structured Logs.

[WebToolsE2E][Aspire] Click the endpoint of the webapp in eshop dashboard and open the chatbot, the AI chat window is partially obscured.

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.9 P1 from build [34303.117.d17.9]
  3. Install latest 8.0 SDK: 8.0.100
  4. Apply NuGet Feeds
  5. Install Docker Desktop

REPRO STEPS

  1. In the VS, clone the eShop repository and open eShop.Web.slnf
  2. F5 / Ctrl-F5
  3. Click Endpoint for 'webapp' and then open AI chatbot

ACTUAL
The AI chat window is partially obscured
image

EXPECTED
image

The build failed

dotnet run --project src/eShop.AppHost/eShop.AppHost.csproj
Building...
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: The specified task executable "/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc" could not be run. System.ComponentModel.Win32Exception (13): An error occurred trying to start process '/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc' with working directory '/data/eShop/src/Basket.API'. Permission denied [/data/eShop/src/Basket.API/Basket.API.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [/data/eShop/src/Basket.API/Basket.API.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [/data/eShop/src/Basket.API/Basket.API.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/data/eShop/src/Basket.API/Basket.API.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.Execute() [/data/eShop/src/Basket.API/Basket.API.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: The specified task executable "/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc" could not be run. System.ComponentModel.Win32Exception (13): An error occurred trying to start process '/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc' with working directory '/data/eShop/src/WebApp'. Permission denied [/data/eShop/src/WebApp/WebApp.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [/data/eShop/src/WebApp/WebApp.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [/data/eShop/src/WebApp/WebApp.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/data/eShop/src/WebApp/WebApp.csproj]
/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.Execute() [/data/eShop/src/WebApp/WebApp.csproj]

The build failed. Fix the build errors and run again.

Make URLs pretty

  • Make URLs lowercase
  • Simplify some of the catalog URL patterns

Scalability/load tests

Would be interesting to see how much traffic we can handle with this architecture and where things start to break down.

It's not possible to run with not the .NET 8.0.100

I installed the latest version of .net and tried to run this application, but it requires a preview version of .NET 8
To solve this, I changed global.json and chose version 8.0.100
Here's the global.json file

{
  "sdk": {
    "version": "8.0.100",
    "rollForward": "latestPatch",
    "allowPrerelease": false
  }
}

[WebToolsE2E][Aspire] After running the eshop.web solution, some rabbitMQ error logs appeared in the structured logs: "Unexpected connection closure: AMQP close-reason."

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.9 P1 from build [34309.102.d17.9]
  3. Install latest 8.0 SDK: 8.0.100
  4. Apply NuGet Feeds
  5. Install Docker Desktop

REPRO STEPS

  1. In the VS, clone the eShop repository and open eShop.Web.slnf
  2. F5 / Ctrl-F5
  3. There are some rabbitMQ error logs 'Unexpected connection closure: AMQP close-reason' in Structured Logs

ACTUAL
Unexpected connection closure: AMQP close-reason, initiated by Library, code=0, text='End of stream', classId=0, methodId=0, cause=System.IO.EndOfStreamException: Reached the end of the stream. Possible authentication failure.
at RabbitMQ.Client.Impl.InboundFrame.ReadFrom(Stream reader, Byte[] frameHeaderBuffer, ArrayPool`1 pool, UInt32 maxMessageSize)
at RabbitMQ.Client.Impl.SocketFrameHandler.ReadFrame()
at RabbitMQ.Client.Framing.Impl.Connection.MainLoopIteration()
at RabbitMQ.Client.Framing.Impl.Connection.MainLoop()
image

EXPECTED
There are no errors in Structured Logs.

BasketService can be inconsistent about whether user is authenticated (or at least can disagree with WebApp)

From @SteveSandersonMS

I'm not sure how to repro this but have seen it twice now. You can have a state where the user is logged in and has a non-expired auth token, so WebApp shows you as being logged in, but:

  • Calls to basketClient.GetBasketAsync succeed
  • Calls to basketClient.UpdateBasketAsync fail, reporting RpcException: Status(StatusCode="Unauthenticated", Detail="The caller is not authenticated.")

You can get out of this state by logging out and then back in. But of course we don't want this to occur in the first place.

I suspect the issue is one of two things:

  • Either the WebApp and BasketService disagree about the validity of the auth token, and GetBasketAsync simply doesn't enforce auth at all (perhaps it just returns an empty basket if the user isn't authenticated).
    • If this is the issue, maybe WebApp is incorrectly configured and isn't validating the auth tokens as strictly as it should be. No idea in what way the config might be wrong though - it was taken from the older MVC app.
  • Or, BasketService is internally inconsistent about whether an auth token is valid

Here's what shows up to the user when trying to add an item to the cart in this state:

image

[Big Rock] Fix tests in eShop repo

  • Address failures with Catalog.UnitTests (action: delete these)
  • Address failures with Catalog.FunctionalTests (action: figure out how to use Aspire components/testconstainers in testing)
  • Address failures with Ordering.FunctionalTests (action: figure out how to use Aspire components/testcontainers in testing)
  • Address failures with Ordering.UnitTests (action: upgrade to test minimal API)
  • Address failures with Basket.UnitTests (action: need to be updated to unit test gRPC service)
  • Address failures with Basket.FunctionalTests (action: figure out how to use Aspire components/testcontainers in testing)
  • Address failures in Application.FunctionalTests (action: figure out if functional test setup used for other tests applies here)

Share model classes between projects

From @ReubenBond:

Currently, each project which needs a representation of an Order has its own representation. This makes refactoring complex and it leads to inconsistencies. Instead, we should have one or more shared projects which define the domain model.

If we see a benefit to having a mapped type in some cases (eg, types used in Blazor view models), we should do so, but we should simplify where we can.

Share integration events between projects

From @ReubenBond:

Currently, there are many integration events which have duplicated representations across projects, which makes the complex Order processing flow even more complex because developers cannot use tooling to find usages of the integration event types.

Instead, let's use one or more shared projects to describe these events so that FindAllReferences/etc work.

Checkout process deletes the basket twice

This isn't a bug (hopefully) but the checkout process currently deletes the basket twice. Once via the webapp and once via the basket API once the order process has started.

image

[WebToolsE2E][Aspire] Registering a new webhook in eshop dashboard failed: "Error 400 (Bad Request) when calling the Webhooks API (POST http://webhooks-api/api/v1/webhooks) with GrantUrl."

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.9 P1 from build [34303.117.d17.9]
  3. Install latest 8.0 SDK: 8.0.100
  4. Apply NuGet Feeds
  5. Install Docker Desktop

REPRO STEPS

  1. In the VS, clone the eShop repository and open eShop.Web.slnf
  2. F5 / Ctrl-F5
  3. Click Endpoint for 'webhooksclient'
  4. Navigate to webhook registration page and click 'send'

ACTUAL

Error 400 (Bad Request) when calling the Webhooks API (POST http://webhooks-api/api/v1/webhooks) with GrantUrl: http://localhost:5228/check)

Data sent to the webhooks API was {"Url":"http://localhost:5228/webhook-received","Token":"6168DB8D-DC58-4094-AF24-483278923590","Event":"OrderPaid","GrantUrl":"http://localhost:5228/check"}
image

EXPECTED

Registering a new webhook in eshop dashboard successfully.

Pick a consistent name for the shopping cart/bag/basket

From @danroth27:

We should pick a consistent name for the shopping cart/bag/basket.

Currently we have Basket.API, Cart.razor, and user facing text that says, "Your shopping bag".

From @SteveSandersonMS:

The user-facing text is all consistent on "shopping bag".

In the code, WebApp uses the term Cart, and the underlying service uses the term Basket. So those are indeed inconsistent, but in a way that is sort of valid - nothing strictly requires them to use the same term even though it would be better if they did.

Turn on nullable reference types

  • Basket.API
  • Catalog.API
  • ClientApp
  • EventBus
  • EventBusRabbitMQ
  • HybridApp
  • Identity.API
  • IntegrationEventLogEF
  • Ordering.API
  • Ordering.BackgroundTasks
  • Ordering.Domain
  • Ordering.Infrastructure
  • Payment.API
  • Shared
  • WebApp
  • WebAppComponents
  • WebClient
  • Webhooks.API
  • eShop.AppHost
  • eShop.ServiceDefaults

Accessibility pass

We need to do an accessibility pass. @3lcarry will be handling this.

A couple of known issues:

  • Missing tooltips when hovering over the user/cart icons.
  • Footer text is blocked by banner image when looking at the identity page.

Add items to cart without logging in

Every online store I've used allows anonymously adding items to a shopping cart and then prompts for login during check out. Unusually, eshop requires logging in before adding items to the cart. I think the demo should follow the usual rules for websites.

Was this done for technical reasons? i.e. tracking cart items against an account, or to show off requiring auth in the cart APIs

Update .NET MAUI app to use new endpoints

Right now the .NET MAUI app only uses fake mock data. This needs to be updated to use the new endpoints.

Working with @michaelstonis

  • Update design and any performance issues
  • Update to latest .NET 8
  • Use new endpoints
  • Update Mobile BFF with any new apis needed
  • Ability to run with or without auth

Assets file 'C:\Users\User\Downloads\eShop-main\src\WebApp\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. WebApp C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 266

few error when load the project. try to acces nuget seem not authorise.
other error Assets file 'C:\Users\User\Downloads\eShop-main\src\EventBusRabbitMQ\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.
EventBusRabbitMQ C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 266

[WebToolsE2E][Aspire] Clicking the "webhooksclient" endpoint and then logging in to order management failed: "invalid_request".

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.9 P1 from build [34310.174.d17.9]
  3. Install latest 8.0 SDK: 8.0.100
  4. Apply NuGet Feeds
  5. Install Docker Desktop

REPRO STEPS

  1. In the VS, clone the eShop repository and open eShop.Web.slnf
  2. F5 / Ctrl-F5, maybe you will encounter this issue #66
  3. Click Endpoint for 'webhooksclient'
  4. Click 'Log in' button

ACTUAL
Sorry, there was an error: invalid_request
Invalid redirect_uri
Animation

EXPECTED

Login successful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.