Allow configuration through a file and export images automatically
Introduce a configuration file for all settings, remove the web-based config editor, fix the grid display, and add automatic hourly PNG exports. 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
This commit is contained in:
@@ -2,14 +2,18 @@ import type { Express } from "express";
|
||||
import { createServer, type Server } from "http";
|
||||
import { WebSocketServer, WebSocket } from "ws";
|
||||
import { storage } from "./storage";
|
||||
import { insertPixelSchema, insertCanvasConfigSchema, insertUserCooldownSchema, type WSMessage } from "@shared/schema";
|
||||
import { randomUUID } from "crypto";
|
||||
import { insertPixelSchema, insertUserCooldownSchema, type WSMessage } from "@shared/schema";
|
||||
import { CanvasExporter } from "./export";
|
||||
|
||||
export async function registerRoutes(app: Express): Promise<Server> {
|
||||
const httpServer = createServer(app);
|
||||
const wss = new WebSocketServer({ server: httpServer, path: '/ws' });
|
||||
|
||||
let connectedUsers = new Set<WebSocket>();
|
||||
|
||||
// Initialize canvas exporter
|
||||
const exporter = new CanvasExporter(storage);
|
||||
exporter.startAutoExport();
|
||||
|
||||
// API Routes
|
||||
app.get("/api/pixels", async (req, res) => {
|
||||
@@ -30,22 +34,8 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/api/config", async (req, res) => {
|
||||
try {
|
||||
const configData = insertCanvasConfigSchema.parse(req.body);
|
||||
const config = await storage.updateCanvasConfig(configData);
|
||||
|
||||
// Broadcast config update to all connected clients
|
||||
broadcast({
|
||||
type: "config_updated",
|
||||
data: configData,
|
||||
});
|
||||
|
||||
res.json(config);
|
||||
} catch (error) {
|
||||
res.status(400).json({ message: "Invalid config data" });
|
||||
}
|
||||
});
|
||||
// Config is now read-only from file
|
||||
// Remove the POST endpoint for config updates
|
||||
|
||||
app.post("/api/pixels", async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user