From c79414066dad38675bf38e8eca849590186a121a Mon Sep 17 00:00:00 2001 From: Josh Kuhn Date: Thu, 25 Feb 2016 16:23:43 -0800 Subject: [PATCH] Fix library serving --- cli/src/init.js | 1 - cli/src/serve.js | 8 ++------ server/src/server.js | 4 +++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cli/src/init.js b/cli/src/init.js index 79cc52f29..73918ac03 100644 --- a/cli/src/init.js +++ b/cli/src/init.js @@ -13,7 +13,6 @@ const indexHTML = `\ horizon.onConnected(function() { document.querySelector('h1').innerHTML = 'It works!' }); - horizon.onSocketError(e => console.log('booty', e)); horizon.connect(); diff --git a/cli/src/serve.js b/cli/src/serve.js index 36e6b98fc..a349a60fa 100644 --- a/cli/src/serve.js +++ b/cli/src/serve.js @@ -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) => { diff --git a/server/src/server.js b/server/src/server.js index 854d68069..dc014bdf4 100644 --- a/server/src/server.js +++ b/server/src/server.js @@ -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'),