Refactor CORS config; add architectural commentary
Refactored CORS setup to be environment-aware, restricting origins in production and relaxing in development. Added extensive comments and discussion on service and repository layer design, including clean architecture best practices and CQRS/MediatR considerations. No changes to business logic; documentation and intent clarified for maintainers.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using DbFirst.Domain.Entities;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
|
||||
namespace DbFirst.Domain.Repositories;
|
||||
|
||||
@@ -11,6 +12,12 @@ A generic Repository<T> isn’t really worthwhile here:
|
||||
• Operations aren’t symmetric (separate procs for insert/update/delete with output handling and reload), so a one-size-fits-all CRUD pattern doesn’t fit well.
|
||||
• Better to keep the specialized repo.If you want reuse, extract small helpers (e.g., for proc calls/output parameters/reload) instead of forcing a generic repository. */
|
||||
|
||||
|
||||
/* Hakan's Response:
|
||||
* I think it still makes sense. An execute SQL method can be added to repository. The relevant SQL can be executed in the application layer.
|
||||
* Because the application layer is no longer dependent on a method like CreateAsync. It is now directly dependent on that procedure.
|
||||
*/
|
||||
|
||||
// TODO: move to application layer as a part of clean architecture
|
||||
|
||||
/* Copilot's Response:
|
||||
@@ -22,6 +29,12 @@ A generic Repository<T> isn’t really worthwhile here:
|
||||
Con: If Domain logic needs repos, it would depend on Application, weakening the layer separation.
|
||||
Recommendation: Keep the interface in Domain. It’s conventional, clean, and avoids a Domain -> Application dependency. Implementation stays in Infrastructure. */
|
||||
|
||||
/* Hakan's Response:
|
||||
* I don't think there's any point in keeping repository interfaces in the domain layer. These interfaces will be used in the application layer, not the domain layer.
|
||||
* Furthermore, this is how they are used in the most popular clean architecture pattern.
|
||||
* See: https://github.com/jasontaylordev/CleanArchitecture/blob/main/src/Infrastructure/Identity/IdentityService.cs
|
||||
*/
|
||||
|
||||
public interface ICatalogRepository
|
||||
{
|
||||
Task<List<VwmyCatalog>> GetAllAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
Reference in New Issue
Block a user