0 | module Node.Net.Server.Listen
 1 |
 2 | import Node
 3 | import Node.Internal.Support
 4 |
 5 | public export
 6 | record Options where
 7 |   constructor MkOptions
 8 |   port : Maybe Int
 9 |   host : Maybe String
10 |   path : Maybe String
11 |   backlog : Maybe Int
12 |   exclusive : Bool
13 |   readableAll : Bool
14 |   writableAll : Bool
15 |   ipv6Only : Bool
16 |   -- TODO signal <AbortSignal> An AbortSignal that may be used to close a listening server.
17 |
18 | export
19 | defaultOptions : Options
20 | defaultOptions = MkOptions
21 |   { port = Nothing
22 |   , host = Nothing
23 |   , path = Nothing
24 |   , backlog = Nothing
25 |   , exclusive = False
26 |   , readableAll = False
27 |   , writableAll = False
28 |   , ipv6Only = False
29 |   }
30 |
31 | %foreign """
32 |   node:lambda:
33 |   ( port
34 |   , host
35 |   , path
36 |   , backlog
37 |   , exclusive
38 |   , readableAll
39 |   , writableAll
40 |   , ipv6Only
41 |   ) => _keepDefined({
42 |     port: _maybe(port),
43 |     host: _maybe(host),
44 |     path: _maybe(path),
45 |     backlog: _maybe(backlog),
46 |     exclusive: _bool(exclusive),
47 |     readableAll: _bool(readableAll),
48 |     writableAll: _bool(writableAll),
49 |     ipv6Only: _bool(ipv6Only),
50 |   })
51 |   """
52 | ffi_convertOptions :
53 |   (port : Maybe Int) ->
54 |   (host : Maybe String) ->
55 |   (path : Maybe String) ->
56 |   (backlog : Maybe Int) ->
57 |   (exclusive : Bool) ->
58 |   (readableAll : Bool) ->
59 |   (writableAll : Bool) ->
60 |   (ipv6Only : Bool) ->
61 |   Node Options
62 |
63 | export
64 | convertOptions : Options -> Node Options
65 | convertOptions o = ffi_convertOptions
66 |   o.port
67 |   o.host
68 |   o.path
69 |   o.backlog
70 |   o.exclusive
71 |   o.readableAll
72 |   o.writableAll
73 |   o.ipv6Only
74 |
75 |