Added complete calendar deletion functionality including: - Context menu component with right-click activation on calendar items - Backend API endpoint for calendar deletion with CalDAV DELETE method - Frontend integration with calendar list refresh after deletion - Fixed URL construction to prevent double /dav.php path issue - Added proper error handling and user feedback 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
72 lines
2.0 KiB
Rust
72 lines
2.0 KiB
Rust
use axum::{
|
|
response::Json,
|
|
routing::{get, post},
|
|
Router,
|
|
};
|
|
use tower_http::cors::{CorsLayer, Any};
|
|
use std::sync::Arc;
|
|
|
|
mod auth;
|
|
mod models;
|
|
mod handlers;
|
|
mod calendar;
|
|
mod config;
|
|
|
|
use auth::AuthService;
|
|
|
|
#[derive(Clone)]
|
|
pub struct AppState {
|
|
pub auth_service: AuthService,
|
|
}
|
|
|
|
pub async fn run_server() -> Result<(), Box<dyn std::error::Error>> {
|
|
// Initialize logging
|
|
println!("🚀 Starting Calendar Backend Server");
|
|
|
|
// Create auth service
|
|
let jwt_secret = std::env::var("JWT_SECRET")
|
|
.unwrap_or_else(|_| "your-super-secret-jwt-key-change-in-production".to_string());
|
|
|
|
let auth_service = AuthService::new(jwt_secret);
|
|
|
|
let app_state = AppState { auth_service };
|
|
|
|
// Build our application with routes
|
|
let app = Router::new()
|
|
.route("/", get(root))
|
|
.route("/api/health", get(health_check))
|
|
.route("/api/auth/login", post(handlers::login))
|
|
.route("/api/auth/verify", get(handlers::verify_token))
|
|
.route("/api/user/info", get(handlers::get_user_info))
|
|
.route("/api/calendar/create", post(handlers::create_calendar))
|
|
.route("/api/calendar/delete", post(handlers::delete_calendar))
|
|
.route("/api/calendar/events", get(handlers::get_calendar_events))
|
|
.route("/api/calendar/events/:uid", get(handlers::refresh_event))
|
|
.layer(
|
|
CorsLayer::new()
|
|
.allow_origin(Any)
|
|
.allow_methods(Any)
|
|
.allow_headers(Any),
|
|
)
|
|
.with_state(Arc::new(app_state));
|
|
|
|
// Start server
|
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
|
|
println!("📡 Server listening on http://0.0.0.0:3000");
|
|
|
|
axum::serve(listener, app).await?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
async fn root() -> &'static str {
|
|
"Calendar Backend API v0.1.0"
|
|
}
|
|
|
|
async fn health_check() -> Json<serde_json::Value> {
|
|
Json(serde_json::json!({
|
|
"status": "healthy",
|
|
"service": "calendar-backend",
|
|
"version": "0.1.0"
|
|
}))
|
|
} |