Base solution for your next web application
Open Closed

Consume third party APIs from main application #12178


User avatar
0
Loizos created

Version 13.0.0, Angular 17, .NET 8

Hi Support,

Please advise on how to approach below case.

We have some third party APIs we have to call throughout our main ASP.NET zero application, however requires addition of NuGet packages, authentication keys, client certificates, etc.. so I wouldn't like to tight ASP.NET zero by just creating a domain service under .Core project and add all these extra requirements...

What is the best approach to handle this?

Do I have to create separate project (logical separation) inside the same solution to handle all this new functionality? If yes what would be the connection/references with the other projects?

Do I have to create a standalone API (physical separation) that will handle this functionality? In that case how do I consume it through my ASP.NET zero application so that to use same authentication/authorization?

Thank you in advance!

Loizos


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Loizos

    I think there is no need to create separate project for this. You can create an interface and call it inside your application service or whenever you need to execute this code block.

    Then, you can create its implementation on the Web layer or application layer depending on your needs. Currently, it seems like Web layer is more appropriate.

  • User Avatar
    0
    Loizos created

    Hi @ismcagdas

    So which project one exactly is the Web layer? Do you mean the ...Web.Core? Can you elaborate more on this why is it better than application layer?

    Also please have in mind that we are going to have some business logic inside this code and also maybe an implementation of a factory pattern so that to instantiate the correct remote/third party API call each time. Isn't that goes to domain layer? That's why the confusion.

    Loizos

  • User Avatar
    0
    Loizos created

    Hi @ismcagdas

    Any update on this?

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Loizos

    Sorry for my late reply.

    I mean, Web.Core or Web, both works. You can place your business logic implementation in the Domain layer. You can inject any domain service into the Controllers or AppServices usde in the Web layer.

    It is hard to offer something without seeing your code but I feel like this is a bit outside of the scope of AspNet Zero support. However, if you can send a sample code block to [email protected], we can try to provide a better suggestion.

    Thanks,

  • User Avatar
    0
    Loizos created

    Hi @ismcagdas

    Thanks for the reply!

    I am just looking for the way to create a new module (project) in order to have all third party APIs implementation there (including many third party libraries) and not to tight the domain layer, hence be able to update asp.net zero easily as well.

    Can I create this new module and add reference to .Core (domain) library? Is there any sample code on how to create new module?

    Thanks, Loizos

  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi Loizos

    This blog post can help you with your request.

  • User Avatar
    0
    Loizos created

    Hi @oguzhanagir

    Thank you!