Skip to content

Commit ee3697b

Browse files
Update code to use new dependencies
1 parent 1481ede commit ee3697b

File tree

10 files changed

+174
-356
lines changed

10 files changed

+174
-356
lines changed

spago.dhall

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
, "functions"
88
, "maybe"
99
, "node-buffer"
10+
, "node-event-emitter"
1011
, "node-fs"
1112
, "node-net"
1213
, "node-path"
@@ -15,7 +16,7 @@
1516
, "nullable"
1617
, "partial"
1718
, "prelude"
18-
, "typelevel-prelude"
19+
, "unsafe-coerce"
1920
]
2021
, packages = ./packages.dhall
2122
, sources = [ "src/**/*.purs" ]

src/Node/Http2/Client.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ import http2 from "node:http2";
22

33
export const connectAuthImpl = (auth) => http2.connect(auth);
44
export const connectAuthOptionsImpl = (auth, options) => http2.connect(auth, options);
5-
6-
const undefined_ = undefined;
7-
export { undefined_ as undefined }

src/Node/Http2/Client.purs

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,27 @@
11
module Node.Http2.Client
2-
( ConnectOptions
3-
, connect
2+
( connect
43
, connect'
54
) where
65

76
import Effect (Effect)
87
import Effect.Uncurried (EffectFn1, EffectFn2, runEffectFn1, runEffectFn2)
9-
import Node.Buffer.Immutable (ImmutableBuffer)
10-
import Node.Http2.Types (Client, Http2Session, Settings, TlsSecureContextOptions)
11-
import Node.Net.Socket (Socket)
8+
import Node.Http2.Types (Http2ClientConnectOptions, Http2Session)
9+
import Node.Net.Types (ConnectTcpOptions)
10+
import Node.TLS.Types (Client, ConnectTlsSocketOptions, CreateSecureContextOptions)
1211
import Prim.Row as Row
13-
import Type.Row (type (+))
1412

1513
connect :: String -> Effect (Http2Session Client)
1614
connect authority = runEffectFn1 connectAuthImpl authority
1715

1816
foreign import connectAuthImpl :: EffectFn1 (String) (Http2Session Client)
1917

20-
-- | `maxDeflateDynamicTableSize` <number> Sets the maximum dynamic table size for deflating header fields. Default: 4Kib.
21-
-- | `maxSettings` <number> Sets the maximum number of settings entries per SETTINGS frame. The minimum value allowed is 1. Default: 32.
22-
-- | `maxSessionMemory`<number> Sets the maximum memory that the Http2Session is permitted to use. The value is expressed in terms of number of megabytes, e.g. 1 equal 1 megabyte. The minimum value allowed is 1. This is a credit based limit, existing Http2Streams may cause this limit to be exceeded, but new Http2Stream instances will be rejected while this limit is exceeded. The current number of Http2Stream sessions, the current memory use of the header compression tables, current data queued to be sent, and unacknowledged PING and SETTINGS frames are all counted towards the current limit. Default: 10.
23-
-- | `maxHeaderListPairs` <number> Sets the maximum number of header entries. This is similar to server.maxHeadersCount or request.maxHeadersCount in the node:http module. The minimum value is 1. Default: 128.
24-
-- | `maxOutstandingPings` <number> Sets the maximum number of outstanding, unacknowledged pings. Default: 10.
25-
-- | `maxReservedRemoteStreams` <number> Sets the maximum number of reserved push streams the client will accept at any given time. Once the current number of currently reserved push streams exceeds reaches this limit, new push streams sent by the server will be automatically rejected. The minimum allowed value is 0. The maximum allowed value is 232-1. A negative value sets this option to the maximum allowed value. Default: 200.
26-
-- | `maxSendHeaderBlockLength` <number> Sets the maximum allowed size for a serialized, compressed block of headers. Attempts to send headers that exceed this limit will result in a 'frameError' event being emitted and the stream being closed and destroyed.
27-
-- | `paddingStrategy` <number> Strategy used for determining the amount of padding to use for HEADERS and DATA frames. Default: http2.constants.PADDING_STRATEGY_NONE. Value may be one of:
28-
-- | `peerMaxConcurrentStreams` <number> Sets the maximum number of concurrent streams for the remote peer as if a SETTINGS frame had been received. Will be overridden if the remote peer sets its own value for maxConcurrentStreams. Default: 100.
29-
-- | `protocol` <string> The protocol to connect with, if not set in the authority. Value may be either 'http:' or 'https:'. Default: 'https:'
30-
-- | `settings` <HTTP/2 Settings Object> The initial settings to send to the remote peer upon connection.
31-
-- | `createConnection` <Function> An optional callback that receives the URL instance passed to connect and the options object, and returns any Duplex stream that is to be used as the connection for this session.
32-
-- | `unknownProtocolTimeout` <number> Specifies a timeout in milliseconds that a server should wait when an 'unknownProtocol' event is emitted. If the socket has not been destroyed by that time the server will destroy it. Default: 10000.
33-
-- |
34-
-- | Note: `createConnection` is not supported for now.
35-
type ConnectOptions :: (Type -> Type) -> Row Type -> Row Type
36-
type ConnectOptions f r =
37-
( maxDeflateDynamicTableSize :: f Int
38-
, maxSettings :: f Int
39-
, maxSessionMemory :: f Int
40-
, maxHeaderListPairs :: f Int
41-
, maxOutstandingPings :: f Int
42-
, maxReservedRemoteStreams :: f Int
43-
, maxSendHeaderBlockLength :: f Int
44-
, paddingStrategy :: f Int
45-
, peerMaxConcurrentStreams :: f Int
46-
, protocol :: f String
47-
, settings :: f Settings
48-
-- , createConnection :: Function -- not supported for now.
49-
, unknownProtocolTimeout :: f Int
50-
| r
51-
)
52-
53-
type TlsConnectOptions :: (Type -> Type) -> Row Type -> Row Type
54-
type TlsConnectOptions f r =
55-
( enableTrace :: f Boolean
56-
, socket :: f Socket
57-
, allowHalfOpen :: f Boolean
58-
, rejectUnauthorized :: f Boolean
59-
-- , pskCallback :: <Function
60-
, "ALPNProtocols" :: f (Array ImmutableBuffer)
61-
, servername :: f String
62-
-- , checkServerIdentity :: EffectFn2 String ? (Nullable Error) -- ignoring for now
63-
, session :: f ImmutableBuffer
64-
, minDHSize :: f Int
65-
, highWaterMark :: f Int
66-
-- , secureContext :: f TlsSecureContext -- ignoring for now
67-
-- , onread :: <Object> -- ignoring
68-
| r
69-
)
70-
71-
type TcpConnectOptions :: (Type -> Type) -> Row Type -> Row Type
72-
type TcpConnectOptions f r =
73-
( port :: f Int
74-
, host :: f String
75-
, localAddress :: f String
76-
, localPort :: f Int
77-
, family :: f Int
78-
-- , hints :: f number
79-
-- , lookup :: f Function
80-
, noDelay :: f Boolean
81-
, keepAlive :: f Boolean
82-
, keepAliveInitialDelay :: f Number -- is this milliseconds or seconds?
83-
-- , autoSelectFamily :: f Boolean
84-
-- , autoSelectFamilyAttemptTimeout :: f number
85-
| r
86-
)
87-
8818
connect'
8919
:: forall rec trash
90-
. Row.Union rec trash (ConnectOptions Unlift + TlsConnectOptions Unlift + TlsSecureContextOptions Unlift + TcpConnectOptions Unlift + ())
20+
. Row.Union rec trash (Http2ClientConnectOptions (ConnectTlsSocketOptions Client (CreateSecureContextOptions (ConnectTcpOptions ()))))
9121
=> String
9222
-> { | rec }
9323
-> Effect (Http2Session Client)
9424
connect' authority rec = runEffectFn2 connectAuthOptionsImpl authority rec
9525

9626
foreign import connectAuthOptionsImpl :: forall r. EffectFn2 (String) ({ | r }) (Http2Session Client)
9727

98-
type Unlift :: Type -> Type
99-
type Unlift a = a
100-
101-
foreign import undefined :: forall a. a

src/Node/Http2/Server.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
import http2 from "node:http2";
22

33
export const createSecureServerImpl = (opts) => http2.createSecureServer(opts);
4-
export const listenImpl = (s, o) => s.listen(o);
5-
6-
const undefined_ = undefined;
7-
export { undefined_ as undefined }
8-
9-
export const onCheckContinueImpl = (s, cb) => s.on("checkContinue", cb);
10-
export const onConnectionImpl = (s, cb) => s.on("connection", cb);
11-
export const onRequestImpl = (s, cb) => s.on("request", cb);
12-
export const onSessionImpl = (s, cb) => s.on("session", cb);
13-
export const onSessionErrorImpl = (s, cb) => s.on("sessionError", cb);
14-
export const onStreamImpl = (s, cb) => s.on("stream", cb);
15-
export const onTimeoutImpl = (s, cb) => s.on("timeout", cb);
16-
export const onUnknownProtocolImpl = (s, cb) => s.on("unknownProtocol", cb);
17-
export const closeImpl = (s) => s.close();
184
export const setTimeoutImpl = (s, msecs) => s.setTimeout(msecs);
195
export const timeoutImpl = (s) => s.timeout;
206
export const updateSettingsImpl = (s, settings) => s.updateSettings(settings);

0 commit comments

Comments
 (0)