Wetterdienst
This commit is contained in:
@@ -26,6 +26,8 @@ if (args.Length > 0 && args[0] == "set-password")
|
||||
|
||||
var secret = builder.Configuration["JWT_SECRET"]
|
||||
?? throw new InvalidOperationException("JWT_SECRET nicht konfiguriert.");
|
||||
var outboundUserAgent = builder.Configuration["Geocoding:UserAgent"]
|
||||
?? "LehrerApp-Server/1.0 (+https://science-teaching.de)";
|
||||
|
||||
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(o => o.TokenValidationParameters = new()
|
||||
@@ -81,6 +83,20 @@ builder.Services.AddSingleton<SnapshotStore>(_ => new SnapshotStore(data));
|
||||
builder.Services.AddSingleton<ReadableSnapshotStore>(_ => new ReadableSnapshotStore(data));
|
||||
builder.Services.AddSingleton<PlainEventStore>(sp =>
|
||||
new PlainEventStore(sp.GetRequiredService<EventStore>()));
|
||||
builder.Services.AddSingleton<SchoolWeatherStore>(_ => new SchoolWeatherStore(data));
|
||||
builder.Services.AddHttpClient<IGeocoder, NominatimGeocoder>(client =>
|
||||
{
|
||||
client.BaseAddress = new Uri("https://nominatim.openstreetmap.org/");
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd(outboundUserAgent);
|
||||
client.Timeout = TimeSpan.FromSeconds(15);
|
||||
});
|
||||
builder.Services.AddHttpClient("dwd", client =>
|
||||
{
|
||||
client.DefaultRequestHeaders.UserAgent.ParseAdd(outboundUserAgent);
|
||||
client.Timeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
builder.Services.AddSingleton(sp => new DwdWeatherService(
|
||||
sp.GetRequiredService<IHttpClientFactory>().CreateClient("dwd")));
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseForwardedHeaders();
|
||||
@@ -95,5 +111,6 @@ app.MapAttachmentEndpoints();
|
||||
app.MapSnapshotEndpoints();
|
||||
app.MapReadableSnapshotEndpoints();
|
||||
app.MapPlainSyncEndpoints();
|
||||
app.MapSchoolWeatherEndpoints();
|
||||
app.Run();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user