clean routes
This commit is contained in:
@@ -427,9 +427,9 @@ export class ApiRequestLogger {
|
||||
/**
|
||||
* Create a logged fetch function
|
||||
*/
|
||||
createLoggedFetch(): typeof window.fetch {
|
||||
createLoggedFetch(): typeof fetch {
|
||||
const logger = this;
|
||||
const originalFetch = window.fetch;
|
||||
const originalFetch = typeof window !== 'undefined' ? window.fetch : fetch;
|
||||
|
||||
return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
||||
const startTime = performance.now();
|
||||
@@ -507,7 +507,7 @@ export function initializeApiLogger(options?: ApiRequestLoggerOptions): ApiReque
|
||||
/**
|
||||
* Fetch interceptor that automatically logs all requests
|
||||
*/
|
||||
export function createLoggedFetch(originalFetch: typeof window.fetch = window.fetch): typeof window.fetch {
|
||||
export function createLoggedFetch(originalFetch: typeof fetch = typeof window !== 'undefined' ? window.fetch : fetch): typeof fetch {
|
||||
const logger = getGlobalApiLogger();
|
||||
|
||||
return async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
||||
|
||||
@@ -70,6 +70,14 @@ export class GlobalErrorHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only initialize in browser environment
|
||||
if (typeof window === 'undefined') {
|
||||
if (this.options.verboseLogging) {
|
||||
this.logger.info('Global error handler skipped (server-side)');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle uncaught JavaScript errors
|
||||
window.addEventListener('error', this.handleWindowError);
|
||||
|
||||
@@ -454,12 +462,14 @@ export class GlobalErrorHandler {
|
||||
* Destroy the error handler and remove all listeners
|
||||
*/
|
||||
destroy(): void {
|
||||
window.removeEventListener('error', this.handleWindowError);
|
||||
window.removeEventListener('unhandledrejection', this.handleUnhandledRejection);
|
||||
|
||||
// Restore original console.error
|
||||
if ((console as any)._originalError) {
|
||||
console.error = (console as any)._originalError;
|
||||
if (typeof window !== 'undefined') {
|
||||
window.removeEventListener('error', this.handleWindowError);
|
||||
window.removeEventListener('unhandledrejection', this.handleUnhandledRejection);
|
||||
|
||||
// Restore original console.error
|
||||
if ((console as any)._originalError) {
|
||||
console.error = (console as any)._originalError;
|
||||
}
|
||||
}
|
||||
|
||||
this.isInitialized = false;
|
||||
|
||||
Reference in New Issue
Block a user