#2 implement debugger
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("client", "client.express.setupRoutes");
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import express from 'express';
|
||||
@@ -15,7 +17,7 @@ let nodeData = {};
|
||||
|
||||
router.get('/', async (req, res) => {
|
||||
const output = await launchProcess('python', ['./discordAudioBot/pdab/getDevices.py'], true, true)
|
||||
console.log("Device List", output);
|
||||
log.INFO("Device List", output);
|
||||
res.render('setup/setup', { deviceList: output });
|
||||
});
|
||||
|
||||
@@ -28,7 +30,7 @@ router.post('/', (req, res) => {
|
||||
// Handle form submission here
|
||||
const { clientName, clientLocation, clientCapabilities, audioDeviceId } = req.body;
|
||||
|
||||
console.log(clientName, clientLocation, clientCapabilities, audioDeviceId);
|
||||
log.INFO(clientName, clientLocation, clientCapabilities, audioDeviceId);
|
||||
|
||||
nodeData.clientName = clientName;
|
||||
nodeData.clientLocation = clientLocation;
|
||||
@@ -44,11 +46,11 @@ router.post('/add-system', (req, res) => {
|
||||
|
||||
// Store system information for later use
|
||||
// For now, let's just log the information
|
||||
console.log('System Name:', systemName);
|
||||
console.log('Frequencies:', frequencies);
|
||||
console.log('Mode:', mode);
|
||||
console.log('Trunk File:', trunkFile);
|
||||
console.log('Whitelist File:', whitelistFile);
|
||||
log.INFO('System Name:', systemName);
|
||||
log.INFO('Frequencies:', frequencies);
|
||||
log.INFO('Mode:', mode);
|
||||
log.INFO('Trunk File:', trunkFile);
|
||||
log.INFO('Whitelist File:', whitelistFile);
|
||||
|
||||
// Store system information in the array
|
||||
systemsData.push({
|
||||
@@ -67,7 +69,7 @@ router.post('/add-system', (req, res) => {
|
||||
router.post('/finish-setup', async (req, res) => {
|
||||
// Write collected information to .env file
|
||||
// For now, let's just log the collected information
|
||||
console.log('Collected System Information:', nodeData, systemsData);
|
||||
log.INFO('Collected System Information:', nodeData, systemsData);
|
||||
|
||||
if (!await exportCsv(nodeData)) return res.status(500).send('Error writing to .env file');
|
||||
|
||||
@@ -82,7 +84,7 @@ export default router;
|
||||
|
||||
const exportCsv = (nodeData) => {
|
||||
const nuid = generateUniqueID();
|
||||
console.log(`Generated a new unique ID for this node: '${nuid}'`);
|
||||
log.INFO(`Generated a new unique ID for this node: '${nuid}'`);
|
||||
const envData = {
|
||||
CLIENT_NUID: nuid,
|
||||
CLIENT_NAME: nodeData.clientName,
|
||||
@@ -109,10 +111,10 @@ const exportCsv = (nodeData) => {
|
||||
// File doesn't exist, create it
|
||||
fs.writeFile('.env', envContent, (writeErr) => {
|
||||
if (writeErr) {
|
||||
console.error('Error writing to .env file:', writeErr);
|
||||
log.ERROR('Error writing to .env file:', writeErr);
|
||||
res(false);
|
||||
} else {
|
||||
console.log('.env file created successfully');
|
||||
log.INFO('.env file created successfully');
|
||||
res(true);
|
||||
}
|
||||
});
|
||||
@@ -120,10 +122,10 @@ const exportCsv = (nodeData) => {
|
||||
// File exists, update it
|
||||
fs.writeFile('.env', envContent, (writeErr) => {
|
||||
if (writeErr) {
|
||||
console.error('Error writing to .env file:', writeErr);
|
||||
log.ERROR('Error writing to .env file:', writeErr);
|
||||
res(false);
|
||||
} else {
|
||||
console.log('.env file updated successfully');
|
||||
log.INFO('.env file updated successfully');
|
||||
res(true);
|
||||
}
|
||||
});
|
||||
@@ -155,10 +157,10 @@ const exportSystems = (systemsData) => {
|
||||
// File doesn't exist, create it
|
||||
fs.writeFile(radioPresetsPath, JSON.stringify(radioPresetsData, null, 4), (writeErr) => {
|
||||
if (writeErr) {
|
||||
console.error('Error writing to radioPresets.json:', writeErr);
|
||||
log.ERROR('Error writing to radioPresets.json:', writeErr);
|
||||
res(false);
|
||||
} else {
|
||||
console.log('radioPresets.json created successfully');
|
||||
log.INFO('radioPresets.json created successfully');
|
||||
res(true);
|
||||
}
|
||||
});
|
||||
@@ -166,10 +168,10 @@ const exportSystems = (systemsData) => {
|
||||
// File exists, update it
|
||||
fs.writeFile(radioPresetsPath, JSON.stringify(radioPresetsData, null, 4), (writeErr) => {
|
||||
if (writeErr) {
|
||||
console.error('Error writing to radioPresets.json:', writeErr);
|
||||
log.ERROR('Error writing to radioPresets.json:', writeErr);
|
||||
res(false);
|
||||
} else {
|
||||
console.log('radioPresets.json updated successfully');
|
||||
log.INFO('radioPresets.json updated successfully');
|
||||
res(true);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user