Closed michalCapo closed 6 years ago
Hi @michalCapo, can I see your initialization code?
const options = {};
require('total.js').http('release', options);
F.on('load', function () {
F.server
});
And where is the horizon integration?
Hmm i'm really sorry. It just happens only when i try "watch it" in my IDE (webstorm). Just printing it to console console.log(F.server)
it works.
Right now there is no integration code. I was just trying find out 'how it could be done'.
Does horizon
use WebSocket?
Yes, internally.
I'm sorry for this issue, but at the end it works like a charm:
First you need to start rethinkdb
const options = {};
require('total.js').http('release', options);
F.on('load', function () {
const horizon = require('@horizon/server');
const options = {
project_name: 'myProject',
auto_create_collection: true,
auto_create_index: true,
auth: {
token_secret: 'my_super_secret_secret'
}
};
const horizonServer = horizon(F.server, options);
console.log('Listening on port 8181.');
});
Hmm but debug doesn't work:
const options = {};
require('total.js/debug')(options);
F.on('load', function () {
const horizon = require('@horizon/server');
const options = {
project_name: 'myProject',
auto_create_collection: true,
auto_create_index: true,
auth: {
token_secret: 'my_super_secret_secret'
}
};
const horizonServer = horizon(F.server, options);
console.log('Listening on port 8181.');
});
exception:
ReferenceError: F is not defined
at Object.<anonymous> (/home/capo/my/code/emptyproject-website-master/debug.js:18:1)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
-------------------------> DEBUG PID: 31468 (v2.8.0)
ReferenceError: F is not defined
at Object.<anonymous> (/home/capo/my/code/emptyproject-website-master/debug.js:18:1)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
You need to create a definition file e.g. definitions/horizon.js
:
const Horizon = require('@horizon/server');
const Options = {
project_name: 'myProject',
auto_create_collection: true,
auto_create_index: true,
auth: {
token_secret: 'my_super_secret_secret'
}
};
ON('load', function() {
F.global.horizon = Horizon(F.server, Options);
// or global.horizon = Horizon(...)
});
Total.js/Debug creates a separated thread, it's a bit complicated to explain it.
ok, thanks. BTW: impresive response time.
Thank you, Sometimes I'm faster, but today is weekend.
Hello,
I want to integrate horizon with totaljs. But I dont know how to get http server instance from total.js.
When i'm trying to get
F.server
i got: