1773ed5f95
Mirror to GitHub / mirror (push) Successful in 26s
Test and Lint / backend-test (push) Successful in 1m11s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m28s
Version and Release / version-bump (push) Successful in 32s
Version and Release / trigger-drone (push) Has been skipped
Original: feat: enhance security logging and ensure rate limit blocks are properly tracked - Add comprehensive logging for rate limit blocks with full request details - IP address (with proper proxy detection), user agent, headers, timestamps - Rate limit info (current count, limit, remaining, reset time) - Separate tracking for auth vs general endpoints - Enhance authentication failure logging - JWT validation failures with detailed error info - Admin auth attempts without token - Failed token validation with user context - All events include IP, path, method, user agent - Improve Winston logger configuration for production - Add automatic log rotation (10MB errors, 50MB combined) - Create separate security.log for auth/rate limit events - Ensure logs directory exists automatically - Add structured JSON format for log aggregation - Support container logging with LOG_TO_CONSOLE env var - Create comprehensive documentation - Security logging guide with examples - Monitoring recommendations - Configuration reference - Add test script to verify logging functionality All rate limit settings remain configurable via admin panel: - Window duration, max requests, auth limits - Skip authenticated requests option - Public endpoints only option 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
96 lines
2.4 KiB
TypeScript
96 lines
2.4 KiB
TypeScript
import { api } from '../config/api';
|
|
|
|
export interface Archive {
|
|
id: number;
|
|
slug: string;
|
|
eventName: string;
|
|
eventDate: string;
|
|
eventType: string;
|
|
hostEmail: string;
|
|
archivedAt: string;
|
|
expiresAt: string;
|
|
photoCount: number;
|
|
originalSize: number;
|
|
archiveSize: number;
|
|
archivePath?: string;
|
|
}
|
|
|
|
export interface ArchiveDetails extends Archive {
|
|
adminEmail: string;
|
|
welcomeMessage?: string;
|
|
colorTheme?: string;
|
|
createdAt: string;
|
|
photos: Array<{
|
|
filename: string;
|
|
type: string;
|
|
size_bytes: number;
|
|
uploaded_at: string;
|
|
}>;
|
|
archiveFile?: {
|
|
size: number;
|
|
createdAt: string;
|
|
path: string;
|
|
};
|
|
}
|
|
|
|
export interface ArchivesResponse {
|
|
archives: Archive[];
|
|
pagination: {
|
|
page: number;
|
|
limit: number;
|
|
total: number;
|
|
totalPages: number;
|
|
};
|
|
}
|
|
|
|
export const archiveService = {
|
|
// Get all archives with pagination
|
|
async getArchives(page: number = 1, limit: number = 20): Promise<ArchivesResponse> {
|
|
const response = await api.get<ArchivesResponse>('/admin/archives', {
|
|
params: { page, limit }
|
|
});
|
|
return response.data;
|
|
},
|
|
|
|
// Get single archive details
|
|
async getArchiveDetails(id: number): Promise<ArchiveDetails> {
|
|
const response = await api.get<ArchiveDetails>(`/admin/archives/${id}`);
|
|
return response.data;
|
|
},
|
|
|
|
// Restore archive
|
|
async restoreArchive(id: number): Promise<void> {
|
|
await api.post(`/admin/archives/${id}/restore`);
|
|
},
|
|
|
|
// Download archive
|
|
async downloadArchive(id: number, filename: string): Promise<void> {
|
|
const response = await api.get(`/admin/archives/${id}/download`, {
|
|
responseType: 'blob'
|
|
});
|
|
|
|
// Create download link
|
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
|
const link = document.createElement('a');
|
|
link.href = url;
|
|
link.setAttribute('download', filename);
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
link.remove();
|
|
window.URL.revokeObjectURL(url);
|
|
},
|
|
|
|
// Delete archive permanently
|
|
async deleteArchive(id: number): Promise<void> {
|
|
await api.delete(`/admin/archives/${id}`);
|
|
},
|
|
|
|
// Format bytes to human readable
|
|
formatBytes(bytes: number): string {
|
|
if (bytes === 0) return '0 Bytes';
|
|
const k = 1024;
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
}
|
|
}; |