diff --git a/app.js b/app.js index ef394ae..74249fb 100644 --- a/app.js +++ b/app.js @@ -48,7 +48,7 @@ console.log('CLUSTERS', clusters) const app = express(); app.use(cors({ - origin: 'http://localhost:5173' + origin: config.frontendUrl, })) app.use(logger('dev')); app.use(express.json()); @@ -155,14 +155,12 @@ const oneShotSearch = async ({ kafka, socket, topic, maxItems }) => onBatchDone: buildSocketMessageSender({ socket, type: 'item_count' }) }) -/** - * @type {WebSocketServer} - */ +/** @type {WebSocketServer} */ const wsServer = new ws.WebSocketServer({ noServer: true }) -/** @type {Map} */ +/** @type {Map} */ const consumers = new Map() buildEscape(consumers, clusters) diff --git a/config.js b/config.js index 68745d5..e8b5090 100644 --- a/config.js +++ b/config.js @@ -5,19 +5,19 @@ const homedir = require('os').homedir() const configFilePath = homedir + path.sep + '.kafka-dance' const emptyConfig = () => ({ - clusters: {} + clusters: {}, + frontendUrl: 'http://localhost:5173', }) const readConfig = () => { - if (!fs.existsSync(configFilePath)) { - return emptyConfig() - } - try { - return JSON.parse(fs.readFileSync(configFilePath).toString()) - } catch (e) { - console.error(e.toString()) - return emptyConfig() + if (fs.existsSync(configFilePath)) { + try { + return JSON.parse(fs.readFileSync(configFilePath).toString()) + } catch (e) { + console.error(e.toString()) + } } + return emptyConfig() } const storeConfig = async config =>