module FundLab.Api.Program open System open Giraffe open Microsoft.AspNetCore.Builder open Microsoft.Extensions.DependencyInjection let private requiredEnvironment name = match Environment.GetEnvironmentVariable(name) with | value when not (String.IsNullOrWhiteSpace value) -> value | _ -> failwithf "%s must be configured" name [] let main argv = let builder = WebApplication.CreateBuilder(argv) builder.Services.AddGiraffe() |> ignore let repository = FundRepository(requiredEnvironment "FUND_LAB_DATABASE_URL") repository.EnsureSchema() let collector = ProcessMarketDataCollector.FromEnvironment() :> IMarketDataCollector let marketData = MarketDataService(repository, collector) :> IMarketDataService let app = builder.Build() app.UseGiraffe(App.createApplicationWithMarketData repository marketData) app.Run() 0