Brought in data model / dependencies

A combination of the previous effort plus a few things swiped from
Quatro
This commit is contained in:
Daniel J. Summers
2016-12-12 22:29:05 -06:00
parent 864777a831
commit da6910e055
7 changed files with 332 additions and 36 deletions

36
src/App.fs Normal file
View File

@@ -0,0 +1,36 @@
/// Main server module for myPrayerJournal
module MyPrayerJournal.App
open Reader
open System.IO
open Suave
open Suave.Filters
open Suave.Operators
/// Data Configuration singleton
let lazyCfg = lazy (DataConfig.FromJson <| try File.ReadAllText "data-config.json" with _ -> "{}")
/// RethinkDB connection singleton
let lazyConn = lazy lazyCfg.Force().CreateConnection ()
/// Application dependencies
let deps = {
new IDependencies with
member __.Conn with get () = lazyConn.Force ()
}
/// Suave application
let app : WebPart =
choose [
GET >=> Files.browseHome
GET >=> Files.browseFileHome "index.html"
RequestErrors.NOT_FOUND "Page not found."
]
let suaveCfg = { defaultConfig with homeFolder = Some (Path.GetFullPath "./wwwroot/") }
[<EntryPoint>]
let main argv =
// Establish the data environment
liftDep getConn (Data.establishEnvironment >> Async.RunSynchronously)
|> run deps
startWebServer suaveCfg app
0