loggerverse
Version:
Enterprise-grade logging library with beautiful console output, file rotation, email alerts, and secure web dashboard
110 lines • 3 kB
TypeScript
import type { IncomingMessage } from 'http';
/**
* Dashboard utility functions
*/
export declare class DashboardUtils {
/**
* Generate a secure random session ID
*/
static generateSessionId(): string;
/**
* Hash a password using SHA256
*/
static hashPassword(password: string): string;
/**
* Parse cookies from request headers
*/
static parseCookies(req: IncomingMessage): Record<string, string>;
/**
* Get client IP address from request
*/
static getClientIP(req: IncomingMessage): string;
/**
* Create secure cookie string
*/
static createSecureCookie(name: string, value: string, options?: {
path?: string;
maxAge?: number;
httpOnly?: boolean;
sameSite?: 'Strict' | 'Lax' | 'None';
secure?: boolean;
}): string;
/**
* Clear cookie string
*/
static clearCookie(name: string, path?: string): string;
/**
* Format bytes to human readable format
*/
static formatBytes(bytes: number, decimals?: number): string;
/**
* Format percentage
*/
static formatPercentage(value: number, decimals?: number): string;
/**
* Format uptime from seconds to human readable
*/
static formatUptime(seconds: number): string;
/**
* Validate username format
*/
static isValidUsername(username: string): boolean;
/**
* Validate password strength
*/
static isValidPassword(password: string): boolean;
/**
* Sanitize HTML to prevent XSS
*/
static escapeHtml(unsafe: string): string;
/**
* Parse query string
*/
static parseQuery(queryString: string): Record<string, string>;
/**
* Debounce function
*/
static debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
/**
* Rate limit check
*/
static checkRateLimit(attempts: Map<string, {
count: number;
lastAttempt: number;
}>, key: string, maxAttempts: number, windowMs: number): {
allowed: boolean;
remainingAttempts?: number;
resetTime?: number;
};
/**
* Update rate limit attempts
*/
static updateRateLimit(attempts: Map<string, {
count: number;
lastAttempt: number;
}>, key: string): void;
/**
* Clean expired sessions
*/
static cleanExpiredSessions<T extends {
lastAccess: number;
}>(sessions: Map<string, T>, timeoutMs: number): number;
}
/**
* Template data helpers
*/
export declare class TemplateHelpers {
/**
* Get dashboard template data
*/
static getDashboardData(config: any, session?: any): Record<string, any>;
/**
* Get login template data
*/
static getLoginData(config: any): Record<string, any>;
/**
* Format log entry for display
*/
static formatLogEntry(entry: any): string;
}
//# sourceMappingURL=dashboard-utils.d.ts.map