mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-20 05:38:18 +02:00
Add feature to automatically delete old sales data for legal compliance
Implements a data purge system, scheduler, and API endpoints for stats and manual execution. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 91318273-c764-4fd4-be04-bdc12c38af32 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/c3a86207-4ee0-47f9-8062-2dbbae696290.jpg
This commit is contained in:
1 parent
686512516d
commit
7404dc6443
5 files changed
+316
-1
No files matched your search
@@ -6,6 +6,7 @@ import connectPg from "connect-pg-simple";
|
||||
import { loginSchema, insertUserSchema, insertStoreSchema, insertSaleSchema } from "@shared/schema";
|
||||
import { z } from "zod";
|
||||
import { createAutomaticBackup, getBackupStats } from "./backup-scheduler";
|
||||
import { executePurgeManually, getPurgeStats } from "./data-purge";
|
||||
|
||||
declare module 'express-session' {
|
||||
interface SessionData {
|
||||
@@ -535,6 +536,27 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
});
|
||||
|
||||
// Admin routes - Data Purge
|
||||
app.get('/api/admin/purge/stats', requireRole(['admin']), async (req, res) => {
|
||||
try {
|
||||
const stats = await getPurgeStats();
|
||||
res.json(stats);
|
||||
} catch (error) {
|
||||
console.error('Get purge stats error:', error);
|
||||
res.status(500).json({ error: "Failed to get purge stats" });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/admin/purge/execute', requireRole(['admin']), async (req, res) => {
|
||||
try {
|
||||
const result = await executePurgeManually();
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
console.error('Execute purge error:', error);
|
||||
res.status(500).json({ error: "Failed to execute purge" });
|
||||
}
|
||||
});
|
||||
|
||||
const httpServer = createServer(app);
|
||||
return httpServer;
|
||||
}
|
||||
Reference in new issue
Block a user