blob: b7d0ef675a1d433a8db18714e23da565fc5b4f23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
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
[<EntryPoint>]
let main argv =
let builder = WebApplication.CreateBuilder(argv)
builder.Services |> App.addOptionFriendlyJson |> ignore
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
|