Adds initial files for a proof-of-concept project, including Dockerfile, .gitignore, project files, and MQTT-related services. This commit sets up the basic structure and configuration for exploring and validating the core concepts of the project.
31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using Microsoft.Extensions.Caching.Memory;
|
|
using ProofOfConcept.Services;
|
|
|
|
var builder = WebApplication.CreateSlimBuilder(args);
|
|
|
|
// builder.Services.ConfigureHttpJsonOptions(options => { options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); });
|
|
|
|
builder.Services.AddOpenApi();
|
|
builder.Services.AddMediator();
|
|
builder.Services.AddMemoryCache();
|
|
builder.Services.AddHybridCache();
|
|
|
|
builder.Services.AddSingleton<IMessageProcessor, MessageProcessor>();
|
|
|
|
builder.Services.AddHostedService<MQTTServer>();
|
|
builder.Services.AddHostedService<MQTTClient>();
|
|
|
|
var app = builder.Build();
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
//Map tesla required public key file
|
|
app.MapGet("/.well-known/appspecific/com.tesla.3p.public-key.pem", (IMemoryCache memoryCache) => memoryCache.GetOrCreateAsync("publicKeyCert", async (_) => await File.ReadAllTextAsync("Resources/Signature/public-key.pem")));
|
|
|
|
//Map an under constrcution page...
|
|
app.Map("/", ()=> "Under construction...");
|
|
|
|
app.Run(); |