purescript-node / purescript-node-http Goto Github PK
View Code? Open in Web Editor NEWA wrapper for Node's HTTP APIs
License: MIT License
A wrapper for Node's HTTP APIs
License: MIT License
Hi, using yarn I get
$ yarn add purescript-node-http
...
error Couldn't find package "purescript-node-http" on the "npm" registry.
ok, let's use the git form:
yarn add https://github.com/purescript-node/purescript-node-http
...
error Package "undefined@undefined" doesn't have a "name".
guess there's something missing in the yarn descriptor?
Hello!
Using this library we can start a server but not shut it down. Could we expose Node's server.close
?
https://nodejs.org/api/http.html#http_server_close_callback
I'm happy to contribute this if it would be accepted.
Cheers,
Louis
It would be nice to support node's https
module -- as far as I know, the API is the same.
It seems there is no way to attach error handlers to HTTP servers. Am I missing something?
E.g. the equivalent of the following JS:
var s = http.createServer(h);
s.on('error', function(err) { console.log('oops!', err); });
s.listen(9000); // in case of failure, will call the above callback
Currently, CI fails (as described in #33) because the the tests leave servers running until they are manually torn down. This results in timeout failures as in this failed run. We should fix the tests so that they terminate.
there is already support for this method in https://github.com/purescript-node/purescript-node-net/blob/1fd91c872ecff202ae86b848f2c8d054f7a751f3/src/Node/Net/Server.purs#L72-L88
string means ICP or pipe of socket
http.server inherits from net.server
https://nodejs.org/api/http.html#http_class_http_server
the question is can it return String
if server is created using purescript-node-http?
i.e. should it be
address :: Server -> Effect (Maybe (Either Address String))
or
address :: Server -> Effect (Maybe Address)
I can send a PR, if that's OK?
I want to close
an HTTP
server after one connection. It seems to be impossible? The variable server
is not defined at close server
.
server <- createServer \request response -> do
respond request response
close server (pure unit)
It looks like this is impossible because the Node.js API is bad. createServer
is just a wrapper for the Node.js http.createServer
function. But still.
Hi! I am toying with the idea of writing a web socket server in Purescript. That would require access to the upgrade
events emitted by Node's HTTP servers. It seems like this is not currently supported, right?
I think something like onUpgrade :: Server -> (Request -> Socket -> Buffer -> Effect Unit) -> Effect Unit
would do the trick.
I understand this a niche use case and that client code could go down to the FFI and wrap this itself. But, since this is part of Node's public API, maybe it would make sense to expose this functionality here.
If this sounds like something that this library would want to support, I'd be happy to submit a PR.
The node.js http
module has had support for request.connection
for ages (since version 0.3.0), it's just been poorly documented. Up until the 8.x series it was tucked away in the comment of the 'connection'
event. Since then, it's had its own documentation. I'd like to propose we add support for connection
, but it will require some work for the Socket
it returns.
My guess (and what I mentioned on slack) is that we'll want a purescript-node/purescript-node-net
package, where we have Socket
and all its facilities defined. If that's the case, I'm more than happy to do the work if someone can make the repo. Then, we can expose connection :: Node.HTTP.Request -> Node.Net.Socket
. Does that sound about right?
When running tests for one of my libraries, I tried to print the responseHeaders from a Response and got the following:
Response headers:
TypeError: s.replace is not a function
at exports.showStringImpl (/home/thimotron/Programming/purescript-simple-request/output/Prelude/foreign.js:23
1:19)
I tracked it down to the fact that the responseHeaders in question had a "set-cookie" key with an Array String value.
HTTP/2 is Stable in nodejs v10.10.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.