MachinaXX.Chassis
0.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MachinaXX.Chassis --version 0.0.1
NuGet\Install-Package MachinaXX.Chassis -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MachinaXX.Chassis" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MachinaXX.Chassis" Version="0.0.1" />
<PackageReference Include="MachinaXX.Chassis" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MachinaXX.Chassis --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MachinaXX.Chassis, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=MachinaXX.Chassis&version=0.0.1
#tool nuget:?package=MachinaXX.Chassis&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MachinaXX.Chassis
A core library for building standardized ASP.NET Core APIs with common patterns and configurations.
Installation
dotnet add package MachinaXX.Chassis
Quick Start
The simplest way to use the library is with the CreateStandardApi
extension method:
using MachinaXX.API.Builder;
var app = args.CreateStandardApi();
app.Run();
This creates an API with:
- JWT authentication
- Swagger documentation
- CORS configuration
- Standard endpoints (/health, /version)
- Common middleware
Customizing Your API
Adding Custom Services
var app = args.CreateStandardApi(
configureBuilder: builder =>
{
// Register your services
builder.Builder.Services.AddSingleton<IMyService, MyService>();
// Customize auth settings
builder.AddAuth(options =>
{
options.ConfigureAuthorization = auth =>
{
auth.AddPolicy("MyCustomPolicy", policy =>
policy.RequireRole("SpecialRole"));
};
});
});
Adding Custom Routes and Endpoints
var app = args.CreateStandardApi(
configureApp: app =>
{
// Add custom routes
app.MapGet("/api/custom", () => "My custom endpoint")
.RequireAuthorization("APIUser");
// Or use extension method to organize routes
app.ConfigureMyFeatureRoutes();
});
Using Vertical Slice Architecture
The library is designed to work well with vertical slice architecture:
// Register services from specific assemblies
builder.AddVerticalServices(typeof(MyFeature), typeof(AnotherFeature));
// When using Carter for endpoint organization
app.MapCarter();
Database Access
// Register the data access service
builder.Builder.Services.AddSingleton<ISqlDataAccess, SqlDataAccess>();
// Inject and use in your services
public class MyService
{
private readonly ISqlDataAccess _db;
public MyService(ISqlDataAccess db)
{
_db = db;
}
public async Task<IEnumerable<MyEntity>> GetAllAsync()
{
return await _db.QueryAsync<MyEntity>("SELECT * FROM MyEntities");
}
}
Database Migrations
// Add the migration service
builder.Builder.Services.AddMigrations(
typeof(MyFeature).Assembly, // Assembly containing migration scripts
typeof(AnotherFeature).Assembly);
Customizing Core Components
If you need more control, you can use the ApiBuilder
directly:
var builder = new ApiBuilder(args);
// Add only what you need
builder
.AddAuth()
.AddSwagger()
.AddCors(options =>
{
options.AllowAnyOrigin = true;
options.AllowCredentials = true;
})
.AddVerticalServices(typeof(Program));
// Build and configure the app
var app = builder.Build();
// Configure middleware
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Run();
Publishing to NuGet
- Update version in the
.csproj
file - Build the package:
dotnet pack -c Release
- Push to NuGet:
dotnet nuget push bin/Release/MachinaXX.API.{version}.nupkg --api-key {your-api-key} --source https://api.nuget.org/v3/index.json
Versioning Strategy
This library follows Semantic Versioning:
- MAJOR version for incompatible API changes
- MINOR version for backward-compatible functionality
- PATCH version for backward-compatible bug fixes
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
- MechanaXAccessAPI (>= 1.1.3)
- MediatR (>= 12.5.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 9.0.5)
- Microsoft.Data.SqlClient (>= 6.0.2)
- Swashbuckle.AspNetCore (>= 8.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.