Files
Automatic-Parking/Source/ProofOfConcept/Program.cs
Szakáts Alpár Zsolt 183d71e203
Some checks failed
Build, Push and Run Container / build (push) Failing after 33s
POC big step
2025-08-12 16:48:16 +02:00

45 lines
1.5 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using ProofOfConcept.Services;
using ProofOfConcept.Utilities;
var builder = WebApplication.CreateSlimBuilder(args);
// Load static web assets manifest (referenced libs + your wwwroot)
builder.WebHost.UseStaticWebAssets();
// builder.Services.ConfigureHttpJsonOptions(options => { options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); });
// Add services
builder.Services.AddOpenApi();
builder.Services.AddMediator();
builder.Services.AddMemoryCache();
builder.Services.AddHybridCache();
builder.Services.AddHttpClient();
builder.Services.AddRazorPages();
// Add own services
builder.Services.AddSingleton<IMessageProcessor, MessageProcessor>();
builder.Services.AddTransient<TeslaAuthenticatorService>();
// Add hosted services
builder.Services.AddHostedService<MQTTServer>();
builder.Services.AddHostedService<MQTTClient>();
//Build app
WebApplication app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.MapGet("/GetPartnerAuthenticationToken", ([FromServices] TeslaAuthenticatorService service) => service.AcquirePartnerAuthenticationTokenAsync());
app.MapGet("/CheckRegisteredApplication", ([FromServices] TeslaAuthenticatorService service) => service.CheckApplicationRegistrationAsync());
app.MapGet("/RegisterApplication", ([FromServices] TeslaAuthenticatorService service) => service.RegisterApplicationAsync());
}
//Map static assets
app.MapStaticAssets();
app.MapRazorPages();
app.Run();