Final fixes before tests
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Cloud.Firestore;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
@@ -14,7 +12,6 @@ using DiunaBI.Core.Interfaces;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// ✅ SERILOG TYLKO DLA PRODUKCJI
|
||||
if (builder.Environment.IsProduction())
|
||||
{
|
||||
builder.Host.UseSerilog((context, configuration) =>
|
||||
@@ -30,6 +27,7 @@ if (builder.Environment.IsProduction())
|
||||
}
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("SQLDatabase");
|
||||
|
||||
builder.Services.AddDbContext<AppDbContext>(x =>
|
||||
{
|
||||
x.UseSqlServer(connectionString);
|
||||
@@ -70,25 +68,24 @@ builder.Services.AddAuthentication(options =>
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration["Secret"]!))
|
||||
};
|
||||
});
|
||||
builder.Services.AddAuthentication();
|
||||
|
||||
// Queue services
|
||||
builder.Services.AddScoped<IJobQueueService, JobQueueService>();
|
||||
builder.Services.AddHostedService<JobQueueProcessor>();
|
||||
builder.Services.AddSingleton<JobQueueProcessor>();
|
||||
|
||||
// Zarejestruj Google Sheets dependencies
|
||||
// Google Sheets dependencies
|
||||
builder.Services.AddSingleton<GoogleSheetsHelper>();
|
||||
builder.Services.AddSingleton<GoogleDriveHelper>();
|
||||
builder.Services.AddSingleton<SpreadsheetsResource.ValuesResource>(provider =>
|
||||
{
|
||||
var googleSheetsHelper = provider.GetRequiredService<GoogleSheetsHelper>();
|
||||
var valuesResource = googleSheetsHelper.Service?.Spreadsheets.Values;
|
||||
|
||||
|
||||
if (valuesResource == null)
|
||||
{
|
||||
throw new InvalidOperationException("Google Sheets Service is not initialized properly");
|
||||
}
|
||||
|
||||
|
||||
return valuesResource;
|
||||
});
|
||||
|
||||
@@ -96,7 +93,6 @@ builder.Services.AddSingleton<PluginManager>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// ✅ SERILOG REQUEST LOGGING TYLKO DLA PRODUKCJI
|
||||
if (app.Environment.IsProduction())
|
||||
{
|
||||
app.UseSerilogRequestLogging(options =>
|
||||
@@ -106,25 +102,25 @@ if (app.Environment.IsProduction())
|
||||
{
|
||||
diagnosticContext.Set("RequestHost", httpContext.Request.Host.Value);
|
||||
diagnosticContext.Set("RequestScheme", httpContext.Request.Scheme);
|
||||
|
||||
|
||||
var userAgent = httpContext.Request.Headers.UserAgent.FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(userAgent))
|
||||
{
|
||||
diagnosticContext.Set("UserAgent", userAgent);
|
||||
}
|
||||
|
||||
|
||||
diagnosticContext.Set("RemoteIP", httpContext.Connection.RemoteIpAddress?.ToString() ?? "unknown");
|
||||
diagnosticContext.Set("RequestContentType", httpContext.Request.ContentType ?? "none");
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// Plugin initialization
|
||||
var pluginManager = app.Services.GetRequiredService<PluginManager>();
|
||||
var executablePath = Assembly.GetExecutingAssembly().Location;
|
||||
var executableDir = Path.GetDirectoryName(executablePath)!;
|
||||
var pluginsPath = Path.Combine(executableDir, "Plugins");
|
||||
|
||||
// ✅ RÓŻNE LOGGERY W ZALEŻNOŚCI OD ŚRODOWISKA
|
||||
if (app.Environment.IsProduction())
|
||||
{
|
||||
Log.Information("Starting DiunaBI application");
|
||||
@@ -165,8 +161,7 @@ app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
||||
// ✅ SERILOG CLEANUP TYLKO DLA PRODUKCJI
|
||||
if (app.Environment.IsProduction())
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user