Add .json extension to config file.

A tiny bit of refactoring.
This commit is contained in:
Sage Vaillancourt 2022-09-08 22:50:33 -04:00
parent 75e81e7956
commit 1afe267866
2 changed files with 15 additions and 13 deletions

26
app.js
View File

@ -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 getClusterData = () =>
Object.fromEntries(
Object.entries(clusters).map(([key, value]) => {
value = JSON.parse(JSON.stringify(value))
if (value.config.sasl?.password) {
value.config.sasl.password = passwordPlaceholder
Object.entries(clusters).map(([key, cluster]) => {
cluster = deepCopy(cluster)
if (cluster.config.sasl?.password) {
cluster.config.sasl.password = passwordPlaceholder
}
return [key, value.config]
return [key, cluster.config]
}))
router.get('/clusters', async (req, res, _next) => {
@ -132,13 +141,6 @@ router.put('/clusters', async (req, res, _next) => {
app.use(router)
const buildSocketMessageSender = ({ type, socket }) => message => {
socket.send(JSON.stringify({
type,
message
}))
}
const realTimeSearch = async ({ kafka, socket, topic }) =>
query.realTimeMessageSearch({
kafka,

View File

@ -2,7 +2,7 @@ const fs = require('fs')
const path = require('path')
const homedir = require('os').homedir()
const configFilePath = homedir + path.sep + '.kafka-dance'
const configFilePath = homedir + path.sep + '.kafka-dance.json'
const emptyConfig = () => ({
clusters: {},