Plugins engine is working
This commit is contained in:
@@ -5,10 +5,11 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using DiunaBI.Core.Models;
|
||||
using DiunaBI.Database.Context;
|
||||
using DiunaBI.Core.Services;
|
||||
using Google.Apis.Sheets.v4;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -57,8 +58,22 @@ builder.Services.AddAuthentication(options =>
|
||||
});
|
||||
builder.Services.AddAuthentication();
|
||||
|
||||
builder.Services.AddSingleton(typeof(GoogleSheetsHelper));
|
||||
builder.Services.AddSingleton(typeof(GoogleDriveHelper));
|
||||
// Zarejestruj 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;
|
||||
});
|
||||
|
||||
|
||||
var fileName = "diunabi-admin-firebase.json";
|
||||
#if DEBUG
|
||||
@@ -72,8 +87,17 @@ FirebaseAdmin.FirebaseApp.Create(new AppOptions()
|
||||
});
|
||||
builder.Services.AddSingleton(FirestoreDb.Create("diunabi-admin"));
|
||||
|
||||
builder.Services.AddSingleton<PluginManager>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
var pluginManager = app.Services.GetRequiredService<PluginManager>();
|
||||
|
||||
var executablePath = Assembly.GetExecutingAssembly().Location;
|
||||
var executableDir = Path.GetDirectoryName(executablePath)!;
|
||||
var pluginsPath = Path.Combine(executableDir, "Plugins");
|
||||
|
||||
pluginManager.LoadPluginsFromDirectory(pluginsPath);
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user