-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRemoting.fs
38 lines (31 loc) · 1.1 KB
/
Remoting.fs
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
27
28
29
30
31
32
33
34
35
36
37
38
module OpenXmlExplorer.Remoting
open Fable.Core
open Fable.Import.Axios
open Fable.Import.Axios.Globals
open Shared
let inline private toAsync<'a>(resp: JS.Promise<AxiosXHR<'a>>) =
resp |> Promise.map(_.data) |> Async.AwaitPromise
let getApiClient(serverHost) : IOpenXmlApi =
let typeName = nameof(IOpenXmlApi)
let getRoute methodName =
serverHost + Route.builder typeName methodName
{ getPackageInfo =
fun filePath ->
let data = [ filePath ]
axios.post<Document>(getRoute "getPackageInfo", data) |> toAsync
getPartContent =
fun filePath partUri ->
let data = [ filePath; partUri ]
axios.post<string>(getRoute "getPartContent", data) |> toAsync
checkHealth =
fun () ->
async {
try
return! axios.get(getRoute "checkHealth") |> toAsync
with e ->
return false
}
stopApplication =
fun () ->
Log.line $"Stopping API Server ..."
axios.get(getRoute "stopApplication") |> toAsync }