-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@horizon/client in Node.js #571
Comments
Don't include "const Horizon = require('@horizon/client')" on the server. You also won't need POST routes, this is handled by horizon, and websockets that communicate to the database. |
I think this is what That being said, this is confusing and we should document how to do this or make the process easier. Our "isomorphic" method right now is not the greatest. |
@hnordt let me know if including |
@deontologician He can either use webpack, or browserify or include |
He's trying to create an rest endpoint that stores something in the database. You should be able to use the horizon client in Node if you want to, it should be importable without problems. The stack trace he's getting with minified code indicates the wrong thing is being imported, since minified code is only for the browser. Whether the endpoint needs to be set up this way, I can't comment on since I don't know what requirements @hnordt's app has, maybe it needs rest endpoints for other clients. But for the immediate problem he's presented, it seems like he should be able to do it. |
@deontologician it looks like the |
|
@deontologician where/when does the
|
The feature I need is:
So I have started a Horizon server with |
Guess it's going to be tricky getting a client side auth (JWT) then adding it to Node, presumably hitting a websocket connection from a REST endpoint. |
@hnordt this works fine for me using something like
@deontologician as I understand this "isomorphic" approach should be a valid way of interacting with Horizon. While this is awesome! 🎉, I'm having issues getting this to work over https/ssl/wss. The node process running the horizon client (in my setup this is a client separate from the node process running the horizon server - not like the example above), fails to handshake/connect when the horizon server is only available over https. This is the output I'm seeing from node.js:
To be clear, browser clients connecting to the same wss endpoint work fine. (the self signed cert has been loaded in the OS X keychain and is used by the browser) If this is a separate issue, feel free to branch 😃 |
@deontologician @dalanmiller the workaround with the webpack import/export loader for fetch should not be needed anymore thanks to a fix in the fetch-everywhere package! It should be removed with the next version.. |
beautiful! On Fri, Jun 10, 2016, 02:25 Patrick Neschkudla notifications@github.com
|
@flipace I've been watching that other issue unfold. I'm glad it worked out! |
This was fixed by be83b22 |
I need to start a Horizon server and create an endpoint that will store a message in Horizon, so here is what I did:
The problem is that when I run
node server.js
I receive an error:Error: Cannot find module 'imports?this=>global!exports?global.fetch!isomorphic-fetch'
Then I changed
const Horizon = require('@horizon/client')
toconst Horizon = require('@horizon/client/dist/horizon')
, but when I runnode server.js
and dispatch aPOST /messages
call the server crashes and display thehorizon.js
code:Am I doing something wrong?
The text was updated successfully, but these errors were encountered: