mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
fix: add user ID for no-auth mode and improve TypeScript imports
Extract improvements from PR #318: 1. Set default user ID in no-auth mode for auth middleware - Ensures consistent behavior when authentication is disabled - Prevents potential issues with undefined user IDs 2. Convert to type-only imports in push notification service - Use TypeScript type imports for better tree shaking - Remove .js extensions from imports for consistency - Minor logging improvement for service worker registration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
ac55f9685c
commit
cd2378c665
2 changed files with 7 additions and 6 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
import { PushNotificationPreferences, PushSubscription } from '../../shared/types.js';
|
import type { PushNotificationPreferences, PushSubscription } from '../../shared/types';
|
||||||
import { createLogger } from '../utils/logger.js';
|
import { createLogger } from '../utils/logger';
|
||||||
import { authClient } from './auth-client.js';
|
import { authClient } from './auth-client';
|
||||||
|
|
||||||
// Re-export types for components
|
// Re-export types for components
|
||||||
export { PushSubscription, PushNotificationPreferences };
|
export type { PushSubscription, PushNotificationPreferences };
|
||||||
export type NotificationPreferences = PushNotificationPreferences;
|
export type NotificationPreferences = PushNotificationPreferences;
|
||||||
|
|
||||||
const logger = createLogger('push-notification-service');
|
const logger = createLogger('push-notification-service');
|
||||||
|
|
@ -71,7 +71,7 @@ export class PushNotificationService {
|
||||||
scope: '/',
|
scope: '/',
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.log('service worker registered');
|
logger.log('service worker registered successfully');
|
||||||
|
|
||||||
// Wait for service worker to be ready
|
// Wait for service worker to be ready
|
||||||
await navigator.serviceWorker.ready;
|
await navigator.serviceWorker.ready;
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,10 @@ export function createAuthMiddleware(config: AuthConfig) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no auth is disabled, allow all requests
|
// If no auth is required, allow all requests
|
||||||
if (config.noAuth) {
|
if (config.noAuth) {
|
||||||
req.authMethod = 'no-auth';
|
req.authMethod = 'no-auth';
|
||||||
|
req.userId = 'no-auth-user'; // Set a default user ID for no-auth mode
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue