Files
michaelschiemer/resources/js/modules/webpush/index.js
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
2025-10-25 19:18:37 +02:00

54 lines
1.9 KiB
JavaScript

/**
* Web Push Module Entry Point
*/
import { WebPushManager } from './WebPushManager.js';
export { WebPushManager };
/**
* Initialize WebPush Module
* Called by framework module system
*/
export function init(config = {}, context = null) {
const apiBase = config.apiBase || '/api/push';
// Use absolute path from site root
// This ensures the Service Worker has the correct scope
const serviceWorkerUrl = config.serviceWorkerUrl || '/js/sw-push.js';
// Check browser support
if (!WebPushManager.isSupported()) {
console.warn('⚠️ WebPush not supported in this browser');
console.warn('Service Worker support:', 'serviceWorker' in navigator);
console.warn('Push Manager support:', 'PushManager' in window);
return null;
}
try {
// Create global instance
window.webPushManager = new WebPushManager({
apiBase,
serviceWorkerUrl,
onSubscriptionChange: (subscription) => {
console.log('🔔 Push subscription changed:', subscription ? 'Subscribed' : 'Unsubscribed');
}
});
console.log('🔔 WebPush Manager initialized (use window.webPushManager)');
console.log('Service Worker URL:', serviceWorkerUrl);
console.log('API Base:', apiBase);
console.log('');
console.log('💡 Usage:');
console.log(' await window.webPushManager.init() // Initialize and register service worker');
console.log(' await window.webPushManager.subscribe() // Subscribe to notifications');
console.log(' await window.webPushManager.unsubscribe() // Unsubscribe');
console.log(' await window.webPushManager.sendTestNotification() // Send test');
return window.webPushManager;
} catch (error) {
console.error('❌ Failed to initialize WebPush Manager:', error);
return null;
}
}