Provides a default set of APIs for building Brighten .NET Core microservices and web server applications
$ dotnet add package OakPeak.CoreOakPeak.Core is a powerful framework for building enterprise-grade microservices and web applications in .NET. It provides a comprehensive set of APIs, tools, and utilities to streamline your development process and enhance productivity.
Install the package using NuGet Package Manager or by executing the following command in the Package Manager Console:
Install-Package OakPeak.Core
For specific .NET versions:
# For .NET 6
Install-Package OakPeak.Core -Version 6.0.2
# For .NET 8
Install-Package OakPeak.Core -Version 8.0.6
# For .NET 9
Install-Package OakPeak.Core -Version 9.0.1
OakPeak.Core follows a multi-layered architecture:
OakPeak.Core includes several middleware components for cross-cutting concerns:
Multiple authentication methods are supported:
The framework includes built-in multi-tenancy capabilities:
Add OakPeak.Core to your ASP.NET Core application in Program.cs or Startup.cs:
// Add services
services.AddOakPeakCore(Configuration);
// Configure middleware
app.UseOakPeak();
Configure OakPeak.Core in your appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=...;Database=...;User Id=...;Password=...;"
},
"AppSettings": {
"EnableSwagger": true,
"HealthBaseUrl": "https://your-api-base-url.com"
},
"JwtIssuerOptions": {
"Issuer": "your-issuer",
"Audience": "your-audience",
"Subject": "your-subject",
"ValidFor": "24:00:00",
"Key": "your-secret-key-with-at-least-16-characters"
},
"EmailConfiguration": {
"Provider": "smtp",
"SmtpServer": "smtp.example.com",
"SmtpPort": 587,
"SmtpUsername": "user@example.com",
"SmtpPassword": "password",
"FromEmail": "noreply@example.com",
"UseSsl": true,
"Title": "Your Application Name",
"TemplateFile": "email-template.html"
}
}
Configure authentication in your application:
services.AddAuthentication(options => {
options.JwtIssuerOptions = new JwtIssuerOptions {
Issuer = Configuration["JwtIssuerOptions:Issuer"],
Audience = Configuration["JwtIssuerOptions:Audience"],
Subject = Configuration["JwtIssuerOptions:Subject"],
ValidFor = Configuration.GetValue<TimeSpan>("JwtIssuerOptions:ValidFor"),
Key = Configuration["JwtIssuerOptions:Key"],
};
});
Create scheduled tasks by implementing the IScheduledTask interface:
public class MyScheduledTask : BaseSchedulerTask
{
public override string Schedule => "0 */12 * * *"; // Cron expression
public override async Task DoWork()
{
// Task implementation
await Task.CompletedTask;
}
}
Register scheduled tasks:
services.AddScheduler((sender, args) => {
Console.Write(args.Exception.Message);
args.SetObserved();
});
services.AddSingleton<IScheduledTask, MyScheduledTask>();
Send emails using the notification service:
public class MyService
{
private readonly INotificationService _notificationService;
public MyService(INotificationService notificationService)
{
_notificationService = notificationService;
}
public async Task SendNotification()
{
await _notificationService.CreateAndSendHtmlEmail(
"recipient@example.com",
"Recipient Name",
"Email Subject",
"<p>Email body content</p>"
);
}
}
Use the data provider for database operations:
public class MyRepository
{
private readonly IDataProvider _dataProvider;
public MyRepository(IDataProvider dataProvider)
{
_dataProvider = dataProvider;
}
public IEnumerable<MyEntity> GetItems()
{
return _dataProvider.ExecuteReader("GetItems").FillCollection<MyEntity>();
}
}
OakPeak.Core includes Azure DevOps pipeline configurations for different .NET versions:
azure-pipelines.yml - Main pipeline for .NET 5azure-pipelines-NET6.yml - Pipeline for .NET 6azure-pipelines-NET8.yml - Pipeline for .NET 8These pipelines automate the build, test, and deployment processes for your applications.
OakPeak.Core integrates with Swagger/OpenAPI for API documentation. Enable it in your application:
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Your API", Version = "v1" });
c.EnableAnnotations();
});
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Your API v1"));
This project is licensed under the MIT License.
For issues, questions, or contributions, please contact us or open an issue on the repository.
OakPeak.Core is developed and maintained by Brighten Consulting.
© 2025 Brighten Consulting. All rights reserved.
This documentation is subject to change as the framework evolves. Always refer to the latest version for the most up-to-date information.