Reusable library for building clean, decoupled, and resilient APIs on .NET 8.
This package provides:
- Result modeling (
Result,SuccessResult,FailureResult) - Error wrappers (
BusinessRuleException,ErrorList) - Clean Architecture interfaces (
IInteractor,IPresenter,IResponse, etc.) - Centralized HTTP client (
HttpApiClient) - Logging extensions for Serilog + Seq
Install from NuGet:
dotnet add package Raptor.CommonOr add to your .csproj:
<PackageReference Include="Raptor.Common" Version="x.y.z" />Replace x.y.z with the latest version from NuGet.
- .NET 8 SDK (net8.0)
- Compatible with ASP.NET Core, domain libraries, and microservices
The library now lives at Common/ (previous nested paths were flattened).
Common/ core library
CleanArch/ clean architecture abstractions
Infra/HttpApi/ HTTP API client and responses
Logging/ Serilog + Seq extensions
Users/ sample user domain helpers
Common.Tests/ tests
Common.sln solution
Common/version version source for packaging
using Common;
Result<string> ok = Result.OK("All good");
Result<string> error = Result.Fail<string>("Something went wrong");using Common;
using Common.CleanArch;
public class GetUserInteractor : IResultInteractor<GetUserRequest, UserDto>
{
public Task<Result<UserDto>> Handle(GetUserRequest request, CancellationToken cancellationToken)
{
if (request.Id <= 0)
return Task.FromResult(Result.Fail<UserDto>("Invalid ID"));
var user = new UserDto { Id = request.Id, Name = "Example" };
return Task.FromResult(Result.OK(user));
}
}using Common.Infra.HttpApi;
var client = new HttpApiClient("https://api.example.com/");
var response = await client.GetAsync<MyResponse>("endpoint");appsettings.json:
"CustomLogging": {
"Project": "MyApiProject",
"SeqUri": "http://localhost:5341",
"LogEventLevel": "Information"
}Registration:
using Common.Logging;
builder.Services.AddLoggingServices(configuration);- PackageId:
Raptor.Common - Version source:
Common/version(used byCommon/Common.csproj) - Recommended tags:
vX.Y.Z(matching the NuGet package version)
- Update
Common/versionandCHANGELOG.md. - Run
dotnet test Common.sln. - Run
dotnet pack Common/Common.csproj -c Release. - Tag the commit:
git tag vX.Y.Z. - Push branch and tags.
main: stable, published codedevelop: integration branchfeature/*: new workfix/*orhotfix/*: urgent fixeslegacy/*: legacy snapshots (for examplelegacy/common-legacy)- Release tags:
vX.Y.Z
This is an internal package. Issues and PRs are welcome for improvements.
MIT (per package metadata).