Skip to content

Commit cfd1a28

Browse files
Update node libs (#48)
* Update PS deps in bower.json * Make code compile again * Add entry * Close server after responding to first test; disable testUpgrades
1 parent 9baab9d commit cfd1a28

File tree

6 files changed

+138
-72
lines changed

6 files changed

+138
-72
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based
55
## [Unreleased]
66

77
Breaking changes:
8+
- Update node libraries to latest releases (#48 by @JordanMartinez)
89

910
New features:
1011

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"purescript-foreign": "^7.0.0",
2222
"purescript-foreign-object": "^4.0.0",
2323
"purescript-maybe": "^6.0.0",
24-
"purescript-node-buffer": "^8.0.0",
25-
"purescript-node-net": "^4.0.0",
26-
"purescript-node-streams": "^7.0.0",
24+
"purescript-node-buffer": "^9.0.0",
25+
"purescript-node-net": "^5.1.0",
26+
"purescript-node-streams": "^9.0.0",
2727
"purescript-node-url": "^6.0.0",
2828
"purescript-nullable": "^6.0.0",
2929
"purescript-options": "^7.0.0",

src/Node/HTTP.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Data.Nullable (Nullable, toNullable)
3333
import Effect (Effect)
3434
import Foreign.Object (Object)
3535
import Node.Buffer (Buffer)
36-
import Node.Net.Socket (Socket)
36+
import Node.Net.Types (Socket, TCP)
3737
import Node.Stream (Writable, Readable)
3838
import Unsafe.Coerce (unsafeCoerce)
3939

@@ -72,10 +72,10 @@ type ListenOptions =
7272
foreign import listenSocket :: Server -> String -> Effect Unit -> Effect Unit
7373

7474
-- | Listen to `connect` events on the server
75-
foreign import onConnect :: Server -> (Request -> Socket -> Buffer -> Effect Unit) -> Effect Unit
75+
foreign import onConnect :: Server -> (Request -> Socket TCP -> Buffer -> Effect Unit) -> Effect Unit
7676

7777
-- | Listen to `upgrade` events on the server
78-
foreign import onUpgrade :: Server -> (Request -> Socket -> Buffer -> Effect Unit) -> Effect Unit
78+
foreign import onUpgrade :: Server -> (Request -> Socket TCP -> Buffer -> Effect Unit) -> Effect Unit
7979

8080
-- | Get the request HTTP version
8181
httpVersion :: Request -> String

src/Node/HTTP/Secure.purs

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,17 @@ import Unsafe.Coerce (unsafeCoerce)
9090

9191
-- | Create an HTTPS server, given the SSL options and a function to be executed
9292
-- | when a request is received.
93-
foreign import createServerImpl ::
94-
Foreign ->
95-
(Request -> Response -> Effect Unit) ->
96-
Effect Server
93+
foreign import createServerImpl
94+
:: Foreign
95+
-> (Request -> Response -> Effect Unit)
96+
-> Effect Server
9797

9898
-- | Create an HTTPS server, given the SSL options and a function to be executed
9999
-- | when a request is received.
100-
createServer :: Options SSLOptions ->
101-
(Request -> Response -> Effect Unit) ->
102-
Effect Server
100+
createServer
101+
:: Options SSLOptions
102+
-> (Request -> Response -> Effect Unit)
103+
-> Effect Server
103104
createServer = createServerImpl <<< options
104105

105106
-- | The type of HTTPS server options
@@ -120,16 +121,22 @@ rejectUnauthorized = opt "rejectUnauthorized"
120121
-- | The npnProtocols option can be a String, a Buffer, a Uint8Array, or an
121122
-- | array of any of those types.
122123
data NPNProtocols
124+
123125
npnProtocolsString :: String -> NPNProtocols
124126
npnProtocolsString = unsafeCoerce
127+
125128
npnProtocolsBuffer :: Buffer -> NPNProtocols
126129
npnProtocolsBuffer = unsafeCoerce
130+
127131
npnProtocolsUint8Array :: Uint8Array -> NPNProtocols
128132
npnProtocolsUint8Array = unsafeCoerce
133+
129134
npnProtocolsStringArray :: Array String -> NPNProtocols
130135
npnProtocolsStringArray = unsafeCoerce
136+
131137
npnProtocolsBufferArray :: Array Buffer -> NPNProtocols
132138
npnProtocolsBufferArray = unsafeCoerce
139+
133140
npnProtocolsUint8ArrayArray :: Array Uint8Array -> NPNProtocols
134141
npnProtocolsUint8ArrayArray = unsafeCoerce
135142

@@ -140,16 +147,22 @@ npnProtocols = opt "NPNProtocols"
140147
-- | The alpnProtocols option can be a String, a Buffer, a Uint8Array, or an
141148
-- | array of any of those types.
142149
data ALPNProtocols
150+
143151
alpnProtocolsString :: String -> ALPNProtocols
144152
alpnProtocolsString = unsafeCoerce
153+
145154
alpnProtocolsBuffer :: Buffer -> ALPNProtocols
146155
alpnProtocolsBuffer = unsafeCoerce
156+
147157
alpnProtocolsUint8Array :: Uint8Array -> ALPNProtocols
148158
alpnProtocolsUint8Array = unsafeCoerce
159+
149160
alpnProtocolsStringArray :: Array String -> ALPNProtocols
150161
alpnProtocolsStringArray = unsafeCoerce
162+
151163
alpnProtocolsBufferArray :: Array Buffer -> ALPNProtocols
152164
alpnProtocolsBufferArray = unsafeCoerce
165+
153166
alpnProtocolsUint8ArrayArray :: Array Uint8Array -> ALPNProtocols
154167
alpnProtocolsUint8ArrayArray = unsafeCoerce
155168

@@ -167,8 +180,10 @@ ticketKeys = opt "ticketKeys"
167180

168181
-- | The PFX option can take either a String or a Buffer
169182
data PFX
183+
170184
pfxString :: String -> PFX
171185
pfxString = unsafeCoerce
186+
172187
pfxBuffer :: Buffer -> PFX
173188
pfxBuffer = unsafeCoerce
174189

@@ -179,12 +194,16 @@ pfx = opt "pfx"
179194
-- | The key option can be a String, a Buffer, an array of strings, or an array
180195
-- | of buffers.
181196
data Key
197+
182198
keyString :: String -> Key
183199
keyString = unsafeCoerce
200+
184201
keyBuffer :: Buffer -> Key
185202
keyBuffer = unsafeCoerce
203+
186204
keyStringArray :: Array String -> Key
187205
keyStringArray = unsafeCoerce
206+
188207
keyBufferArray :: Array Buffer -> Key
189208
keyBufferArray = unsafeCoerce
190209

@@ -199,12 +218,16 @@ passphrase = opt "passphrase"
199218
-- | The cert option can be a String, a Buffer, an array of strings, or an array
200219
-- | of buffers.
201220
data Cert
221+
202222
certString :: String -> Cert
203223
certString = unsafeCoerce
224+
204225
certBuffer :: Buffer -> Cert
205226
certBuffer = unsafeCoerce
227+
206228
certStringArray :: Array String -> Cert
207229
certStringArray = unsafeCoerce
230+
208231
certBufferArray :: Array Buffer -> Cert
209232
certBufferArray = unsafeCoerce
210233

@@ -215,12 +238,16 @@ cert = opt "cert"
215238
-- | The CA option can be a String, a Buffer, an array of strings, or an array
216239
-- | of buffers.
217240
data CA
241+
218242
caString :: String -> CA
219243
caString = unsafeCoerce
244+
220245
caBuffer :: Buffer -> CA
221246
caBuffer = unsafeCoerce
247+
222248
caStringArray :: Array String -> CA
223249
caStringArray = unsafeCoerce
250+
224251
caBufferArray :: Array Buffer -> CA
225252
caBufferArray = unsafeCoerce
226253

@@ -231,12 +258,16 @@ ca = opt "ca"
231258
-- | The CRL option can be a String, a Buffer, an array of strings, or an array
232259
-- | of buffers.
233260
data CRL
261+
234262
crlString :: String -> CRL
235263
crlString = unsafeCoerce
264+
236265
crlBuffer :: Buffer -> CRL
237266
crlBuffer = unsafeCoerce
267+
238268
crlStringArray :: Array String -> CRL
239269
crlStringArray = unsafeCoerce
270+
240271
crlBufferArray :: Array Buffer -> CRL
241272
crlBufferArray = unsafeCoerce
242273

@@ -258,8 +289,10 @@ ecdhCurve = opt "ecdhCurve"
258289

259290
-- | The DHParam option can take either a String or a Buffer
260291
data DHParam
292+
261293
dhparamString :: String -> DHParam
262294
dhparamString = unsafeCoerce
295+
263296
dhparamBuffer :: Buffer -> DHParam
264297
dhparamBuffer = unsafeCoerce
265298

test/Main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
import http from "node:http";
2+
import https from "node:https";
3+
export const createServerOnly = () => http.createServer();
4+
export const createSecureServerOnlyImpl = (opts) => https.createServer(opts);
5+
export const onRequestImpl = (server, cb) => server.on("request", cb);
16
export const stdout = process.stdout;
7+
export const setTimeoutImpl = (int, cb) => setTimeout(cb, int);

0 commit comments

Comments
 (0)