🔧 Enhance Middleware and Admin Features

 Updated Middleware Logic:
- Enhanced admin route protection with Basic Auth for legacy routes and session-based auth for `/manage` and `/editor`.

 Improved Admin Panel Styles:
- Added glassmorphism styles for admin components to enhance UI aesthetics.

 Refined Rate Limiting:
- Adjusted rate limits for admin dashboard requests to allow more generous access.

 Introduced Analytics Reset API:
- Added a new endpoint for resetting analytics data with rate limiting and admin authentication.

🎯 Overall Improvements:
- Strengthened security and user experience for admin functionalities.
- Enhanced visual design for better usability.
- Streamlined analytics management processes.
This commit is contained in:
2025-09-09 19:50:52 +02:00
parent 0ae1883cf4
commit be01ee2adb
26 changed files with 4518 additions and 1103 deletions

View File

@@ -19,7 +19,7 @@ export function verifyAdminAuth(request: NextRequest): boolean {
const [expectedUsername, expectedPassword] = adminAuth.split(':');
return username === expectedUsername && password === expectedPassword;
} catch (error) {
} catch {
return false;
}
}

View File

@@ -71,7 +71,7 @@ export const projectService = {
return prisma.project.create({
data: {
...data,
performance: data.performance || { lighthouse: 90, bundleSize: '50KB', loadTime: '1.5s' },
performance: data.performance || { lighthouse: 0, bundleSize: '0KB', loadTime: '0s' },
analytics: data.analytics || { views: 0, likes: 0, shares: 0 }
} as any // eslint-disable-line @typescript-eslint/no-explicit-any
});

View File

@@ -141,5 +141,18 @@ export const analyticsCache = {
async invalidateProject(projectId: number) {
await cache.del(`analytics:project:${projectId}`);
await cache.del('analytics:overall');
},
async clearAll() {
try {
const client = await getRedisClient();
// Clear all analytics-related keys
const keys = await client.keys('analytics:*');
if (keys.length > 0) {
await client.del(keys);
}
} catch (error) {
console.error('Error clearing analytics cache:', error);
}
}
};