Skip to content

Commit

Permalink
Fix library serving
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Kuhn committed Feb 26, 2016
1 parent 3976895 commit c794140
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion cli/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const indexHTML = `\
horizon.onConnected(function() {
document.querySelector('h1').innerHTML = 'It works!'
});
horizon.onSocketError(e => console.log('booty', e));
horizon.connect();
</script>
</head>
Expand Down
8 changes: 2 additions & 6 deletions cli/src/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,14 @@ const serve_file = (file_path, res) => {

const fileServer = (distDir) => (req, res) => {
const req_path = url.parse(req.url).pathname;
const horizonMatch = req_path.match(/\/horizon\/(horizon\.js(?:\.map)?)$/);
// Serve client files directly
if (req_path === '/' || req_path === '') {
serve_file(path.join(distDir, 'index.html'), res);
} else if (horizonMatch) {
const horizonDir = path.dirname(require.resolve('@horizon/client'));
serve_file(path.join(horizonDir, horizonMatch[1]), res);
} else if (!req_path.match(/\/horizon\/.*/)) {
} else if (!req_path.match(/\/horizon\/.*$/)) {
// All other static files come from the dist directory
serve_file(path.join(distDir, req_path), res);
}
// Fall through otherwise. Should be handled by horizon websocket
// Fall through otherwise. Should be handled by horizon server
};

const createInsecureServers = (opts) => {
Expand Down
4 changes: 3 additions & 1 deletion server/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const logger = require('./logger');
const horizon_protocol = require('./schema/horizon_protocol');
const options_schema = require('./schema/server_options').server;

const horizon_client_path = require.resolve('@horizon/client');
// TODO: dynamically serve different versions of the horizon
// library. Minified, Rx included etc.
const horizon_client_path = require.resolve('@horizon/client/dist/horizon');

const endpoints = {
insert: require('./endpoint/insert'),
Expand Down

0 comments on commit c794140

Please sign in to comment.