Files
gott/Program.cs
T
Meleki f203ed7f47 feat: Auth-Tokens in SQLite persistieren statt in-memory
Tokens überleben jetzt App-Restarts. AuthService schreibt/liest
Tokens aus einer 'tokens'-Tabelle in der SQLite-DB.
Logout (RevokeToken) funktioniert weiterhin korrekt.
2026-03-03 10:07:06 +01:00

60 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.MapTelegramEndpoints();
app.Run("http://0.0.0.0:19000");