place_maxlan/server/config.ts
freesemar93 59eb9e4040 Remove grid functionality from the pixel art creation platform
Removes the grid display option, grid toggle button, and related configuration settings from the canvas component, CSS, and server configuration files.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 0385ea33-cde8-4bbd-8fce-8d192d30eb41
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/870d08ce-da3b-4822-9874-c2fe2b7628b1/0385ea33-cde8-4bbd-8fce-8d192d30eb41/Zffw2vY
2025-08-18 12:21:53 +00:00

88 lines
2.6 KiB
TypeScript

import { readFileSync } from "fs";
import { join } from "path";
interface Config {
canvasWidth: number;
canvasHeight: number;
defaultCooldown: number;
enableAutomaticEvents: boolean;
eventDurationMinutes: number;
eventIntervalHours: number;
autoExportIntervalSeconds: number;
exportPath: string;
}
function parseConfigFile(): Config {
try {
const configPath = join(process.cwd(), "config.cfg");
const configContent = readFileSync(configPath, "utf-8");
const config: Partial<Config> = {};
configContent.split("\n").forEach(line => {
line = line.trim();
if (line.startsWith("#") || !line.includes("=")) return;
const [key, value] = line.split("=");
const trimmedKey = key.trim();
const trimmedValue = value.trim();
switch (trimmedKey) {
case "CANVAS_WIDTH":
config.canvasWidth = parseInt(trimmedValue);
break;
case "CANVAS_HEIGHT":
config.canvasHeight = parseInt(trimmedValue);
break;
case "DEFAULT_COOLDOWN":
config.defaultCooldown = parseInt(trimmedValue);
break;
case "ENABLE_AUTOMATIC_EVENTS":
config.enableAutomaticEvents = trimmedValue.toLowerCase() === "true";
break;
case "EVENT_DURATION_MINUTES":
config.eventDurationMinutes = parseInt(trimmedValue);
break;
case "EVENT_INTERVAL_HOURS":
config.eventIntervalHours = parseInt(trimmedValue);
break;
case "AUTO_EXPORT_INTERVAL_SECONDS":
config.autoExportIntervalSeconds = parseInt(trimmedValue);
break;
case "EXPORT_PATH":
config.exportPath = trimmedValue;
break;
}
});
// Set defaults for missing values
return {
canvasWidth: config.canvasWidth || 100,
canvasHeight: config.canvasHeight || 100,
defaultCooldown: config.defaultCooldown || 5,
enableAutomaticEvents: config.enableAutomaticEvents || false,
eventDurationMinutes: config.eventDurationMinutes || 30,
eventIntervalHours: config.eventIntervalHours || 6,
autoExportIntervalSeconds: config.autoExportIntervalSeconds || 60,
exportPath: config.exportPath || "./exports/",
};
} catch (error) {
console.error("Error reading config file, using defaults:", error);
return {
canvasWidth: 100,
canvasHeight: 100,
defaultCooldown: 5,
enableAutomaticEvents: false,
eventDurationMinutes: 30,
eventIntervalHours: 6,
autoExportIntervalSeconds: 60,
exportPath: "./exports/",
};
}
}
export const config = parseConfigFile();