Added new codebook page

This commit is contained in:
2026-04-06 02:49:14 -04:00
parent 32a690d85b
commit 3cb34a226a
31 changed files with 4076 additions and 4067 deletions
+38
View File
@@ -0,0 +1,38 @@
import dotenv from 'dotenv';
import * as fs from 'node:fs';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import { execSync } from "child_process";
dotenv.config();
export const environment = {
config: process.env.CONFIG || 'config.json',
hostname: process.env.HOSTNAME || execSync('hostname', { encoding: "utf-8" }) || 'localhost',
gpsd: process.env.GPSD || 2947,
port: process.env.PORT || 80,
root: dirname(dirname(fileURLToPath(import.meta.url))),
settings: {},
}
if(!environment.config.startsWith('/')) environment.config = `${environment.root}/${environment.config}`;
export function loadSettings() {
if(!fs.existsSync(environment.config)) fs.writeFileSync(environment.config, '', { flag: 'a' });
const value = fs.readFileSync(environment.config, 'utf-8');
try { return JSON.parse(value); }
catch (e) {
return {
lora: {
mode: 'MESH',
telemetry: true,
}
};
}
}
export function saveSettings() {
fs.writeFileSync(environment.config, JSON.stringify(environment.settings, null, 4));
}
loadSettings();