first commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using TinfoilVibeServer.Middleware;
|
||||
using TinfoilVibeServer.Services;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// -----------------------------------------------------
|
||||
// 1. Register AuthStore as a singleton
|
||||
// -----------------------------------------------------
|
||||
builder.Services.AddSingleton<AuthStore>();
|
||||
|
||||
// -----------------------------------------------------
|
||||
// 2. Snapshot + other services (unchanged)
|
||||
// -----------------------------------------------------
|
||||
builder.Services.AddSingleton<SnapshotService>();
|
||||
// … any other services you already have
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// -----------------------------------------------------
|
||||
// 3. Apply authentication middleware *before* the
|
||||
// snapshot endpoints. This guarantees all routes
|
||||
// are protected.
|
||||
// -----------------------------------------------------
|
||||
app.UseMiddleware<BasicAuthMiddleware>();
|
||||
|
||||
// -----------------------------------------------------
|
||||
// 4. Existing endpoints – unchanged
|
||||
// -----------------------------------------------------
|
||||
app.MapGet("/", () => Results.Redirect("/index.tfl"));
|
||||
app.MapGet("/index.tfl", async context =>
|
||||
{
|
||||
var jsonPath = Path.Combine(AppContext.BaseDirectory, "index.tfl");
|
||||
context.Response.ContentType = "application/json";
|
||||
await context.Response.WriteAsync(await File.ReadAllTextAsync(jsonPath));
|
||||
});
|
||||
app.MapGet("/debug", () => new SnapshotService(builder.Configuration).GetSnapshot());
|
||||
app.MapGet("/stream/{*relativePath}", async context =>
|
||||
{
|
||||
// … (unchanged streaming logic – same as before)
|
||||
});
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user