Add frontend URL to config.
This commit is contained in:
parent
76ab13b385
commit
75e81e7956
8
app.js
8
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<WebSocket, ({consumer: Consumer, cluster: { kafka, admin, config }})>} */
|
||||
/** @type {Map<WebSocket, ({consumer: kafka.Consumer, cluster: { kafka, admin, config }})>} */
|
||||
const consumers = new Map()
|
||||
|
||||
buildEscape(consumers, clusters)
|
||||
|
|
10
config.js
10
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()
|
||||
}
|
||||
if (fs.existsSync(configFilePath)) {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(configFilePath).toString())
|
||||
} catch (e) {
|
||||
console.error(e.toString())
|
||||
return emptyConfig()
|
||||
}
|
||||
}
|
||||
return emptyConfig()
|
||||
}
|
||||
|
||||
const storeConfig = async config =>
|
||||
|
|
Loading…
Reference in New Issue