Major Enhancement: NestJS Migration + CASL Authorization + Error Handling
Some checks failed
CI/CD Pipeline / Backend Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Tests (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled

Complete rewrite from Express to NestJS with enterprise-grade features:

## Backend Improvements
- Migrated from Express to NestJS 11.0.1 with TypeScript
- Implemented Prisma ORM 7.3.0 for type-safe database access
- Added CASL authorization system replacing role-based guards
- Created global exception filters with structured logging
- Implemented Auth0 JWT authentication with Passport.js
- Added vehicle management with conflict detection
- Enhanced event scheduling with driver/vehicle assignment
- Comprehensive error handling and logging

## Frontend Improvements
- Upgraded to React 19.2.0 with Vite 7.2.4
- Implemented CASL-based permission system
- Added AbilityContext for declarative permissions
- Created ErrorHandler utility for consistent error messages
- Enhanced API client with request/response logging
- Added War Room (Command Center) dashboard
- Created VIP Schedule view with complete itineraries
- Implemented Vehicle Management UI
- Added mock data generators for testing (288 events across 20 VIPs)

## New Features
- Vehicle fleet management (types, capacity, status tracking)
- Complete 3-day Jamboree schedule generation
- Individual VIP schedule pages with PDF export (planned)
- Real-time War Room dashboard with auto-refresh
- Permission-based navigation filtering
- First user auto-approval as administrator

## Documentation
- Created CASL_AUTHORIZATION.md (comprehensive guide)
- Created ERROR_HANDLING.md (error handling patterns)
- Updated CLAUDE.md with new architecture
- Added migration guides and best practices

## Technical Debt Resolved
- Removed custom authentication in favor of Auth0
- Replaced role checks with CASL abilities
- Standardized error responses across API
- Implemented proper TypeScript typing
- Added comprehensive logging

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 08:50:25 +01:00
parent 8ace1ab2c1
commit 868f7efc23
351 changed files with 44997 additions and 6276 deletions

View File

@@ -1,14 +1,14 @@
import React, { Component, ErrorInfo, ReactNode } from 'react';
import React, { Component, ReactNode } from 'react';
import { AlertTriangle, RefreshCw, Home } from 'lucide-react';
interface Props {
children: ReactNode;
fallback?: ReactNode;
}
interface State {
hasError: boolean;
error: Error | null;
errorInfo: ErrorInfo | null;
errorInfo: React.ErrorInfo | null;
}
export class ErrorBoundary extends Component<Props, State> {
@@ -17,7 +17,7 @@ export class ErrorBoundary extends Component<Props, State> {
this.state = {
hasError: false,
error: null,
errorInfo: null
errorInfo: null,
};
}
@@ -25,83 +25,72 @@ export class ErrorBoundary extends Component<Props, State> {
return {
hasError: true,
error,
errorInfo: null
errorInfo: null,
};
}
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
console.error('ErrorBoundary caught an error:', error, errorInfo);
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
console.error('[ERROR BOUNDARY] Caught error:', error, errorInfo);
this.setState({
errorInfo
error,
errorInfo,
});
}
handleReset = () => {
this.setState({
hasError: false,
error: null,
errorInfo: null
});
handleReload = () => {
window.location.reload();
};
handleGoHome = () => {
window.location.href = '/';
};
render() {
if (this.state.hasError) {
if (this.props.fallback) {
return <>{this.props.fallback}</>;
}
return (
<div className="min-h-screen flex items-center justify-center bg-gray-100">
<div className="bg-white p-8 rounded-lg shadow-md max-w-2xl w-full">
<div className="flex items-center mb-4">
<svg
className="w-8 h-8 text-red-500 mr-3"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
/>
</svg>
<h1 className="text-2xl font-bold text-gray-800">Something went wrong</h1>
<div className="min-h-screen bg-gray-50 flex items-center justify-center p-4">
<div className="max-w-md w-full bg-white rounded-lg shadow-xl p-8">
<div className="flex justify-center mb-6">
<div className="rounded-full bg-red-100 p-4">
<AlertTriangle className="h-12 w-12 text-red-600" />
</div>
</div>
<p className="text-gray-600 mb-6">
We're sorry, but something unexpected happened. Please try refreshing the page or contact support if the problem persists.
<h1 className="text-2xl font-bold text-gray-900 text-center mb-4">
Something went wrong
</h1>
<p className="text-gray-600 text-center mb-6">
The application encountered an unexpected error. Please try refreshing the page or returning to the home page.
</p>
{import.meta.env.DEV && this.state.error && (
<details className="mb-6">
<summary className="cursor-pointer text-sm text-gray-500 hover:text-gray-700">
Error details (development mode only)
</summary>
<div className="mt-2 p-4 bg-gray-100 rounded text-xs">
<p className="font-mono text-red-600 mb-2">{this.state.error.toString()}</p>
{this.state.errorInfo && (
<pre className="text-gray-700 overflow-auto">
{this.state.errorInfo.componentStack}
</pre>
)}
</div>
</details>
{process.env.NODE_ENV === 'development' && this.state.error && (
<div className="mb-6 p-4 bg-red-50 border border-red-200 rounded-lg overflow-auto">
<p className="text-sm font-mono text-red-800 mb-2">
{this.state.error.toString()}
</p>
{this.state.errorInfo && (
<pre className="text-xs text-red-700 overflow-auto max-h-40">
{this.state.errorInfo.componentStack}
</pre>
)}
</div>
)}
<div className="flex space-x-4">
<div className="flex gap-3">
<button
onClick={() => window.location.reload()}
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors"
onClick={this.handleReload}
className="flex-1 inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-primary hover:bg-primary/90"
>
Refresh Page
<RefreshCw className="h-4 w-4 mr-2" />
Reload Page
</button>
<button
onClick={this.handleReset}
className="px-4 py-2 bg-gray-200 text-gray-800 rounded hover:bg-gray-300 transition-colors"
onClick={this.handleGoHome}
className="flex-1 inline-flex items-center justify-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
>
Try Again
<Home className="h-4 w-4 mr-2" />
Go Home
</button>
</div>
</div>
@@ -111,4 +100,4 @@ export class ErrorBoundary extends Component<Props, State> {
return this.props.children;
}
}
}