IPG 1.0.5
dotnet add package IPG --version 1.0.5
NuGet\Install-Package IPG -Version 1.0.5
<PackageReference Include="IPG" Version="1.0.5" />
<PackageVersion Include="IPG" Version="1.0.5" />
<PackageReference Include="IPG" />
paket add IPG --version 1.0.5
#r "nuget: IPG, 1.0.5"
#:package IPG@1.0.5
#addin nuget:?package=IPG&version=1.0.5
#tool nuget:?package=IPG&version=1.0.5
IPG - .NET 8 Common Library
A comprehensive .NET 8 library providing common services and utilities for building ASP.NET Core applications quickly.
Features
✅ Dual Logging - Serilog + Application Insights support ✅ Multiple Database Support - MySQL, PostgreSQL, Supabase (use together!) ✅ Supabase Integration - Database, Auth, and Storage ✅ Entity Framework Core - MySQL & PostgreSQL with auto-retry ✅ Azure Communication Services - Enterprise Email & SMS ✅ Google Cloud Storage - File upload/download/delete ✅ Background Jobs - Hangfire with MySQL/PostgreSQL ✅ API Versioning - Built-in URL segment versioning ✅ Swagger/OpenAPI - Auto-generated documentation ✅ Database Migrations - DbUp integration ✅ Exception Handling - Global exception handler ✅ Auto Service Registration - Convention-based DI
Quick Start
1. Install Package
Option A: Install from NuGet (Recommended)
dotnet add package IPG
Or via Package Manager Console in Visual Studio:
Install-Package IPG
Option B: Add Project Reference
Add the IPG project reference to your .csproj:
<ItemGroup>
<ProjectReference Include="..\IPG\IPG.csproj" />
</ItemGroup>
2. Update Program.cs
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Use IPG Standard - Auto-registers all services
// Note: General.Configuration is automatically initialized from appsettings.json
builder.UseIPGStandard(new[] { Assembly.GetExecutingAssembly() });
var app = builder.Build();
// Use IPG Standard middleware
app.UseIPGStandard();
app.MapControllers();
app.Run();
3. Configure appsettings.json
Minimal configuration:
{
"ProjectName": "MyApp",
"Env": "DEV",
"Swagger": {
"Enable": true
}
}
For full configuration options, see appsettings.example.json
4. Create a Controller
[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
private readonly ISupabaseService _supabase;
public UsersController(ISupabaseService supabase)
{
_supabase = supabase;
}
[HttpGet]
public async Task<IActionResult> GetUsers()
{
var users = await _supabase.Table<User>().Get();
return Ok(users.Models);
}
}
5. Run Your App
dotnet run
Swagger UI: http://localhost:5000/api/docs
Available Services
All services are automatically registered and available via dependency injection:
| Service | Interface | Description |
|---|---|---|
| Supabase | ISupabaseService |
Database, Auth, Storage operations |
| Azure Communication | IAzureCommunicationService |
Enterprise Email & SMS |
| Google Storage | IGoogleStorageService |
Google Cloud Storage |
| General | IGeneralService |
General utility methods |
Note: All services are optional and only registered if configured in appsettings.json.
Documentation
📖 Integration Guide - Complete setup guide 📖 Database Usage - MySQL, PostgreSQL & Supabase guide 📖 Azure Communication Services - Email & SMS guide 📖 Supabase Usage - Supabase examples 📖 Example Program.cs - Full Program.cs example 📖 Example Controller - Controller examples 📖 Example Config - Configuration template 📖 Azure Communication Config Examples - 6 configuration scenarios
For React/NPM Developers
📦 React/NPM Library Guide - Create a similar library for React/TypeScript projects
Configuration Options
Required Settings
{
"ProjectName": "YourAppName",
"Env": "DEV"
}
Optional Services
Enable/disable services by adding their configuration:
Supabase:
{
"Supabase": {
"Url": "https://your-project.supabase.co",
"Key": "your-anon-key"
}
}
Application Insights:
{
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=xxx;..."
}
}
Serilog (Seq):
{
"Serilog": {
"serverUrl": "http://localhost:5341",
"apiKey": "your-key"
}
}
Azure Communication Services (Email & SMS):
{
"AzureCommunication": {
"ConnectionString": "endpoint=https://your-resource.communication.azure.com/;accesskey=YOUR_KEY",
"EnableEmail": true,
"EnableSms": true,
"SenderEmail": "DoNotReply@your-domain.com",
"SenderDisplayName": "My Application",
"SmsFromPhoneNumber": "+14255550123",
"EnableSmsDeliveryReports": true,
"DefaultSmsTag": "general"
}
}
See appsettings.azure-communication.json for more configuration examples
Hangfire:
{
"HangfireOptions": {
"Enable": true,
"DbType": "PostgreSQL",
"ConnectionStrings": "Host=localhost;Database=hangfire;..."
}
}
What Gets Registered?
When you call builder.UseIPGStandard(), the following happens automatically:
- Configuration - Loads appsettings.json + environment-specific configs
- Logging - Sets up Serilog with Console, Debug, Seq, and Application Insights
- Services - Registers Supabase, Mail, Google Storage, and General services
- Options - Binds configuration sections to strongly-typed options
- Hangfire - Configures background job processing (if enabled)
- Swagger - Sets up OpenAPI documentation (if enabled)
- API Versioning - Configures URL segment versioning
- AutoMapper - Registers all AutoMapper profiles
- Auto DI - Auto-registers classes ending with
ServiceorRepository - JSON - Configures JSON serialization with camelCase and enum support
When you call app.UseIPGStandard(), the middleware is configured:
- Serilog Request Logging - Logs all HTTP requests
- DbUp Migrations - Runs database migrations on startup
- Hangfire Dashboard - Available at
/hangfire(if enabled) - Exception Handler - Global exception handling
- Swagger UI - Available at
/api/docs(if enabled) - Authentication & Authorization - JWT support
- CORS - Cross-origin resource sharing
Examples
Supabase Database Query
// Get all records
var users = await _supabase.Table<User>().Get();
// Filter and order
var activeUsers = await _supabase.Table<User>()
.Where(x => x.Email!.Contains("@example.com"))
.Order(x => x.CreatedAt, Ordering.Descending)
.Get();
// Insert
var newUser = new User { Email = "user@example.com" };
await _supabase.Table<User>().Insert(newUser);
Authentication
// Sign up
var session = await _supabase.SignUpAsync("user@example.com", "password123");
// Sign in
var session = await _supabase.SignInAsync("user@example.com", "password123");
// Get current user
var user = _supabase.GetUser();
File Storage
// Upload to Supabase
using var stream = file.OpenReadStream();
var url = await _supabase.UploadFileAsync("avatars", "user.jpg", stream);
// Upload to Google Cloud
var result = await _storage.UploadFilesAsync("bucket", "file.jpg", stream);
Send Email
_mail.SendMail(
receiver: "user@example.com",
subject: "Welcome!",
message: "<h1>Hello!</h1>",
isHtml: true
);
Use MySQL or PostgreSQL with Entity Framework
// Register MySQL DbContext in Program.cs
builder.Services.AddMySqlContext<MyDbContext>(
builder.Configuration.GetConnectionString("MySqlConnection")
);
// Register PostgreSQL DbContext in Program.cs
builder.Services.AddPostgreSqlContext<MyDbContext>(
builder.Configuration.GetConnectionString("PostgreSqlConnection")
);
// Use in controller
public class ProductsController : ControllerBase
{
private readonly IDbContextFactory<MyDbContext> _dbFactory;
[HttpGet]
public async Task<IActionResult> GetProducts()
{
await using var context = await _dbFactory.CreateDbContextAsync();
var products = await context.Products.ToListAsync();
return Ok(products);
}
}
See Database Usage Guide for complete examples using MySQL, PostgreSQL, and Supabase together!
Troubleshooting
Service not found
- Ensure the service's configuration section exists in appsettings.json
- Check that the service is enabled (for optional services like Hangfire)
Swagger not showing
- Set
Swagger.Enable = truein appsettings.json - Navigate to
/api/docs(not/swagger)
Requirements
- .NET 8.0 or higher
- ASP.NET Core
License
MIT License
Support
For issues or questions, create an issue in the repository.
Built with ❤️ for rapid .NET development
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- Asp.Versioning.Http (>= 8.0.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.0.0)
- AutoMapper.Extensions.Microsoft.DependencyInjection (>= 12.0.1)
- Azure.Communication.Email (>= 1.1.0)
- Azure.Communication.Sms (>= 1.0.2)
- Azure.Storage.Blobs (>= 12.22.2)
- dbup (>= 5.0.41)
- dbup-mysql (>= 5.0.40)
- dbup-postgresql (>= 5.0.40)
- FluentEmail.Core (>= 3.0.2)
- FluentEmail.Smtp (>= 3.0.2)
- Google.Cloud.Storage.V1 (>= 4.7.0)
- Hangfire.AspNetCore (>= 1.8.11)
- Hangfire.Core (>= 1.8.11)
- Hangfire.MySqlStorage (>= 2.0.3)
- Hangfire.PostgreSql (>= 1.20.8)
- Microsoft.ApplicationInsights.AspNetCore (>= 2.22.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.0)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 8.0.0)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- NetCore.AutoRegisterDi (>= 2.1.0)
- Newtonsoft.Json (>= 13.0.3)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.0)
- Pomelo.EntityFrameworkCore.MySql (>= 8.0.0)
- Serilog (>= 4.0.0)
- Serilog.AspNetCore (>= 8.0.0)
- Serilog.Enrichers.Environment (>= 3.0.0)
- Serilog.Sinks.ApplicationInsights (>= 4.0.0)
- Serilog.Sinks.Console (>= 5.0.0)
- Serilog.Sinks.Debug (>= 2.0.0)
- Serilog.Sinks.Seq (>= 7.0.0)
- Supabase (>= 1.1.1)
- Swashbuckle.AspNetCore (>= 6.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.0.0: Initial release with support for Serilog, Application Insights, MySQL, PostgreSQL, Supabase, Hangfire, Google Cloud Storage, email services, API versioning, and Swagger documentation.