40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using FrameProcessor.Configuration;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Configuration.AddJsonFile("frames.json", optional: false, reloadOnChange: true);
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
builder.Services.AddOptions<MqttOptions>()
|
|
.Bind(builder.Configuration.GetSection(MqttOptions.SectionName))
|
|
.ValidateDataAnnotations()
|
|
.ValidateOnStart();
|
|
|
|
builder.Services.AddOptions<StorageOptions>()
|
|
.Bind(builder.Configuration.GetSection(StorageOptions.SectionName))
|
|
.ValidateDataAnnotations()
|
|
.ValidateOnStart();
|
|
|
|
builder.Services.AddOptions<UrlFetchOptions>()
|
|
.Bind(builder.Configuration.GetSection(UrlFetchOptions.SectionName))
|
|
.ValidateDataAnnotations()
|
|
.ValidateOnStart();
|
|
|
|
builder.Services.AddOptions<ApiKeyOptions>()
|
|
.Configure<IConfiguration>((opts, cfg) => opts.Value = cfg[ApiKeyOptions.SectionName] ?? string.Empty)
|
|
.ValidateDataAnnotations()
|
|
.ValidateOnStart();
|
|
|
|
builder.Services.AddSingleton<IValidateOptions<FramesOptions>, FramesOptionsValidator>();
|
|
builder.Services.AddOptions<FramesOptions>()
|
|
.Bind(builder.Configuration)
|
|
.ValidateOnStart();
|
|
|
|
var app = builder.Build();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|