Add .json extension to config file.
A tiny bit of refactoring.
This commit is contained in:
parent
75e81e7956
commit
1afe267866
26
app.js
26
app.js
|
@ -74,16 +74,25 @@ router.get('/topics/:cluster', async (req, res, _next) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const buildSocketMessageSender = ({ type, socket }) => message => {
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
type,
|
||||||
|
message
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const deepCopy = object => JSON.parse(JSON.stringify(object))
|
||||||
|
|
||||||
const passwordPlaceholder = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
const passwordPlaceholder = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||||
|
|
||||||
const getClusterData = () =>
|
const getClusterData = () =>
|
||||||
Object.fromEntries(
|
Object.fromEntries(
|
||||||
Object.entries(clusters).map(([key, value]) => {
|
Object.entries(clusters).map(([key, cluster]) => {
|
||||||
value = JSON.parse(JSON.stringify(value))
|
cluster = deepCopy(cluster)
|
||||||
if (value.config.sasl?.password) {
|
if (cluster.config.sasl?.password) {
|
||||||
value.config.sasl.password = passwordPlaceholder
|
cluster.config.sasl.password = passwordPlaceholder
|
||||||
}
|
}
|
||||||
return [key, value.config]
|
return [key, cluster.config]
|
||||||
}))
|
}))
|
||||||
|
|
||||||
router.get('/clusters', async (req, res, _next) => {
|
router.get('/clusters', async (req, res, _next) => {
|
||||||
|
@ -132,13 +141,6 @@ router.put('/clusters', async (req, res, _next) => {
|
||||||
|
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|
||||||
const buildSocketMessageSender = ({ type, socket }) => message => {
|
|
||||||
socket.send(JSON.stringify({
|
|
||||||
type,
|
|
||||||
message
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
const realTimeSearch = async ({ kafka, socket, topic }) =>
|
const realTimeSearch = async ({ kafka, socket, topic }) =>
|
||||||
query.realTimeMessageSearch({
|
query.realTimeMessageSearch({
|
||||||
kafka,
|
kafka,
|
||||||
|
|
|
@ -2,7 +2,7 @@ const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const homedir = require('os').homedir()
|
const homedir = require('os').homedir()
|
||||||
|
|
||||||
const configFilePath = homedir + path.sep + '.kafka-dance'
|
const configFilePath = homedir + path.sep + '.kafka-dance.json'
|
||||||
|
|
||||||
const emptyConfig = () => ({
|
const emptyConfig = () => ({
|
||||||
clusters: {},
|
clusters: {},
|
||||||
|
|
Loading…
Reference in New Issue