@@ -20,13 +20,13 @@ module Node.Http2.Server
2020
2121import Prelude
2222
23- import Data.Maybe (Maybe (..), fromMaybe )
2423import Data.Time.Duration (Milliseconds )
2524import Effect (Effect )
2625import Effect.Exception (Error )
2726import Effect.Uncurried (EffectFn1 , EffectFn2 , EffectFn4 , mkEffectFn1 , mkEffectFn2 , mkEffectFn4 , runEffectFn1 , runEffectFn2 )
2827import Node.Http2.Types (Headers , Http2SecureServer , Http2ServerRequest , Http2ServerResponse , Http2Session , Http2Stream , Server , Settings , TlsSecureContextOptions )
2928import Node.Stream (Duplex )
29+ import Prim.Row as Row
3030import Type.Row (type (+))
3131
3232-- | `allowHTTP1` <boolean> Incoming client connections that do not support HTTP/2 will be downgraded to HTTP/1.x when set to true. See the 'unknownProtocol' event. See ALPN negotiation. Default: false.
@@ -115,120 +115,13 @@ type NetCreateServerOptions f r =
115115-- | })
116116-- | ```
117117createSecureServer
118- :: ( { | Http2CreateSecureServerOptions Maybe + TlsCreateServerOptions Maybe + TlsSecureContextOptions Maybe + NetCreateServerOptions Maybe + () }
119- -> { | Http2CreateSecureServerOptions Maybe + TlsCreateServerOptions Maybe + TlsSecureContextOptions Maybe + NetCreateServerOptions Maybe + () }
120- )
118+ :: forall rec trash
119+ . Row.Union rec trash ( Http2CreateSecureServerOptions Unlift + TlsCreateServerOptions Unlift + TlsSecureContextOptions Unlift + NetCreateServerOptions Unlift + ())
120+ => { | rec }
121121 -> Effect Http2SecureServer
122- createSecureServer buildOptions = do
123- let
124- o = buildOptions
125- { allowHTTP1: Nothing
126- , maxDeflateDynamicTableSize: Nothing
127- , maxSettings: Nothing
128- , maxSessionMemory: Nothing
129- , maxHeaderListPairs: Nothing
130- , maxOutstandingPings: Nothing
131- , maxSendHeaderBlockLength: Nothing
132- , paddingStrategy: Nothing
133- , peerMaxConcurrentStreams: Nothing
134- , maxSessionInvalidFrames: Nothing
135- , maxSessionRejectedStreams: Nothing
136- , settings: Nothing
137- , origins: Nothing
138- , unknownProtocolTimeout: Nothing
139- -- tls create server options
140- , " ALPNProtocols" : Nothing
141- , enableTrace: Nothing
142- , handshakeTimeout: Nothing
143- , rejectUnauthorized: Nothing
144- , requestCert: Nothing
145- , pskIdentityHint: Nothing
146- -- tls secure context options
147- , ca: Nothing
148- , cert: Nothing
149- , sigalgs: Nothing
150- , ciphers: Nothing
151- , clientCertEngine: Nothing
152- , crl: Nothing
153- , dhparam: Nothing
154- , ecdhCurve: Nothing
155- , honorCipherOrder: Nothing
156- , key: Nothing
157- , privateKeyEngine: Nothing
158- , privateKeyIdentifier: Nothing
159- , maxVersion: Nothing
160- , minVersion: Nothing
161- , passphrase: Nothing
162- , pfx: Nothing
163- , secureOptions: Nothing
164- , secureProtocol: Nothing
165- , sessionIdContext: Nothing
166- , ticketKeys: Nothing
167- , sessionTimeout: Nothing
168- -- net create server options
169- , allowHalfOpen: Nothing
170- , pauseOnConnect: Nothing
171- , noDelay: Nothing
172- , keepAlive: Nothing
173- , keepAliveInitialDelay: Nothing
174- }
175-
176- options' :: { | Http2CreateSecureServerOptions Unlift + TlsCreateServerOptions Unlift + TlsSecureContextOptions Unlift + NetCreateServerOptions Unlift + () }
177- options' =
178- -- Http2
179- { allowHTTP1: fromMaybe undefined o.allowHTTP1
180- , maxDeflateDynamicTableSize: fromMaybe undefined o.maxDeflateDynamicTableSize
181- , maxSettings: fromMaybe undefined o.maxSettings
182- , maxSessionMemory: fromMaybe undefined o.maxSessionMemory
183- , maxHeaderListPairs: fromMaybe undefined o.maxHeaderListPairs
184- , maxOutstandingPings: fromMaybe undefined o.maxOutstandingPings
185- , maxSendHeaderBlockLength: fromMaybe undefined o.maxSendHeaderBlockLength
186- , paddingStrategy: fromMaybe undefined o.paddingStrategy
187- , peerMaxConcurrentStreams: fromMaybe undefined o.peerMaxConcurrentStreams
188- , maxSessionInvalidFrames: fromMaybe undefined o.maxSessionInvalidFrames
189- , maxSessionRejectedStreams: fromMaybe undefined o.maxSessionRejectedStreams
190- , settings: fromMaybe undefined o.settings
191- , origins: fromMaybe undefined o.origins
192- , unknownProtocolTimeout: fromMaybe undefined o.unknownProtocolTimeout
193- -- tls create server options
194- , " ALPNProtocols" : fromMaybe undefined o." ALPNProtocols"
195- , enableTrace: fromMaybe undefined o.enableTrace
196- , handshakeTimeout: fromMaybe undefined o.handshakeTimeout
197- , rejectUnauthorized: fromMaybe undefined o.rejectUnauthorized
198- , requestCert: fromMaybe undefined o.requestCert
199- , pskIdentityHint: fromMaybe undefined o.pskIdentityHint
200- -- tls secure context options
201- , ca: fromMaybe undefined o.ca
202- , cert: fromMaybe undefined o.cert
203- , sigalgs: fromMaybe undefined o.sigalgs
204- , ciphers: fromMaybe undefined o.ciphers
205- , clientCertEngine: fromMaybe undefined o.clientCertEngine
206- , crl: fromMaybe undefined o.crl
207- , dhparam: fromMaybe undefined o.dhparam
208- , ecdhCurve: fromMaybe undefined o.ecdhCurve
209- , honorCipherOrder: fromMaybe undefined o.honorCipherOrder
210- , key: fromMaybe undefined o.key
211- , privateKeyEngine: fromMaybe undefined o.privateKeyEngine
212- , privateKeyIdentifier: fromMaybe undefined o.privateKeyIdentifier
213- , maxVersion: fromMaybe undefined o.maxVersion
214- , minVersion: fromMaybe undefined o.minVersion
215- , passphrase: fromMaybe undefined o.passphrase
216- , pfx: fromMaybe undefined o.pfx
217- , secureOptions: fromMaybe undefined o.secureOptions
218- , secureProtocol: fromMaybe undefined o.secureProtocol
219- , sessionIdContext: fromMaybe undefined o.sessionIdContext
220- , ticketKeys: fromMaybe undefined o.ticketKeys
221- , sessionTimeout: fromMaybe undefined o.sessionTimeout
222- -- net create server options
223- , allowHalfOpen: fromMaybe undefined o.allowHalfOpen
224- , pauseOnConnect: fromMaybe undefined o.pauseOnConnect
225- , noDelay: fromMaybe undefined o.noDelay
226- , keepAlive: fromMaybe undefined o.keepAlive
227- , keepAliveInitialDelay: fromMaybe undefined o.keepAliveInitialDelay
228- }
229- runEffectFn1 createSecureServerImpl options'
230-
231- foreign import createSecureServerImpl :: EffectFn1 { | Http2CreateSecureServerOptions Unlift + TlsCreateServerOptions Unlift + TlsSecureContextOptions Unlift + NetCreateServerOptions Unlift + () } (Http2SecureServer )
122+ createSecureServer options = runEffectFn1 createSecureServerImpl options
123+
124+ foreign import createSecureServerImpl :: forall r . EffectFn1 { | r } (Http2SecureServer )
232125
233126-- | `port` <number>
234127-- | `host` <string>
@@ -238,42 +131,26 @@ foreign import createSecureServerImpl :: EffectFn1 { | Http2CreateSecureServerOp
238131-- | `readableAll` <boolean> For IPC servers makes the pipe readable for all users. Default: false.
239132-- | `writableAll` <boolean> For IPC servers makes the pipe writable for all users. Default: false.
240133-- | `ipv6Only` <boolean> For TCP servers, setting ipv6Only to true will disable dual-stack support, i.e., binding to host :: won't make 0.0.0.0 be bound. Default: false.
241- type ListenOptions f =
242- { port :: f Int
243- , host :: f String
244- , backlog :: f Number
245- , exclusive :: f Boolean
246- , readableAll :: f Boolean
247- , writableAll :: f Boolean
248- , ipv6Only :: f Boolean
249- }
250-
251- listen :: Http2SecureServer -> (ListenOptions Maybe -> ListenOptions Maybe ) -> Effect Unit
252- listen s buildOptions = do
253- let
254- o = buildOptions
255- { port: Nothing
256- , host: Nothing
257- , backlog: Nothing
258- , exclusive: Nothing
259- , readableAll: Nothing
260- , writableAll: Nothing
261- , ipv6Only: Nothing
262- }
263-
264- finalOptions :: ListenOptions Unlift
265- finalOptions =
266- { port: fromMaybe undefined o.port
267- , host: fromMaybe undefined o.host
268- , backlog: fromMaybe undefined o.backlog
269- , exclusive: fromMaybe undefined o.exclusive
270- , readableAll: fromMaybe undefined o.readableAll
271- , writableAll: fromMaybe undefined o.writableAll
272- , ipv6Only: fromMaybe undefined o.ipv6Only
273- }
274- runEffectFn2 listenImpl s finalOptions
275-
276- foreign import listenImpl :: EffectFn2 (Http2SecureServer ) (ListenOptions Unlift ) (Unit )
134+ type ListenOptions r =
135+ ( port :: Int
136+ , host :: String
137+ , backlog :: Number
138+ , exclusive :: Boolean
139+ , readableAll :: Boolean
140+ , writableAll :: Boolean
141+ , ipv6Only :: Boolean
142+ | r
143+ )
144+
145+ listen
146+ :: forall r trash
147+ . Row.Union r trash (ListenOptions + ())
148+ => Http2SecureServer
149+ -> { | r }
150+ -> Effect Unit
151+ listen s o = runEffectFn2 listenImpl s o
152+
153+ foreign import listenImpl :: forall r . EffectFn2 (Http2SecureServer ) { | r } (Unit )
277154
278155type Unlift :: Type -> Type
279156type Unlift a = a
0 commit comments