- Neue Spalte 'settings' in users-Tabelle (Migration via TryAddColumn) - SettingsEndpoint: GET/PUT /api/settings - DatabaseService: GetUserSettings() + UpdateUserSettings() - Frontend: currentSettings als globaler State in app.js - settings-page.js: localStorage komplett entfernt, nutzt API - Settings werden beim App-Start aus DB geladen und angewendet
61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using System;
|
||
using System.IO;
|
||
using System.Net.Http;
|
||
using Gott.Endpoints;
|
||
using Gott.Middleware;
|
||
using Gott.Services;
|
||
using Microsoft.AspNetCore.Builder;
|
||
using Microsoft.Extensions.Configuration;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
|
||
var builder = WebApplication.CreateBuilder(args);
|
||
builder.Services.AddHttpClient();
|
||
|
||
var dataDir = Path.Combine(AppContext.BaseDirectory, "data");
|
||
|
||
var dbPath = Path.Combine(dataDir, "gott.db");
|
||
var authService = new AuthService(dbPath);
|
||
var dbService = new DatabaseService(dbPath);
|
||
dbService.EnsureDefaultUser(authService);
|
||
|
||
builder.Services.AddSingleton(authService);
|
||
builder.Services.AddSingleton(dbService);
|
||
builder.Services.AddSingleton(new ToolService());
|
||
builder.Services.AddSingleton(new ImageService());
|
||
builder.Services.AddSingleton(new StreamingTracker());
|
||
var memoryService = new MemoryService(dataDir);
|
||
var skillService = new SkillService(dataDir);
|
||
builder.Services.AddSingleton(memoryService);
|
||
builder.Services.AddSingleton(skillService);
|
||
|
||
// Telegram Bot (optional – nur wenn Token konfiguriert)
|
||
var telegramToken = builder.Configuration["TelegramBotToken"] ?? "";
|
||
var telegramSecret = builder.Configuration["TelegramWebhookSecret"] ?? Guid.NewGuid().ToString("N");
|
||
var anthropicToken = builder.Configuration["AnthropicToken"] ?? "";
|
||
builder.Services.AddSingleton<TelegramService>(sp =>
|
||
new TelegramService(
|
||
telegramToken, telegramSecret, anthropicToken,
|
||
sp.GetRequiredService<IHttpClientFactory>(),
|
||
dbService, new ToolService(), memoryService, skillService,
|
||
builder.Configuration.GetValue<int>("MaxIterations", 100)));
|
||
|
||
var app = builder.Build();
|
||
app.UseDefaultFiles();
|
||
app.UseStaticFiles();
|
||
app.UseMiddleware<AuthMiddleware>();
|
||
|
||
app.MapAuthEndpoints();
|
||
app.MapChatEndpoint();
|
||
app.MapHistoryEndpoint();
|
||
app.MapSessionEndpoints();
|
||
app.MapAgentEndpoints();
|
||
app.MapWorkspaceEndpoint();
|
||
app.MapInfoEndpoint();
|
||
app.MapBackupEndpoint();
|
||
app.MapSkillEndpoints();
|
||
app.MapProfileEndpoints();
|
||
app.MapSettingsEndpoints();
|
||
app.MapTelegramEndpoints();
|
||
|
||
app.Run("http://0.0.0.0:19000");
|