WIP
This commit is contained in:
37
src/Server/Server.fs
Normal file
37
src/Server/Server.fs
Normal file
@@ -0,0 +1,37 @@
|
||||
open System.IO
|
||||
open System.Threading.Tasks
|
||||
|
||||
open Microsoft.AspNetCore.Builder
|
||||
open Microsoft.Extensions.DependencyInjection
|
||||
open FSharp.Control.Tasks.V2
|
||||
open Giraffe
|
||||
open Saturn
|
||||
open Shared
|
||||
|
||||
|
||||
let tryGetEnv = System.Environment.GetEnvironmentVariable >> function null | "" -> None | x -> Some x
|
||||
|
||||
let publicPath = Path.GetFullPath "../Client/public"
|
||||
|
||||
let port =
|
||||
"SERVER_PORT"
|
||||
|> tryGetEnv |> Option.map uint16 |> Option.defaultValue 8085us
|
||||
|
||||
// let webApp = router {
|
||||
// get "/api/init" (fun next ctx ->
|
||||
// task {
|
||||
// let counter = {Value = 7}
|
||||
// return! json counter next ctx
|
||||
// })
|
||||
// }
|
||||
|
||||
let app = application {
|
||||
url ("http://0.0.0.0:" + port.ToString() + "/")
|
||||
//use_router webApp
|
||||
memory_cache
|
||||
use_static publicPath
|
||||
use_json_serializer(Thoth.Json.Giraffe.ThothSerializer())
|
||||
use_gzip
|
||||
}
|
||||
|
||||
run app
|
||||
13
src/Server/Server.fsproj
Normal file
13
src/Server/Server.fsproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="paket.references" />
|
||||
<Compile Include="..\Shared\Shared.fs" />
|
||||
<Compile Include="Server.fs" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
||||
4
src/Server/paket.references
Normal file
4
src/Server/paket.references
Normal file
@@ -0,0 +1,4 @@
|
||||
group Server
|
||||
FSharp.Core
|
||||
Saturn
|
||||
Thoth.Json.Giraffe
|
||||
Reference in New Issue
Block a user