feat: add organization branding support with database fields and API for logo upload and color customization.

This commit is contained in:
2025-12-28 22:08:03 -03:00
parent 2005545633
commit 1a2b9e473c
5 changed files with 597 additions and 146 deletions
+53 -15
View File
@@ -1,15 +1,15 @@
mod handlers;
mod handlers_branding;
use axum::{
routing::{get, post, delete},
Router,
middleware,
Router, middleware,
routing::{delete, get, post},
};
use tower_http::cors::{Any, CorsLayer};
use sqlx::postgres::PgPoolOptions;
use std::net::SocketAddr;
use dotenvy::dotenv;
use sqlx::postgres::PgPoolOptions;
use std::env;
use std::net::SocketAddr;
use tower_http::cors::{Any, CorsLayer};
#[tokio::main]
async fn main() {
@@ -36,30 +36,68 @@ async fn main() {
// Rutas protegidas que requieren autenticación y contexto de organización
let protected_routes = Router::new()
.route("/courses", get(handlers::get_courses).post(handlers::create_course))
.route("/courses/{id}", get(handlers::get_course).put(handlers::update_course))
.route(
"/courses",
get(handlers::get_courses).post(handlers::create_course),
)
.route(
"/courses/{id}",
get(handlers::get_course).put(handlers::update_course),
)
.route("/courses/{id}/publish", post(handlers::publish_course))
.route("/courses/{id}/outline", get(handlers::get_course_outline))
.route("/courses/{id}/analytics", get(handlers::get_course_analytics))
.route("/modules", get(handlers::get_modules).post(handlers::create_module))
.route(
"/courses/{id}/analytics",
get(handlers::get_course_analytics),
)
.route(
"/modules",
get(handlers::get_modules).post(handlers::create_module),
)
.route("/modules/{id}", axum::routing::put(handlers::update_module))
.route("/lessons", get(handlers::get_lessons).post(handlers::create_lesson))
.route("/lessons/{id}", get(handlers::get_lesson).put(handlers::update_lesson))
.route("/lessons/{id}/transcribe", post(handlers::process_transcription))
.route(
"/lessons",
get(handlers::get_lessons).post(handlers::create_lesson),
)
.route(
"/lessons/{id}",
get(handlers::get_lesson).put(handlers::update_lesson),
)
.route(
"/lessons/{id}/transcribe",
post(handlers::process_transcription),
)
.route("/lessons/{id}/summarize", post(handlers::summarize_lesson))
.route("/lessons/{id}/generate-quiz", post(handlers::generate_quiz))
.route("/grading", post(handlers::create_grading_category))
.route("/grading/{id}", delete(handlers::delete_grading_category))
.route("/courses/{id}/grading", get(handlers::get_grading_categories))
.route(
"/courses/{id}/grading",
get(handlers::get_grading_categories),
)
.route("/audit-logs", get(handlers::get_audit_logs))
.route("/assets/upload", post(handlers::upload_asset))
.route("/organization", get(handlers::get_organization))
.route_layer(middleware::from_fn(common::middleware::org_extractor_middleware));
.route(
"/organizations/:id/logo",
post(handlers_branding::upload_organization_logo),
)
.route(
"/organizations/:id/branding",
axum::routing::put(handlers_branding::update_organization_branding),
)
.route_layer(middleware::from_fn(
common::middleware::org_extractor_middleware,
));
// Rutas públicas que no requieren autenticación
let public_routes = Router::new()
.route("/auth/register", post(handlers::register))
.route("/auth/login", post(handlers::login))
.route(
"/organizations/:id/branding",
get(handlers_branding::get_organization_branding),
)
.nest_service("/assets", tower_http::services::ServeDir::new("uploads"))
.merge(protected_routes)
.layer(cors)