Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/core/admin/fetchConfigHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export class FetchConfigHandler extends AdminCommandHandler {
}

async handle(task: AdminFetchConfigCommand): Promise<P2PCommandResponse> {
console.log({ task, message: 'FETCH_CONFIG_P2P_COMMAND' })
const validation = await this.validate(task)
console.log({ validation, message: 'FETCH_CONFIG_P2P_COMMAND' })
if (!validation.valid) {
return new Promise<P2PCommandResponse>((resolve) => {
resolve(buildInvalidParametersResponse(validation))
Expand All @@ -25,6 +27,10 @@ export class FetchConfigHandler extends AdminCommandHandler {
const config = loadConfigFromFile()
config.keys.privateKey = '[*** HIDDEN CONTENT ***]'

console.log({
responseConfig: JSON.stringify(config),
message: 'FETCH_CONFIG_P2P_COMMAND'
})
return new Promise<P2PCommandResponse>((resolve) => {
resolve({
status: { httpStatus: 200 },
Expand Down
6 changes: 6 additions & 0 deletions src/components/core/admin/pushConfigHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@
}

async handle(task: AdminPushConfigCommand): Promise<P2PCommandResponse> {
console.log({ task, message: 'PUSH_CONFIG_P2P_COMMAND' })
const validation = await this.validate(task)
if (!validation.valid) {
return new Promise<P2PCommandResponse>((resolve) => {
resolve(buildInvalidParametersResponse(validation))
})
}
console.log({ validation, message: 'PUSH_CONFIG_P2P_COMMAND' })

try {
const configPath = getConfigFilePath()
const configContent = await fs.promises.readFile(configPath, 'utf-8')

Check warning on line 57 in src/components/core/admin/pushConfigHandler.ts

View workflow job for this annotation

GitHub Actions / lint

Found readFile from package "fs" with non literal argument at index 0
const currentConfig = JSON.parse(configContent)

const mergedConfig = { ...currentConfig, ...task.config }
Expand All @@ -62,6 +64,10 @@
newConfig.keys.privateKey = '[*** HIDDEN CONTENT ***]'
CORE_LOGGER.logMessage('Configuration reloaded successfully')

console.log({
responseConfig: JSON.stringify(newConfig),
message: 'PUSH_CONFIG_P2P_COMMAND'
})
return new Promise<P2PCommandResponse>((resolve) => {
resolve({
status: { httpStatus: 200 },
Expand All @@ -82,7 +88,7 @@
private async saveConfigToFile(config: Record<string, any>): Promise<void> {
const configPath = getConfigFilePath()
const content = JSON.stringify(config, null, 4)
await fs.promises.writeFile(configPath, content, 'utf-8')

Check warning on line 91 in src/components/core/admin/pushConfigHandler.ts

View workflow job for this annotation

GitHub Actions / lint

Found writeFile from package "fs" with non literal argument at index 0
CORE_LOGGER.logMessage(`Config saved to: ${configPath}`)
}
}
Loading