Your First Service

A Kanject service is just an ASP.NET Core app with extension methods. Here's a minimal Program.cs that boots with DynamoDB, Parameter Store, and Lambda hosting wired up:

csharp
using Kanject.Core.Adapter.Extensions;
using Kanject.Core.ApiV2.Extensions;
using Kanject.Core.NoSqlDatabase.Provider.DynamoDbV2.Extensions;

var builder = WebApplication.CreateBuilder(args);

// 1. Pull config from appsettings + AWS Parameter Store
builder.AddDefaultAppSettings();
builder.AddAwsSystemManagerParameterStore();

// 2. Register Kanject services via clean extension methods
builder.Services.AddDefaultAppServices();
builder.Services.AddDynamoNoSqlDatabase(options =>
{
    options.Namespace = appSettings.DatabaseNamespace;
    options.AwsRegion = appSettings.AwsRegion;
});

// 3. Lambda-ready by default — no separate host needed
builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi);

var app = builder.Build();

app.UseCoreExceptionHandlerMiddleware();
app.UseDefaultAppCors(builder.Configuration);
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();

What you get out of the box

  • Environment-aware configappsettings.Production.json, appsettings.Staging.json, and Parameter Store overrides layer automatically.
  • Exception handling middleware — consistent JSON error responses across every service.
  • CORS & warm-up endpointsUseAdapterPing() keeps Lambdas warm.
  • Lambda or Kestrel — the same code runs locally and in production.